Sha256: 52ed9e9acb8ea256b150f3abcdb2841ca7a561e63bd630f215cfb1f797391a84
Contents?: true
Size: 864 Bytes
Versions: 18
Compression:
Stored size: 864 Bytes
Contents
import assign from 'object.assign'; /** * 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 assign(object, extractValueFromObjectExpression(property.argument)); } } else { object[getValue(property.key)] = getValue(property.value); } return object; }, {}); }
Version data entries
18 entries across 18 versions & 1 rubygems