Permalink
Cannot retrieve contributors at this time
38 lines (31 sloc)
1.36 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/jsx-ast-utils/lib/values/expressions/ObjectExpression.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
exports.default = extractValueFromObjectExpression; | |
var _object = require('object.assign'); | |
var _object2 = _interopRequireDefault(_object); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
/** | |
* Extractor function for an ObjectExpression type value node. | |
* An object expression is using {}. | |
* | |
* @returns - a representation of the object | |
*/ | |
function extractValueFromObjectExpression(value) { | |
// eslint-disable-next-line global-require | |
var getValue = require('.').default; | |
return value.properties.reduce(function (obj, property) { | |
var object = _extends({}, obj); | |
// Support types: SpreadProperty and ExperimentalSpreadProperty | |
if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) { | |
if (property.argument.type === 'ObjectExpression') { | |
return (0, _object2.default)(object, extractValueFromObjectExpression(property.argument)); | |
} | |
} else { | |
object[getValue(property.key)] = getValue(property.value); | |
} | |
return object; | |
}, {}); | |
} |