Socket
Socket
Sign inDemoInstall

@babel/plugin-proposal-function-bind

Package Overview
Dependencies
Maintainers
4
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-proposal-function-bind - npm Package Compare versions

Comparing version 7.21.4-esm.4 to 7.22.5

39

lib/index.js

@@ -1,9 +0,15 @@

import { declare } from "@babel/helper-plugin-utils";
import syntaxFunctionBind from "@babel/plugin-syntax-function-bind";
import { types as t } from "@babel/core";
export default declare(api => {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxFunctionBind = require("@babel/plugin-syntax-function-bind");
var _core = require("@babel/core");
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
function getTempId(scope) {
let id = scope.path.getData("functionBind");
if (id) return t.cloneNode(id);
if (id) return _core.types.cloneNode(id);
id = scope.generateDeclaredUidIdentifier("context");

@@ -13,3 +19,3 @@ return scope.path.setData("functionBind", id);

function getObject(bind) {
if (t.isExpression(bind.object)) {
if (_core.types.isExpression(bind.object)) {
return bind.object;

@@ -21,18 +27,18 @@ }

const object = getObject(bind);
return scope.isStatic(object) && (t.isSuper(object) ? t.thisExpression() : object);
return scope.isStatic(object) && (_core.types.isSuper(object) ? _core.types.thisExpression() : object);
}
function inferBindContext(bind, scope) {
const staticContext = getStaticContext(bind, scope);
if (staticContext) return t.cloneNode(staticContext);
if (staticContext) return _core.types.cloneNode(staticContext);
const tempId = getTempId(scope);
if (bind.object) {
bind.callee = t.sequenceExpression([t.assignmentExpression("=", tempId, bind.object), bind.callee]);
} else if (t.isMemberExpression(bind.callee)) {
bind.callee.object = t.assignmentExpression("=", tempId, bind.callee.object);
bind.callee = _core.types.sequenceExpression([_core.types.assignmentExpression("=", tempId, bind.object), bind.callee]);
} else if (_core.types.isMemberExpression(bind.callee)) {
bind.callee.object = _core.types.assignmentExpression("=", tempId, bind.callee.object);
}
return t.cloneNode(tempId);
return _core.types.cloneNode(tempId);
}
return {
name: "proposal-function-bind",
inherits: syntaxFunctionBind,
inherits: _pluginSyntaxFunctionBind.default,
visitor: {

@@ -44,5 +50,5 @@ CallExpression({

const bind = node.callee;
if (!t.isBindExpression(bind)) return;
if (!_core.types.isBindExpression(bind)) return;
const context = inferBindContext(bind, scope);
node.callee = t.memberExpression(bind.callee, t.identifier("call"));
node.callee = _core.types.memberExpression(bind.callee, _core.types.identifier("call"));
node.arguments.unshift(context);

@@ -56,3 +62,3 @@ },

const context = inferBindContext(node, scope);
path.replaceWith(t.callExpression(t.memberExpression(node.callee, t.identifier("bind")), [context]));
path.replaceWith(_core.types.callExpression(_core.types.memberExpression(node.callee, _core.types.identifier("bind")), [context]));
}

@@ -62,3 +68,4 @@ }

});
exports.default = _default;
//# sourceMappingURL=index.js.map
{
"name": "@babel/plugin-proposal-function-bind",
"version": "7.21.4-esm.4",
"version": "7.22.5",
"description": "Compile function bind operator to ES5",

@@ -20,11 +20,11 @@ "repository": {

"dependencies": {
"@babel/helper-plugin-utils": "7.21.4-esm.4",
"@babel/plugin-syntax-function-bind": "7.21.4-esm.4"
"@babel/helper-plugin-utils": "^7.22.5",
"@babel/plugin-syntax-function-bind": "^7.22.5"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0 || ^7.21.4-esm.2"
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "7.21.4-esm.4",
"@babel/helper-plugin-test-runner": "7.21.4-esm.4"
"@babel/core": "^7.22.5",
"@babel/helper-plugin-test-runner": "^7.22.5"
},

@@ -35,3 +35,3 @@ "engines": {

"author": "The Babel Team (https://babel.dev/team)",
"type": "module"
"type": "commonjs"
}

Sorry, the diff of this file is not supported yet

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