Sha256: 54a20a36c8180073f5dec78487c0fc2ca0dea361ab75ae23459b8560b6f0a350
Contents?: true
Size: 834 Bytes
Versions: 25
Compression:
Stored size: 834 Bytes
Contents
/** * Extractor function for an ObjectExpression type value node. * An object expression is using {}. * * @returns - a representation of the object */ export default function extractValueFromObjectExpression(value) { // eslint-disable-next-line global-require const getValue = require('./index.js').default; return value.properties.reduce((obj, property) => { const object = Object.assign({}, obj); // Support types: SpreadProperty and ExperimentalSpreadProperty if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) { if (property.argument.type === 'ObjectExpression') { return Object.assign(object, extractValueFromObjectExpression(property.argument)); } } else { object[getValue(property.key)] = getValue(property.value); } return object; }, {}); }
Version data entries
25 entries across 25 versions & 1 rubygems