How to use the ast-types.builders.arrayExpression function in ast-types

To help you get started, we’ve selected a few ast-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github probmods / webppl / src / transforms / caching.js View on Github external
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:
  }
}
github rexxars / sql-to-graphql / steps / generate-types.js View on Github external
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(
github probmods / webppl / src / transforms / cps.js View on Github external
return atomizeStar(elements, function(elements) {
        return metaK(build.arrayExpression(elements));
      });
    }),
github rainforestapp / decaf / src / parser.js View on Github external
function mapArrayExpression(node: CNode, meta: Object) {
  return b.arrayExpression(node.objects.map(expr => mapExpression(expr, meta)));
}
github GothAck / javascript-x-server / autogen / lib / misc.js View on Github external
        (v) => b.arrayExpression(v.map(_convertValToAST))))]);
  }
github reactjs / react-docgen / src / utils / resolveObjectKeysToArray.js View on Github external
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;
}
github paeckchen / paeckchen / packages / paeckchen-core / src / bundle-json.ts View on Github external
export function buildArray(data: any[]): ESTree.ArrayExpression {
  return b.arrayExpression(
    data.map(element => buildValue(element))
  );
}
github GothAck / javascript-x-server / autogen / lib / misc.js View on Github external
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);
}
github GothAck / javascript-x-server / autogen / lib / statement_body.js View on Github external
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(