How to use the esprima-fb.Syntax.NewExpression function in esprima-fb

To help you get started, we’ve selected a few esprima-fb 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 facebookarchive / jstransform / visitors / es6-call-spread-visitors.js View on Github external
function visitCallSpread(traverse, node, path, state) {
  utils.catchup(node.range[0], state);

  if (node.type === Syntax.NewExpression) {
    // Input  = new Set(1, 2, ...list)
    // Output = new (Function.prototype.bind.apply(Set, [null, 1, 2].concat(list)))
    utils.append('new (Function.prototype.bind.apply(', state);
    process(traverse, node.callee, path, state);
  } else if (node.callee.type === Syntax.MemberExpression) {
    // Input  = get().fn(1, 2, ...more)
    // Output = (_ = get()).fn.apply(_, [1, 2].apply(more))
    var tempVar = utils.injectTempVar(state);
    utils.append('(' + tempVar + ' = ', state);
    process(traverse, node.callee.object, path, state);
    utils.append(')', state);
    if (node.callee.property.type === Syntax.Identifier) {
      utils.append('.', state);
      process(traverse, node.callee.property, path, state);
    } else {
      utils.append('[', state);
github Zach417 / churchetto-web / node_modules / envify / node_modules / jstransform / visitors / es6-call-spread-visitors.js View on Github external
function visitCallSpread(traverse, node, path, state) {
  utils.catchup(node.range[0], state);

  if (node.type === Syntax.NewExpression) {
    // Input  = new Set(1, 2, ...list)
    // Output = new (Function.prototype.bind.apply(Set, [null, 1, 2].concat(list)))
    utils.append('new (Function.prototype.bind.apply(', state);
    process(traverse, node.callee, path, state);
  } else if (node.callee.type === Syntax.MemberExpression) {
    // Input  = get().fn(1, 2, ...more)
    // Output = (_ = get()).fn.apply(_, [1, 2].apply(more))
    var tempVar = utils.injectTempVar(state);
    utils.append('(' + tempVar + ' = ', state);
    process(traverse, node.callee.object, path, state);
    utils.append(')', state);
    if (node.callee.property.type === Syntax.Identifier) {
      utils.append('.', state);
      process(traverse, node.callee.property, path, state);
    } else {
      utils.append('[', state);
github joshuaslate / saas-tutorial / node_modules / jstransform / visitors / es6-call-spread-visitors.js View on Github external
visitCallSpread.test = function(node, path, state) {
  return (
    (
      node.type === Syntax.CallExpression ||
      node.type === Syntax.NewExpression
    ) &&
    node.arguments.length > 0 &&
    node.arguments[node.arguments.length - 1].type === Syntax.SpreadElement
  );
};
github computers-are-fast / computers-are-fast.github.io / jspm_packages / npm / jstransform@10.1.0 / visitors / es6-call-spread-visitors.js View on Github external
var arg = args.shift();
        utils.move(arg.range[0], state);
        traverse(arg, path, state);
        if (args.length) {
          utils.catchup(args[0].range[0], state);
        } else {
          utils.catchup(arg.range[1], state);
        }
      }
      utils.append('].concat(', state);
      process(traverse, spread.argument, path, state);
      utils.append(')', state);
    } else {
      process(traverse, spread.argument, path, state);
    }
    utils.append(node.type === Syntax.NewExpression ? '))' : ')', state);
    utils.move(node.range[1], state);
    return false;
  }
  visitCallSpread.test = function(node, path, state) {
github Zach417 / churchetto-web / node_modules / envify / node_modules / jstransform / visitors / es6-call-spread-visitors.js View on Github external
node.callee.type === Syntax.FunctionDeclaration ||
      node.callee.type === Syntax.FunctionExpression;
    if (needsToBeWrappedInParenthesis) {
      utils.append('(', state);
    }
    process(traverse, node.callee, path, state);
    if (needsToBeWrappedInParenthesis) {
      utils.append(')', state);
    }
    utils.append('.apply(undefined', state);
  }
  utils.append(', ', state);

  var args = node.arguments.slice();
  var spread = args.pop();
  if (args.length || node.type === Syntax.NewExpression) {
    utils.append('[', state);
    if (node.type === Syntax.NewExpression) {
      utils.append('null' + (args.length ? ', ' : ''), state);
    }
    while (args.length) {
      var arg = args.shift();
      utils.move(arg.range[0], state);
      traverse(arg, path, state);
      if (args.length) {
        utils.catchup(args[0].range[0], state);
      } else {
        utils.catchup(arg.range[1], state);
      }
    }
    utils.append('].concat(', state);
    process(traverse, spread.argument, path, state);
github joshuaslate / saas-tutorial / node_modules / jstransform / visitors / es6-call-spread-visitors.js View on Github external
var arg = args.shift();
      utils.move(arg.range[0], state);
      traverse(arg, path, state);
      if (args.length) {
        utils.catchup(args[0].range[0], state);
      } else {
        utils.catchup(arg.range[1], state);
      }
    }
    utils.append('].concat(', state);
    process(traverse, spread.argument, path, state);
    utils.append(')', state);
  } else {
    process(traverse, spread.argument, path, state);
  }
  utils.append(node.type === Syntax.NewExpression ? '))' : ')', state);

  utils.move(node.range[1], state);
  return false;
}
github facebookarchive / jstransform / visitors / es7-trailing-comma-visitors.js View on Github external
visitFunctionCallArguments.test = function(node, path, state) {
  return (
    node.type === Syntax.CallExpression ||
    node.type === Syntax.NewExpression
  ) && (
    node['arguments'].length > 0
  );
};
github computers-are-fast / computers-are-fast.github.io / jspm_packages / npm / jstransform@10.1.0 / visitors / es6-call-spread-visitors.js View on Github external
function visitCallSpread(traverse, node, path, state) {
    utils.catchup(node.range[0], state);
    if (node.type === Syntax.NewExpression) {
      utils.append('new (Function.prototype.bind.apply(', state);
      process(traverse, node.callee, path, state);
    } else if (node.callee.type === Syntax.MemberExpression) {
      var tempVar = utils.injectTempVar(state);
      utils.append('(' + tempVar + ' = ', state);
      process(traverse, node.callee.object, path, state);
      utils.append(')', state);
      if (node.callee.property.type === Syntax.Identifier) {
        utils.append('.', state);
        process(traverse, node.callee.property, path, state);
      } else {
        utils.append('[', state);
        process(traverse, node.callee.property, path, state);
        utils.append(']', state);
      }
      utils.append('.apply(' + tempVar, state);
github facebookarchive / jstransform / visitors / es6-call-spread-visitors.js View on Github external
var arg = args.shift();
      utils.move(arg.range[0], state);
      traverse(arg, path, state);
      if (args.length) {
        utils.catchup(args[0].range[0], state);
      } else {
        utils.catchup(arg.range[1], state);
      }
    }
    utils.append('].concat(', state);
    process(traverse, spread.argument, path, state);
    utils.append(')', state);
  } else {
    process(traverse, spread.argument, path, state);
  }
  utils.append(node.type === Syntax.NewExpression ? '))' : ')', state);

  utils.move(node.range[1], state);
  return false;
}