Files
old-slucajna-televizija/web/node_modules/jsx-ast-utils/src/values/expressions/ObjectExpression.js
2017-10-16 11:19:46 +02:00

16 lines
446 B
JavaScript

import getValue from './index';
/**
* Extractor function for an ObjectExpression type value node.
* An object expression is using {}.
*
* @returns - a representation of the object
*/
export default function extractValueFromObjectExpression(value) {
return value.properties.reduce((obj, property) => {
const object = Object.assign({}, obj);
object[getValue(property.key)] = getValue(property.value);
return object;
}, {});
}