@babel/helper-function-name
Advanced tools
Comparing version 7.1.0 to 7.7.0
@@ -8,37 +8,15 @@ "use strict"; | ||
function _helperGetFunctionArity() { | ||
const data = _interopRequireDefault(require("@babel/helper-get-function-arity")); | ||
var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity")); | ||
_helperGetFunctionArity = function () { | ||
return data; | ||
}; | ||
var _template = _interopRequireDefault(require("@babel/template")); | ||
return data; | ||
} | ||
var t = _interopRequireWildcard(require("@babel/types")); | ||
function _template() { | ||
const data = _interopRequireDefault(require("@babel/template")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
_template = function () { | ||
return data; | ||
}; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
return data; | ||
} | ||
function t() { | ||
const data = _interopRequireWildcard(require("@babel/types")); | ||
t = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const buildPropertyMethodAssignmentWrapper = (0, _template().default)(` | ||
const buildPropertyMethodAssignmentWrapper = (0, _template.default)(` | ||
(function (FUNCTION_KEY) { | ||
@@ -56,3 +34,3 @@ function FUNCTION_ID() { | ||
`); | ||
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template().default)(` | ||
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template.default)(` | ||
(function (FUNCTION_KEY) { | ||
@@ -82,11 +60,11 @@ function* FUNCTION_ID() { | ||
function getNameFromLiteralId(id) { | ||
if (t().isNullLiteral(id)) { | ||
if (t.isNullLiteral(id)) { | ||
return "null"; | ||
} | ||
if (t().isRegExpLiteral(id)) { | ||
if (t.isRegExpLiteral(id)) { | ||
return `_${id.pattern}_${id.flags}`; | ||
} | ||
if (t().isTemplateLiteral(id)) { | ||
if (t.isTemplateLiteral(id)) { | ||
return id.quasis.map(quasi => quasi.value.raw).join(""); | ||
@@ -107,3 +85,3 @@ } | ||
} else { | ||
if (!t().isFunction(method)) return; | ||
if (!t.isFunction(method)) return; | ||
let build = buildPropertyMethodAssignmentWrapper; | ||
@@ -122,3 +100,3 @@ | ||
for (let i = 0, len = (0, _helperGetFunctionArity().default)(method); i < len; i++) { | ||
for (let i = 0, len = (0, _helperGetFunctionArity.default)(method); i < len; i++) { | ||
params.push(scope.generateUidIdentifier("x")); | ||
@@ -164,19 +142,19 @@ } | ||
if ((t().isObjectProperty(parent) || t().isObjectMethod(parent, { | ||
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { | ||
kind: "method" | ||
})) && (!parent.computed || t().isLiteral(parent.key))) { | ||
})) && (!parent.computed || t.isLiteral(parent.key))) { | ||
id = parent.key; | ||
} else if (t().isVariableDeclarator(parent)) { | ||
} else if (t.isVariableDeclarator(parent)) { | ||
id = parent.id; | ||
if (t().isIdentifier(id) && !localBinding) { | ||
if (t.isIdentifier(id) && !localBinding) { | ||
const binding = scope.parent.getBinding(id.name); | ||
if (binding && binding.constant && scope.getBinding(id.name) === binding) { | ||
node.id = t().cloneNode(id); | ||
node.id[t().NOT_LOCAL_BINDING] = true; | ||
node.id = t.cloneNode(id); | ||
node.id[t.NOT_LOCAL_BINDING] = true; | ||
return; | ||
} | ||
} | ||
} else if (t().isAssignmentExpression(parent)) { | ||
} else if (t.isAssignmentExpression(parent)) { | ||
id = parent.left; | ||
@@ -189,5 +167,5 @@ } else if (!id) { | ||
if (id && t().isLiteral(id)) { | ||
if (id && t.isLiteral(id)) { | ||
name = getNameFromLiteralId(id); | ||
} else if (id && t().isIdentifier(id)) { | ||
} else if (id && t.isIdentifier(id)) { | ||
name = id.name; | ||
@@ -200,7 +178,7 @@ } | ||
name = t().toBindingIdentifierName(name); | ||
id = t().identifier(name); | ||
id[t().NOT_LOCAL_BINDING] = true; | ||
name = t.toBindingIdentifierName(name); | ||
id = t.identifier(name); | ||
id[t.NOT_LOCAL_BINDING] = true; | ||
const state = visit(node, name, scope); | ||
return wrap(state, node, id, scope) || node; | ||
} |
{ | ||
"name": "@babel/helper-function-name", | ||
"version": "7.1.0", | ||
"version": "7.7.0", | ||
"description": "Helper function to change the property 'name' of every function", | ||
@@ -12,6 +12,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name", | ||
"dependencies": { | ||
"@babel/helper-get-function-arity": "^7.0.0", | ||
"@babel/template": "^7.1.0", | ||
"@babel/types": "^7.0.0" | ||
} | ||
"@babel/helper-get-function-arity": "^7.7.0", | ||
"@babel/template": "^7.7.0", | ||
"@babel/types": "^7.7.0" | ||
}, | ||
"gitHead": "97faa83953cb87e332554fa559a4956d202343ea" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7062
142
1
Updated@babel/template@^7.7.0
Updated@babel/types@^7.7.0