committed by
GitHub
parent
20d2b4f98d
commit
e4f3964f67
25
node_modules/@babel/helper-function-name/lib/index.js
generated
vendored
25
node_modules/@babel/helper-function-name/lib/index.js
generated
vendored
@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = _default;
|
||||
|
||||
var _helperGetFunctionArity = require("@babel/helper-get-function-arity");
|
||||
|
||||
var _template = require("@babel/template");
|
||||
|
||||
var _t = require("@babel/types");
|
||||
@ -16,6 +14,7 @@ const {
|
||||
cloneNode,
|
||||
identifier,
|
||||
isAssignmentExpression,
|
||||
isAssignmentPattern,
|
||||
isFunction,
|
||||
isIdentifier,
|
||||
isLiteral,
|
||||
@ -23,11 +22,18 @@ const {
|
||||
isObjectMethod,
|
||||
isObjectProperty,
|
||||
isRegExpLiteral,
|
||||
isRestElement,
|
||||
isTemplateLiteral,
|
||||
isVariableDeclarator,
|
||||
toBindingIdentifierName
|
||||
} = _t;
|
||||
const buildPropertyMethodAssignmentWrapper = (0, _template.default)(`
|
||||
|
||||
function getFunctionArity(node) {
|
||||
const count = node.params.findIndex(param => isAssignmentPattern(param) || isRestElement(param));
|
||||
return count === -1 ? node.params.length : count;
|
||||
}
|
||||
|
||||
const buildPropertyMethodAssignmentWrapper = _template.default.statement(`
|
||||
(function (FUNCTION_KEY) {
|
||||
function FUNCTION_ID() {
|
||||
return FUNCTION_KEY.apply(this, arguments);
|
||||
@ -40,7 +46,8 @@ const buildPropertyMethodAssignmentWrapper = (0, _template.default)(`
|
||||
return FUNCTION_ID;
|
||||
})(FUNCTION)
|
||||
`);
|
||||
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(`
|
||||
|
||||
const buildGeneratorPropertyMethodAssignmentWrapper = _template.default.statement(`
|
||||
(function (FUNCTION_KEY) {
|
||||
function* FUNCTION_ID() {
|
||||
return yield* FUNCTION_KEY.apply(this, arguments);
|
||||
@ -53,6 +60,7 @@ const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(`
|
||||
return FUNCTION_ID;
|
||||
})(FUNCTION)
|
||||
`);
|
||||
|
||||
const visitor = {
|
||||
"ReferencedIdentifier|BindingIdentifier"(path, state) {
|
||||
if (path.node.name !== state.name) return;
|
||||
@ -103,7 +111,7 @@ function wrap(state, method, id, scope) {
|
||||
}).expression;
|
||||
const params = template.callee.body.body[0].params;
|
||||
|
||||
for (let i = 0, len = (0, _helperGetFunctionArity.default)(method); i < len; i++) {
|
||||
for (let i = 0, len = getFunctionArity(method); i < len; i++) {
|
||||
params.push(scope.generateUidIdentifier("x"));
|
||||
}
|
||||
|
||||
@ -120,7 +128,6 @@ function visit(node, name, scope) {
|
||||
selfAssignment: false,
|
||||
selfReference: false,
|
||||
outerDeclar: scope.getBindingIdentifier(name),
|
||||
references: [],
|
||||
name: name
|
||||
};
|
||||
const binding = scope.getOwnBinding(name);
|
||||
@ -185,8 +192,8 @@ function _default({
|
||||
}
|
||||
|
||||
name = toBindingIdentifierName(name);
|
||||
id = identifier(name);
|
||||
id[NOT_LOCAL_BINDING] = true;
|
||||
const newId = identifier(name);
|
||||
newId[NOT_LOCAL_BINDING] = true;
|
||||
const state = visit(node, name, scope);
|
||||
return wrap(state, node, id, scope) || node;
|
||||
return wrap(state, node, newId, scope) || node;
|
||||
}
|
Reference in New Issue
Block a user