Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function exit(node) {
switch (node.type) {
case Syntax.CallExpression:
if (shouldCache(node.callee)) {
return build.callExpression(
build.identifier('incrementalize'),
[node.callee, build.arrayExpression(node.arguments)]
);
}
default:
}
}
fields.push(generateField(model.fields[fieldName], null, name, model));
refs = where(model.references, { refField: fieldName });
for (var i = 0; i < refs.length; i++) {
fields.push(generateReferenceField(model.fields[fieldName], refs[i]));
}
}
model.listReferences.forEach(function(ref) {
fields.push(generateListReferenceField(ref));
});
var interfaces = opts.relay && b.property(
'init',
b.identifier('interfaces'),
b.arrayExpression([b.identifier('nodeInterface')])
);
var typeDeclaration = b.objectExpression([
b.property('init', b.identifier('name'), b.literal(name)),
generateDescription(model.description),
b.property(
'init',
b.identifier('fields'),
buildFieldWrapperFunction(name, b.objectExpression(fields), opts)
)
].concat(interfaces || []));
return {
ast: buildVar(
name + 'Type',
b.newExpression(
return atomizeStar(elements, function(elements) {
return metaK(build.arrayExpression(elements));
});
}),
function mapArrayExpression(node: CNode, meta: Object) {
return b.arrayExpression(node.objects.map(expr => mapExpression(expr, meta)));
}
(v) => b.arrayExpression(v.map(_convertValToAST))))]);
}
export default function resolveObjectKeysToArray(path: NodePath): ?NodePath {
const node = path.node;
if (isObjectKeysCall(node)) {
const objectExpression = resolveToValue(path.get('arguments').get(0));
const values = resolveObjectToNameArray(objectExpression);
if (values) {
const nodes = values
.filter((value, index, array) => array.indexOf(value) === index)
.map(value => builders.literal(value));
return new NodePath(builders.arrayExpression(nodes));
}
}
return null;
}
export function buildArray(data: any[]): ESTree.ArrayExpression {
return b.arrayExpression(
data.map(element => buildValue(element))
);
}
function _convertValToAST(value) {
if (Array.isArray(value)) {
return b.arrayExpression(value.map(_convertValToAST));
}
if (value instanceof Map) {
return b.newExpression(
b.identifier('Map'),
[b.arrayExpression(Array.from(value).map(
(v) => b.arrayExpression(v.map(_convertValToAST))))]);
}
if (value instanceof Set) {
return b.newExpression(
b.identifier('Set'),
[b.arrayExpression(Array.from(value).map(_convertValToAST))]);
}
if (namedTypes.Node.check(value)) {
return value;
}
return b.literal(value);
}
if (fieldref !== null) {
read_stmts.push(b.variableDeclaration(
'var',
[b.variableDeclarator(
b.identifier(`${child_name}_length`),
fieldref)]));
}
write_stmts.push(b.variableDeclaration(
'var',
[b.variableDeclarator(
b.identifier(`${child_name}_length`),
fieldref)]));
read_stmts.push(b.expressionStatement(b.assignmentExpression(
'=',
b.memberExpression(b.identifier('obj'), b.identifier(child_name)),
b.arrayExpression([]))));
let read_stmt = b.expressionStatement(b.callExpression(
b.memberExpression(
b.memberExpression(
b.identifier('obj'), b.identifier(child_name)),
b.identifier('push')),
[b.callExpression(
b.memberExpression(
b.thisExpression(), b.identifier(`read${child_type}`)),
[])]));
if (fieldref === null) {
read_stmts.push(
b.whileStatement(
b.binaryExpression(
'<',
b.memberExpression(