Spaces:
Running
Running
File size: 1,074 Bytes
1df763a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = optimiseCallExpression;
var _t = require("@babel/types");
const {
callExpression,
identifier,
isIdentifier,
isSpreadElement,
memberExpression,
optionalCallExpression,
optionalMemberExpression
} = _t;
function optimiseCallExpression(callee, thisNode, args, optional) {
if (args.length === 1 && isSpreadElement(args[0]) && isIdentifier(args[0].argument, {
name: "arguments"
})) {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("apply"), false, true), [thisNode, args[0].argument], false);
}
return callExpression(memberExpression(callee, identifier("apply")), [thisNode, args[0].argument]);
} else {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("call"), false, true), [thisNode, ...args], false);
}
return callExpression(memberExpression(callee, identifier("call")), [thisNode, ...args]);
}
}
//# sourceMappingURL=index.js.map
|