@babel/plugin-proposal-function-bind
Advanced tools
Comparing version 7.0.0-beta.42 to 7.0.0-beta.43
"use strict"; | ||
exports.__esModule = true; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
function _helperPluginUtils() { | ||
const data = require("@babel/helper-plugin-utils"); | ||
var _pluginSyntaxFunctionBind = _interopRequireDefault(require("@babel/plugin-syntax-function-bind")); | ||
_helperPluginUtils = function () { | ||
return data; | ||
}; | ||
var _core = require("@babel/core"); | ||
return data; | ||
} | ||
function _pluginSyntaxFunctionBind() { | ||
const data = _interopRequireDefault(require("@babel/plugin-syntax-function-bind")); | ||
_pluginSyntaxFunctionBind = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _core() { | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = (0, _helperPluginUtils.declare)(function (api) { | ||
var _default = (0, _helperPluginUtils().declare)(api => { | ||
api.assertVersion(7); | ||
function getTempId(scope) { | ||
var id = scope.path.getData("functionBind"); | ||
let id = scope.path.getData("functionBind"); | ||
if (id) return id; | ||
@@ -25,3 +51,3 @@ id = scope.generateDeclaredUidIdentifier("context"); | ||
function getStaticContext(bind, scope) { | ||
var object = bind.object || bind.callee.object; | ||
const object = bind.object || bind.callee.object; | ||
return scope.isStatic(object) && object; | ||
@@ -31,10 +57,10 @@ } | ||
function inferBindContext(bind, scope) { | ||
var staticContext = getStaticContext(bind, scope); | ||
if (staticContext) return _core.types.cloneNode(staticContext); | ||
var tempId = getTempId(scope); | ||
const staticContext = getStaticContext(bind, scope); | ||
if (staticContext) return _core().types.cloneNode(staticContext); | ||
const tempId = getTempId(scope); | ||
if (bind.object) { | ||
bind.callee = _core.types.sequenceExpression([_core.types.assignmentExpression("=", tempId, bind.object), bind.callee]); | ||
bind.callee = _core().types.sequenceExpression([_core().types.assignmentExpression("=", tempId, bind.object), bind.callee]); | ||
} else { | ||
bind.callee.object = _core.types.assignmentExpression("=", tempId, bind.callee.object); | ||
bind.callee.object = _core().types.assignmentExpression("=", tempId, bind.callee.object); | ||
} | ||
@@ -46,19 +72,24 @@ | ||
return { | ||
inherits: _pluginSyntaxFunctionBind.default, | ||
inherits: _pluginSyntaxFunctionBind().default, | ||
visitor: { | ||
CallExpression: function CallExpression(_ref) { | ||
var node = _ref.node, | ||
scope = _ref.scope; | ||
var bind = node.callee; | ||
if (!_core.types.isBindExpression(bind)) return; | ||
var context = inferBindContext(bind, scope); | ||
node.callee = _core.types.memberExpression(bind.callee, _core.types.identifier("call")); | ||
CallExpression({ | ||
node, | ||
scope | ||
}) { | ||
const bind = node.callee; | ||
if (!_core().types.isBindExpression(bind)) return; | ||
const context = inferBindContext(bind, scope); | ||
node.callee = _core().types.memberExpression(bind.callee, _core().types.identifier("call")); | ||
node.arguments.unshift(context); | ||
}, | ||
BindExpression: function BindExpression(path) { | ||
var node = path.node, | ||
scope = path.scope; | ||
var context = inferBindContext(node, scope); | ||
path.replaceWith(_core.types.callExpression(_core.types.memberExpression(node.callee, _core.types.identifier("bind")), [context])); | ||
BindExpression(path) { | ||
const { | ||
node, | ||
scope | ||
} = path; | ||
const context = inferBindContext(node, scope); | ||
path.replaceWith(_core().types.callExpression(_core().types.memberExpression(node.callee, _core().types.identifier("bind")), [context])); | ||
} | ||
} | ||
@@ -65,0 +96,0 @@ }; |
{ | ||
"name": "@babel/plugin-proposal-function-bind", | ||
"version": "7.0.0-beta.42", | ||
"version": "7.0.0-beta.43", | ||
"description": "Compile function bind operator to ES5", | ||
@@ -12,12 +12,12 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-function-bind", | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "7.0.0-beta.42", | ||
"@babel/plugin-syntax-function-bind": "7.0.0-beta.42" | ||
"@babel/helper-plugin-utils": "7.0.0-beta.43", | ||
"@babel/plugin-syntax-function-bind": "7.0.0-beta.43" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.42" | ||
"@babel/core": "7.0.0-beta.43" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.42", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.42" | ||
"@babel/core": "7.0.0-beta.43", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.43" | ||
} | ||
} |
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
5524
74
+ Added@babel/code-frame@7.0.0-beta.43(transitive)
+ Added@babel/core@7.0.0-beta.43(transitive)
+ Added@babel/generator@7.0.0-beta.43(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.43(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.43(transitive)
+ Added@babel/helper-plugin-utils@7.0.0-beta.43(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.43(transitive)
+ Added@babel/helpers@7.0.0-beta.43(transitive)
+ Added@babel/highlight@7.0.0-beta.43(transitive)
+ Added@babel/plugin-syntax-function-bind@7.0.0-beta.43(transitive)
+ Added@babel/template@7.0.0-beta.43(transitive)
+ Added@babel/traverse@7.0.0-beta.43(transitive)
+ Added@babel/types@7.0.0-beta.43(transitive)
+ Addedbabylon@7.0.0-beta.43(transitive)
- Removed@babel/code-frame@7.0.0-beta.42(transitive)
- Removed@babel/core@7.0.0-beta.42(transitive)
- Removed@babel/generator@7.0.0-beta.42(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.42(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.42(transitive)
- Removed@babel/helper-plugin-utils@7.0.0-beta.42(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.42(transitive)
- Removed@babel/helpers@7.0.0-beta.42(transitive)
- Removed@babel/highlight@7.0.0-beta.42(transitive)
- Removed@babel/plugin-syntax-function-bind@7.0.0-beta.42(transitive)
- Removed@babel/template@7.0.0-beta.42(transitive)
- Removed@babel/traverse@7.0.0-beta.42(transitive)
- Removed@babel/types@7.0.0-beta.42(transitive)
- Removedbabylon@7.0.0-beta.42(transitive)