babel-helper-function-name
Advanced tools
Comparing version 6.6.0 to 6.8.0
134
lib/index.js
@@ -1,28 +0,83 @@ | ||
/* eslint max-len: 0 */ | ||
/*istanbul ignore next*/"use strict"; | ||
"use strict"; | ||
exports.__esModule = true; | ||
var _interopRequireDefault = require("babel-runtime/helpers/interop-require-default")["default"]; | ||
exports.default = function ( /*istanbul ignore next*/_ref) { | ||
/*istanbul ignore next*/var node = _ref.node; | ||
/*istanbul ignore next*/var parent = _ref.parent; | ||
/*istanbul ignore next*/var scope = _ref.scope; | ||
/*istanbul ignore next*/var id = _ref.id; | ||
var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"]; | ||
// has an `id` so we don't need to infer one | ||
if (node.id) return; | ||
exports.__esModule = true; | ||
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && (!parent.computed || t.isLiteral(parent.key))) { | ||
// { foo() {} }; | ||
id = parent.key; | ||
} else if (t.isVariableDeclarator(parent)) { | ||
// let foo = function () {}; | ||
id = parent.id; | ||
var _babelHelperGetFunctionArity = require("babel-helper-get-function-arity"); | ||
if (t.isIdentifier(id)) { | ||
var binding = scope.parent.getBinding(id.name); | ||
if (binding && binding.constant && scope.getBinding(id.name) === binding) { | ||
// always going to reference this method | ||
node.id = id; | ||
node.id[t.NOT_LOCAL_BINDING] = true; | ||
return; | ||
} | ||
} | ||
} else if (t.isAssignmentExpression(parent)) { | ||
// foo = function () {}; | ||
id = parent.left; | ||
} else if (!id) { | ||
return; | ||
} | ||
var name = /*istanbul ignore next*/void 0; | ||
if (id && t.isLiteral(id)) { | ||
name = id.value; | ||
} else if (id && t.isIdentifier(id)) { | ||
name = id.name; | ||
} else { | ||
return; | ||
} | ||
name = t.toBindingIdentifierName(name); | ||
id = t.identifier(name); | ||
// The id shouldn't be considered a local binding to the function because | ||
// we are simply trying to set the function name and not actually create | ||
// a local binding. | ||
id[t.NOT_LOCAL_BINDING] = true; | ||
var state = visit(node, name, scope); | ||
return wrap(state, node, id, scope) || node; | ||
}; | ||
var /*istanbul ignore next*/_babelHelperGetFunctionArity = require("babel-helper-get-function-arity"); | ||
/*istanbul ignore next*/ | ||
var _babelHelperGetFunctionArity2 = _interopRequireDefault(_babelHelperGetFunctionArity); | ||
var _babelTemplate = require("babel-template"); | ||
var /*istanbul ignore next*/_babelTemplate = require("babel-template"); | ||
/*istanbul ignore next*/ | ||
var _babelTemplate2 = _interopRequireDefault(_babelTemplate); | ||
var _babelTypes = require("babel-types"); | ||
var /*istanbul ignore next*/_babelTypes = require("babel-types"); | ||
/*istanbul ignore next*/ | ||
var t = _interopRequireWildcard(_babelTypes); | ||
var buildPropertyMethodAssignmentWrapper = _babelTemplate2["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"); | ||
/*istanbul ignore next*/ | ||
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)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var buildGeneratorPropertyMethodAssignmentWrapper = _babelTemplate2["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"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var visitor = { | ||
var buildPropertyMethodAssignmentWrapper = /*istanbul ignore next*/(0, _babelTemplate2.default)( /*istanbul ignore next*/"\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"); /* eslint max-len: 0 */ | ||
var buildGeneratorPropertyMethodAssignmentWrapper = /*istanbul ignore next*/(0, _babelTemplate2.default)( /*istanbul ignore next*/"\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 = { /*istanbul ignore next*/ | ||
"ReferencedIdentifier|BindingIdentifier": function ReferencedIdentifierBindingIdentifier(path, state) { | ||
@@ -64,3 +119,3 @@ // check if this node matches our function id | ||
var params = _template.callee.body.body[0].params; | ||
for (var i = 0, len = _babelHelperGetFunctionArity2["default"](method); i < len; i++) { | ||
for (var i = 0, len = /*istanbul ignore next*/(0, _babelHelperGetFunctionArity2.default)(method); i < len; i++) { | ||
params.push(scope.generateUidIdentifier("x")); | ||
@@ -123,55 +178,2 @@ } | ||
exports["default"] = function (_ref) { | ||
var node = _ref.node; | ||
var parent = _ref.parent; | ||
var scope = _ref.scope; | ||
var id = _ref.id; | ||
// has an `id` so we don't need to infer one | ||
if (node.id) return; | ||
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && (!parent.computed || t.isLiteral(parent.key))) { | ||
// { foo() {} }; | ||
id = parent.key; | ||
} else if (t.isVariableDeclarator(parent)) { | ||
// let foo = function () {}; | ||
id = parent.id; | ||
if (t.isIdentifier(id)) { | ||
var binding = scope.parent.getBinding(id.name); | ||
if (binding && binding.constant && scope.getBinding(id.name) === binding) { | ||
// always going to reference this method | ||
node.id = id; | ||
node.id[t.NOT_LOCAL_BINDING] = true; | ||
return; | ||
} | ||
} | ||
} else if (t.isAssignmentExpression(parent)) { | ||
// foo = function () {}; | ||
id = parent.left; | ||
} else if (!id) { | ||
return; | ||
} | ||
var name = undefined; | ||
if (id && t.isLiteral(id)) { | ||
name = id.value; | ||
} else if (id && t.isIdentifier(id)) { | ||
name = id.name; | ||
} else { | ||
return; | ||
} | ||
name = t.toBindingIdentifierName(name); | ||
id = t.identifier(name); | ||
// The id shouldn't be considered a local binding to the function because | ||
// we are simply trying to set the function name and not actually create | ||
// a local binding. | ||
id[t.NOT_LOCAL_BINDING] = true; | ||
var state = visit(node, name, scope); | ||
return wrap(state, node, id, scope) || node; | ||
}; | ||
module.exports = exports["default"]; | ||
/*istanbul ignore next*/module.exports = exports["default"]; |
{ | ||
"name": "babel-helper-function-name", | ||
"version": "6.6.0", | ||
"version": "6.8.0", | ||
"description": "", | ||
@@ -9,8 +9,8 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name", | ||
"dependencies": { | ||
"babel-runtime": "^5.0.0", | ||
"babel-types": "^6.6.0", | ||
"babel-traverse": "^6.6.0", | ||
"babel-helper-get-function-arity": "^6.3.13", | ||
"babel-template": "^6.6.0" | ||
"babel-runtime": "^6.0.0", | ||
"babel-types": "^6.8.0", | ||
"babel-traverse": "^6.8.0", | ||
"babel-helper-get-function-arity": "^6.8.0", | ||
"babel-template": "^6.8.0" | ||
} | ||
} |
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
7053
145
- Removedbabel-runtime@5.8.38(transitive)
- Removedcore-js@1.2.7(transitive)
Updatedbabel-runtime@^6.0.0
Updatedbabel-template@^6.8.0
Updatedbabel-traverse@^6.8.0
Updatedbabel-types@^6.8.0