Sha256: 04e23d655e59cec9fed87fcdcc4521694860e4b998942b683fd73326205658f1

Contents?: true

Size: 831 Bytes

Versions: 8

Compression:

Stored size: 831 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('.').default;
  return value.properties.reduce((obj, property) => {
    // Support types: SpreadProperty and ExperimentalSpreadProperty
    if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) {
      if (property.argument.type === 'ObjectExpression') {
        return assign({}, obj, extractValueFromObjectExpression(property.argument));
      }
    } else {
      return assign({}, obj, { [getValue(property.key)]: getValue(property.value) });
    }
    return obj;
  }, {});
}

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.50 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.49 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.48 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.47 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.46 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
immosquare-cleaner-0.1.45 node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
decidim-0.26.8 packages/eslint-config/node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js