Socket
Socket
Sign inDemoInstall

@babel/helper-function-name

Package Overview
Dependencies
Maintainers
6
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-function-name - npm Package Compare versions

Comparing version 7.0.0-beta.42 to 7.0.0-beta.43

131

lib/index.js
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _helperGetFunctionArity = _interopRequireDefault(require("@babel/helper-get-function-arity"));
function _helperGetFunctionArity() {
const data = _interopRequireDefault(require("@babel/helper-get-function-arity"));
var _template2 = _interopRequireDefault(require("@babel/template"));
_helperGetFunctionArity = function () {
return data;
};
var t = _interopRequireWildcard(require("@babel/types"));
return data;
}
function _template() {
const data = _interopRequireDefault(require("@babel/template"));
_template = function () {
return data;
};
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; } }

@@ -16,8 +42,32 @@

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;

@@ -27,2 +77,3 @@ state.selfReference = true;

}
};

@@ -35,4 +86,4 @@

} else {
if (!t.isFunction(method)) return;
var build = buildPropertyMethodAssignmentWrapper;
if (!t().isFunction(method)) return;
let build = buildPropertyMethodAssignmentWrapper;

@@ -43,3 +94,3 @@ if (method.generator) {

var _template = build({
const template = build({
FUNCTION: method,

@@ -49,9 +100,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;
}

@@ -65,3 +116,3 @@ }

function visit(node, name, scope) {
var state = {
const state = {
selfAssignment: false,

@@ -73,3 +124,3 @@ selfReference: false,

};
var binding = scope.getOwnBinding(name);
const binding = scope.getOwnBinding(name);

@@ -87,31 +138,27 @@ 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;
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) {
var binding = scope.parent.getBinding(id.name);
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;

@@ -122,7 +169,7 @@ } else if (!id) {

var name;
let name;
if (id && t.isLiteral(id)) {
if (id && t().isLiteral(id)) {
name = id.value;
} else if (id && t.isIdentifier(id)) {
} else if (id && t().isIdentifier(id)) {
name = id.name;

@@ -133,7 +180,7 @@ } else {

name = t.toBindingIdentifierName(name);
id = t.identifier(name);
id[t.NOT_LOCAL_BINDING] = true;
var state = visit(node, name, scope);
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.0.0-beta.42",
"version": "7.0.0-beta.43",
"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.42",
"@babel/template": "7.0.0-beta.42",
"@babel/types": "7.0.0-beta.42"
"@babel/helper-get-function-arity": "7.0.0-beta.43",
"@babel/template": "7.0.0-beta.43",
"@babel/types": "7.0.0-beta.43"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc