How to use the babel-types.arrayExpression function in babel-types

To help you get started, we’ve selected a few babel-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 babel / babel / packages / babel-plugin-transform-regenerator / lib / emit.js View on Github external
var ce = tryEntry.catchEntry;
      var fe = tryEntry.finallyEntry;

      var locs = [
        tryEntry.firstLoc,
        // The null here makes a hole in the array.
        ce ? ce.firstLoc : null
      ];

      if (fe) {
        locs[2] = fe.firstLoc;
        locs[3] = fe.afterLoc;
      }

      return t.arrayExpression(locs);
    })
  );
github M0nica / React-Ladies / node_modules / regenerator-transform / src / emit.js View on Github external
let ce = tryEntry.catchEntry;
      let fe = tryEntry.finallyEntry;

      let locs = [
        tryEntry.firstLoc,
        // The null here makes a hole in the array.
        ce ? ce.firstLoc : null
      ];

      if (fe) {
        locs[2] = fe.firstLoc;
        locs[3] = fe.afterLoc;
      }

      return t.arrayExpression(locs);
    })
  );
github NervJS / taro / packages / taro-cli / src / util / resolve_npm_files.ts View on Github external
CallExpression (astPath) {
            const node = astPath.node
            const callee = node.callee as t.Identifier
            if (callee.name === 'require') {
              const args = node.arguments as Array
              const requirePath = args[0].value
              if (REG_JSON.test(requirePath)) {
                const realRequirePath = path.resolve(path.dirname(filePath), requirePath)
                if (fs.existsSync(realRequirePath)) {
                  const obj = JSON.parse(fs.readFileSync(realRequirePath).toString())
                  let objArr: t.NullLiteral | t.Expression | t.ObjectProperty[] = t.nullLiteral()
                  if (Array.isArray(obj)) {
                    objArr = t.arrayExpression(convertArrayToAstExpression(obj))
                  } else {
                    objArr = convertObjectToAstExpression(obj)
                  }
                  astPath.replaceWith(t.objectExpression(objArr as any))
                }
                return
              }
              analyzeImportUrl({
                requirePath,
                excludeRequire,
                source: args[0],
                filePath,
                files,
                isProduction,
                npmConfig,
                rootNpm,
github Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / weapp.js View on Github external
astPath.parentPath.remove()
                    } else if (astPath.parent.type === 'VariableDeclarator') {
                      astPath.parentPath.parentPath.remove()
                    } else {
                      astPath.remove()
                    }
                  } else if (Util.REG_JSON.test(valueExtname)) {
                    const vpath = path.resolve(sourceFilePath, '..', value)
                    if (jsonFiles.indexOf(vpath) < 0) {
                      jsonFiles.push(vpath)
                    }
                    if (fs.existsSync(vpath)) {
                      const obj = JSON.parse(fs.readFileSync(vpath).toString())
                      let objArr = [t.nullLiteral()]
                      if (Array.isArray(obj)) {
                        objArr = t.arrayExpression(astConvert.array(obj))
                      } else {
                        objArr = t.objectExpression(astConvert.obj(obj))
                      }
                      astPath.replaceWith(t.objectExpression(objArr))
                    }
                  } else if (Util.REG_SCRIPT.test(valueExtname) || Util.REG_TYPESCRIPT.test(valueExtname)) {
                    const vpath = path.resolve(sourceFilePath, '..', value)
                    let fPath = value
                    if (fs.existsSync(vpath) && vpath !== sourceFilePath) {
                      fPath = vpath
                    }
                    if (scriptFiles.indexOf(fPath) < 0) {
                      scriptFiles.push(fPath)
                    }
                  } else if (Util.REG_FONT.test(valueExtname) || Util.REG_IMAGE.test(valueExtname) || Util.REG_MEDIA.test(valueExtname)) {
                    const vpath = path.resolve(sourceFilePath, '..', value)
github salesforce / lwc / packages / raptor-template-compiler / src / codegen / index.ts View on Github external
function transform(
    root: IRNode,
    codeGen: CodeGen,
    state: State,
): t.Expression {

    const stack = new Stack();
    stack.push(
        t.arrayExpression([]),
    );

    traverse(root, {
        text: {
            exit(textNode: IRText) {
                let { value }  = textNode;

                if (typeof value !== 'string') {
                    value = bindExpression(value, textNode).expression as t.MemberExpression;
                }

                (stack.peek() as t.ArrayExpression).elements.push(
                    codeGen.genText(value),
                );
            },
        },
github Tencent / omi / packages / omip / taro-transformer-wx / src / class.ts View on Github external
if (binded) args.shift()
          path.replaceWith(
            t.callExpression(
              t.memberExpression(t.thisExpression(), t.identifier('__triggerPropsFn')),
              [
                t.stringLiteral(propertyArray.reverse().join('.')),
                t.arrayExpression(args)
              ]
            )
          )
        } else {
          path.replaceWith(
            t.callExpression(
              t.memberExpression(t.thisExpression(), t.identifier('__triggerPropsFn')),
              [t.stringLiteral(propertyArray.reverse().join('.')), t.callExpression(
                t.memberExpression(t.arrayExpression([t.nullLiteral()]), t.identifier('concat')),
                [t.arrayExpression(args)]
              )]
            )
          )
        }
      }
      traverseMember(object)
    }
  }
  traverseMember(member)
github krasimir / cssx / packages / cssx-transpiler / src / visitors / CSSXDefinition.js View on Github external
rulesRegistration = rulesRegistration.reduce(function (result, current) {
      var name;

      if (current.expression && current.expression.left) {
        name = current.expression.left.property.value;
        if (name && rulesBuffer[name]) {
          if (result[rulesBuffer[name].index].expression.right.type === 'ArrayExpression') {
            result[rulesBuffer[name].index].expression.right.elements.push(
              t.identifier(current.expression.right.name)
            );
          } else {
            result[rulesBuffer[name].index].expression.right = t.arrayExpression([
              t.identifier(rulesBuffer[name].rule.expression.right.name),
              t.identifier(current.expression.right.name)
            ]);
          }
        } else {
          rulesBuffer[name] = { index: result.length, rule: current };
          result.push(current);
        }
      }
      return result;
    }, []);
github babel / babel / packages / babel-core / src / transformation / modules / system.js View on Github external
_buildRunnerSetters(block, hoistDeclarators) {
    let scope = this.file.scope;

    return t.arrayExpression(map(this.ids, function (uid, source) {
      let state = {
        hoistDeclarators: hoistDeclarators,
        source:           source,
        nodes:            []
      };

      scope.traverse(block, runnerSettersVisitor, state);

      return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
    }));
  }
github sx1989827 / DOClever / SBDocClient / node_modules / regenerator-transform / src / visit.js View on Github external
function getRuntimeMarkDecl(blockPath) {
  let block = blockPath.node;
  assert.ok(Array.isArray(block.body));

  let info = getMarkInfo(block);
  if (info.decl) {
    return info.decl;
  }

  info.decl = t.variableDeclaration("var", [
    t.variableDeclarator(
      blockPath.scope.generateUidIdentifier("marked"),
      t.callExpression(
        t.memberExpression(
          t.arrayExpression([]),
          t.identifier("map"),
          false
        ),
        [util.runtimeProperty("mark")]
      )
    )
  ]);

  blockPath.unshiftContainer("body", info.decl);

  return info.decl;
}
github Tencent / omi / packages / cax-omip / scripts / taro-transformer-wx / lib / src / class.js View on Github external
handleRefs() {
        const objExpr = this.refs.map(ref => {
            return t.objectExpression([
                t.objectProperty(t.identifier('type'), t.stringLiteral(ref.type)),
                t.objectProperty(t.identifier('id'), t.stringLiteral(ref.id)),
                t.objectProperty(t.identifier('refName'), t.stringLiteral(ref.refName || '')),
                t.objectProperty(t.identifier('fn'), ref.fn ? ref.fn : t.nullLiteral())
            ]);
        });
        this.classPath.node.body.body.push(t.classProperty(t.identifier('$$refs'), t.arrayExpression(objExpr)));
    }
    traverse() {