@babel/helper-function-name
Advanced tools
Comparing version 7.0.0-beta.46 to 7.0.0-beta.47
@@ -9,3 +9,3 @@ "use strict"; | ||
function _helperGetFunctionArity() { | ||
var data = _interopRequireDefault(require("@babel/helper-get-function-arity")); | ||
const data = _interopRequireDefault(require("@babel/helper-get-function-arity")); | ||
@@ -19,6 +19,6 @@ _helperGetFunctionArity = function _helperGetFunctionArity() { | ||
function _template2() { | ||
var data = _interopRequireDefault(require("@babel/template")); | ||
function _template() { | ||
const data = _interopRequireDefault(require("@babel/template")); | ||
_template2 = function _template2() { | ||
_template = function _template() { | ||
return data; | ||
@@ -31,3 +31,3 @@ }; | ||
function t() { | ||
var data = _interopRequireWildcard(require("@babel/types")); | ||
const data = _interopRequireWildcard(require("@babel/types")); | ||
@@ -45,8 +45,32 @@ t = function t() { | ||
var buildPropertyMethodAssignmentWrapper = (0, _template2().default)("\n (function (FUNCTION_KEY) {\n function FUNCTION_ID() {\n return FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n }\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); | ||
var buildGeneratorPropertyMethodAssignmentWrapper = (0, _template2().default)("\n (function (FUNCTION_KEY) {\n function* FUNCTION_ID() {\n return yield* FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n };\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); | ||
var visitor = { | ||
"ReferencedIdentifier|BindingIdentifier": function ReferencedIdentifierBindingIdentifier(path, state) { | ||
const buildPropertyMethodAssignmentWrapper = (0, _template().default)(` | ||
(function (FUNCTION_KEY) { | ||
function FUNCTION_ID() { | ||
return FUNCTION_KEY.apply(this, arguments); | ||
} | ||
FUNCTION_ID.toString = function () { | ||
return FUNCTION_KEY.toString(); | ||
} | ||
return FUNCTION_ID; | ||
})(FUNCTION) | ||
`); | ||
const buildGeneratorPropertyMethodAssignmentWrapper = (0, _template().default)(` | ||
(function (FUNCTION_KEY) { | ||
function* FUNCTION_ID() { | ||
return yield* FUNCTION_KEY.apply(this, arguments); | ||
} | ||
FUNCTION_ID.toString = function () { | ||
return FUNCTION_KEY.toString(); | ||
}; | ||
return FUNCTION_ID; | ||
})(FUNCTION) | ||
`); | ||
const visitor = { | ||
"ReferencedIdentifier|BindingIdentifier"(path, state) { | ||
if (path.node.name !== state.name) return; | ||
var localDeclar = path.scope.getBindingIdentifier(state.name); | ||
const localDeclar = path.scope.getBindingIdentifier(state.name); | ||
if (localDeclar !== state.outerDeclar) return; | ||
@@ -56,2 +80,3 @@ state.selfReference = true; | ||
} | ||
}; | ||
@@ -65,9 +90,7 @@ | ||
if (t().isRegExpLiteral(id)) { | ||
return "_" + id.pattern + "_" + id.flags; | ||
return `_${id.pattern}_${id.flags}`; | ||
} | ||
if (t().isTemplateLiteral(id)) { | ||
return id.quasis.map(function (quasi) { | ||
return quasi.value.raw; | ||
}).join(""); | ||
return id.quasis.map(quasi => quasi.value.raw).join(""); | ||
} | ||
@@ -88,3 +111,3 @@ | ||
if (!t().isFunction(method)) return; | ||
var build = buildPropertyMethodAssignmentWrapper; | ||
let build = buildPropertyMethodAssignmentWrapper; | ||
@@ -95,3 +118,3 @@ if (method.generator) { | ||
var _template = build({ | ||
const template = build({ | ||
FUNCTION: method, | ||
@@ -101,9 +124,9 @@ FUNCTION_ID: id, | ||
}).expression; | ||
var params = _template.callee.body.body[0].params; | ||
const params = template.callee.body.body[0].params; | ||
for (var 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")); | ||
} | ||
return _template; | ||
return template; | ||
} | ||
@@ -117,3 +140,3 @@ } | ||
function visit(node, name, scope) { | ||
var state = { | ||
const state = { | ||
selfAssignment: false, | ||
@@ -125,3 +148,3 @@ selfReference: false, | ||
}; | ||
var binding = scope.getOwnBinding(name); | ||
const binding = scope.getOwnBinding(name); | ||
@@ -139,12 +162,8 @@ if (binding) { | ||
function _default(_ref, localBinding) { | ||
var node = _ref.node, | ||
parent = _ref.parent, | ||
scope = _ref.scope, | ||
id = _ref.id; | ||
if (localBinding === void 0) { | ||
localBinding = false; | ||
} | ||
function _default({ | ||
node, | ||
parent, | ||
scope, | ||
id | ||
}, localBinding = false) { | ||
if (node.id) return; | ||
@@ -160,3 +179,3 @@ | ||
if (t().isIdentifier(id) && !localBinding) { | ||
var binding = scope.parent.getBinding(id.name); | ||
const binding = scope.parent.getBinding(id.name); | ||
@@ -175,3 +194,3 @@ if (binding && binding.constant && scope.getBinding(id.name) === binding) { | ||
var name; | ||
let name; | ||
@@ -191,4 +210,4 @@ if (id && t().isLiteral(id)) { | ||
id[t().NOT_LOCAL_BINDING] = true; | ||
var state = visit(node, name, scope); | ||
const state = visit(node, name, scope); | ||
return wrap(state, node, id, scope) || node; | ||
} |
{ | ||
"name": "@babel/helper-function-name", | ||
"version": "7.0.0-beta.46", | ||
"version": "7.0.0-beta.47", | ||
"description": "Helper function to change the property 'name' of every function", | ||
@@ -9,6 +9,6 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name", | ||
"dependencies": { | ||
"@babel/helper-get-function-arity": "7.0.0-beta.46", | ||
"@babel/template": "7.0.0-beta.46", | ||
"@babel/types": "7.0.0-beta.46" | ||
"@babel/helper-get-function-arity": "7.0.0-beta.47", | ||
"@babel/template": "7.0.0-beta.47", | ||
"@babel/types": "7.0.0-beta.47" | ||
} | ||
} |
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
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
158
0
5513
+ Added@babel/code-frame@7.0.0-beta.47(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.47(transitive)
+ Added@babel/highlight@7.0.0-beta.47(transitive)
+ Added@babel/template@7.0.0-beta.47(transitive)
+ Added@babel/types@7.0.0-beta.47(transitive)
+ Addedbabylon@7.0.0-beta.47(transitive)
- Removed@babel/code-frame@7.0.0-beta.46(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.46(transitive)
- Removed@babel/highlight@7.0.0-beta.46(transitive)
- Removed@babel/template@7.0.0-beta.46(transitive)
- Removed@babel/types@7.0.0-beta.46(transitive)
- Removedbabylon@7.0.0-beta.46(transitive)
Updated@babel/types@7.0.0-beta.47