@babel/helper-function-name
Advanced tools
Comparing version 7.14.5 to 7.15.4
@@ -12,4 +12,20 @@ "use strict"; | ||
var t = require("@babel/types"); | ||
var _t = require("@babel/types"); | ||
const { | ||
NOT_LOCAL_BINDING, | ||
cloneNode, | ||
identifier, | ||
isAssignmentExpression, | ||
isFunction, | ||
isIdentifier, | ||
isLiteral, | ||
isNullLiteral, | ||
isObjectMethod, | ||
isObjectProperty, | ||
isRegExpLiteral, | ||
isTemplateLiteral, | ||
isVariableDeclarator, | ||
toBindingIdentifierName | ||
} = _t; | ||
const buildPropertyMethodAssignmentWrapper = (0, _template.default)(` | ||
@@ -53,11 +69,11 @@ (function (FUNCTION_KEY) { | ||
function getNameFromLiteralId(id) { | ||
if (t.isNullLiteral(id)) { | ||
if (isNullLiteral(id)) { | ||
return "null"; | ||
} | ||
if (t.isRegExpLiteral(id)) { | ||
if (isRegExpLiteral(id)) { | ||
return `_${id.pattern}_${id.flags}`; | ||
} | ||
if (t.isTemplateLiteral(id)) { | ||
if (isTemplateLiteral(id)) { | ||
return id.quasis.map(quasi => quasi.value.raw).join(""); | ||
@@ -78,3 +94,3 @@ } | ||
} else { | ||
if (!t.isFunction(method)) return; | ||
if (!isFunction(method)) return; | ||
let build = buildPropertyMethodAssignmentWrapper; | ||
@@ -134,19 +150,19 @@ | ||
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { | ||
if ((isObjectProperty(parent) || isObjectMethod(parent, { | ||
kind: "method" | ||
})) && (!parent.computed || t.isLiteral(parent.key))) { | ||
})) && (!parent.computed || isLiteral(parent.key))) { | ||
id = parent.key; | ||
} else if (t.isVariableDeclarator(parent)) { | ||
} else if (isVariableDeclarator(parent)) { | ||
id = parent.id; | ||
if (t.isIdentifier(id) && !localBinding) { | ||
if (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 = cloneNode(id); | ||
node.id[NOT_LOCAL_BINDING] = true; | ||
return; | ||
} | ||
} | ||
} else if (t.isAssignmentExpression(parent, { | ||
} else if (isAssignmentExpression(parent, { | ||
operator: "=" | ||
@@ -161,5 +177,5 @@ })) { | ||
if (id && t.isLiteral(id)) { | ||
if (id && isLiteral(id)) { | ||
name = getNameFromLiteralId(id); | ||
} else if (id && t.isIdentifier(id)) { | ||
} else if (id && isIdentifier(id)) { | ||
name = id.name; | ||
@@ -172,7 +188,7 @@ } | ||
name = t.toBindingIdentifierName(name); | ||
id = t.identifier(name); | ||
id[t.NOT_LOCAL_BINDING] = true; | ||
name = toBindingIdentifierName(name); | ||
id = identifier(name); | ||
id[NOT_LOCAL_BINDING] = true; | ||
const state = visit(node, name, scope); | ||
return wrap(state, node, id, scope) || node; | ||
} |
{ | ||
"name": "@babel/helper-function-name", | ||
"version": "7.14.5", | ||
"version": "7.15.4", | ||
"description": "Helper function to change the property 'name' of every function", | ||
@@ -17,5 +17,5 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-get-function-arity": "^7.14.5", | ||
"@babel/template": "^7.14.5", | ||
"@babel/types": "^7.14.5" | ||
"@babel/helper-get-function-arity": "^7.15.4", | ||
"@babel/template": "^7.15.4", | ||
"@babel/types": "^7.15.4" | ||
}, | ||
@@ -22,0 +22,0 @@ "engines": { |
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
6469
155
Updated@babel/template@^7.15.4
Updated@babel/types@^7.15.4