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.43 to 7.0.0-beta.44

85

lib/index.js

@@ -9,5 +9,5 @@ "use strict";

function _helperGetFunctionArity() {
const data = _interopRequireDefault(require("@babel/helper-get-function-arity"));
var data = _interopRequireDefault(require("@babel/helper-get-function-arity"));
_helperGetFunctionArity = function () {
_helperGetFunctionArity = function _helperGetFunctionArity() {
return data;

@@ -19,6 +19,6 @@ };

function _template() {
const data = _interopRequireDefault(require("@babel/template"));
function _template2() {
var data = _interopRequireDefault(require("@babel/template"));
_template = function () {
_template2 = function _template2() {
return data;

@@ -31,5 +31,5 @@ };

function t() {
const data = _interopRequireWildcard(require("@babel/types"));
var data = _interopRequireWildcard(require("@babel/types"));
t = function () {
t = function t() {
return data;

@@ -45,32 +45,8 @@ };

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) {
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) {
if (path.node.name !== state.name) return;
const localDeclar = path.scope.getBindingIdentifier(state.name);
var localDeclar = path.scope.getBindingIdentifier(state.name);
if (localDeclar !== state.outerDeclar) return;

@@ -80,3 +56,2 @@ state.selfReference = true;

}
};

@@ -90,3 +65,3 @@

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

@@ -97,3 +72,3 @@ if (method.generator) {

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

@@ -103,9 +78,9 @@ FUNCTION_ID: id,

}).expression;
const params = template.callee.body.body[0].params;
var params = _template.callee.body.body[0].params;
for (let i = 0, len = (0, _helperGetFunctionArity().default)(method); i < len; i++) {
for (var i = 0, len = (0, _helperGetFunctionArity().default)(method); i < len; i++) {
params.push(scope.generateUidIdentifier("x"));
}
return template;
return _template;
}

@@ -119,3 +94,3 @@ }

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

@@ -127,3 +102,3 @@ selfReference: false,

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

@@ -141,8 +116,12 @@ if (binding) {

function _default({
node,
parent,
scope,
id
}, localBinding = false) {
function _default(_ref, localBinding) {
var node = _ref.node,
parent = _ref.parent,
scope = _ref.scope,
id = _ref.id;
if (localBinding === void 0) {
localBinding = false;
}
if (node.id) return;

@@ -158,3 +137,3 @@

if (t().isIdentifier(id) && !localBinding) {
const binding = scope.parent.getBinding(id.name);
var binding = scope.parent.getBinding(id.name);

@@ -173,3 +152,3 @@ if (binding && binding.constant && scope.getBinding(id.name) === binding) {

let name;
var name;

@@ -187,4 +166,4 @@ if (id && t().isLiteral(id)) {

id[t().NOT_LOCAL_BINDING] = true;
const state = visit(node, name, scope);
var state = visit(node, name, scope);
return wrap(state, node, id, scope) || node;
}
{
"name": "@babel/helper-function-name",
"version": "7.0.0-beta.43",
"version": "7.0.0-beta.44",
"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.43",
"@babel/template": "7.0.0-beta.43",
"@babel/types": "7.0.0-beta.43"
"@babel/helper-get-function-arity": "7.0.0-beta.44",
"@babel/template": "7.0.0-beta.44",
"@babel/types": "7.0.0-beta.44"
}
}
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