How to use babel-helper-optimise-call-expression - 2 common examples

To help you get started, we’ve selected a few babel-helper-optimise-call-expression 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-es2015-classes / src / vanilla.js View on Github external
wrapSuperCall(bareSuper, superRef, thisRef, body) {
    let bareSuperNode = bareSuper.node;

    if (this.isLoose) {
      bareSuperNode.arguments.unshift(t.thisExpression());
      if (bareSuperNode.arguments.length === 2 && t.isSpreadElement(bareSuperNode.arguments[1]) && t.isIdentifier(bareSuperNode.arguments[1].argument, { name: "arguments" })) {
        // special case single arguments spread
        bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument;
        bareSuperNode.callee = t.memberExpression(superRef, t.identifier("apply"));
      } else {
        bareSuperNode.callee = t.memberExpression(superRef, t.identifier("call"));
      }
    } else {
      bareSuperNode = optimiseCall(
        t.callExpression(
          t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
          [this.classRef]
        ),
        t.thisExpression(),
        bareSuperNode.arguments
      );
    }

    let call = t.callExpression(
      this.file.addHelper("possibleConstructorReturn"),
      [t.thisExpression(), bareSuperNode]
    );

    let bareSuperAfter = this.bareSuperAfter.map((fn) => fn(thisRef));
github babel / babel / packages / babel-helper-replace-supers / src / index.js View on Github external
optimiseCall(callee, args) {
    let thisNode = t.thisExpression();
    thisNode[HARDCORE_THIS_REF] = true;
    return optimiseCall(callee, thisNode, args);
  }
}

babel-helper-optimise-call-expression

Helper function to optimise call expression

MIT
Latest version published 8 years ago

Package Health Score

88 / 100
Full package analysis

Popular babel-helper-optimise-call-expression functions

Similar packages