Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/plugin-transform-proto-to-assign

Package Overview
Dependencies
Maintainers
6
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-proto-to-assign - npm Package Compare versions

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

84

lib/index.js
"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 _pull = _interopRequireDefault(require("lodash/pull"));
_helperPluginUtils = function () {
return data;
};
var _core = require("@babel/core");
return data;
}
function _pull() {
const data = _interopRequireDefault(require("lodash/pull"));
_pull = 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 isProtoKey(node) {
return _core.types.isLiteral(_core.types.toComputedKey(node, node.key), {
return _core().types.isLiteral(_core().types.toComputedKey(node, node.key), {
value: "__proto__"

@@ -24,4 +50,4 @@ });

function isProtoAssignmentExpression(node) {
var left = node.left;
return _core.types.isMemberExpression(left) && _core.types.isLiteral(_core.types.toComputedKey(left, left.property), {
const left = node.left;
return _core().types.isMemberExpression(left) && _core().types.isLiteral(_core().types.toComputedKey(left, left.property), {
value: "__proto__"

@@ -32,3 +58,3 @@ });

function buildDefaultsCallExpression(expr, ref, file) {
return _core.types.expressionStatement(_core.types.callExpression(file.addHelper("defaults"), [ref, expr.right]));
return _core().types.expressionStatement(_core().types.callExpression(file.addHelper("defaults"), [ref, expr.right]));
}

@@ -38,19 +64,20 @@

visitor: {
AssignmentExpression: function AssignmentExpression(path, file) {
AssignmentExpression(path, file) {
if (!isProtoAssignmentExpression(path.node)) return;
var nodes = [];
var left = path.node.left.object;
var temp = path.scope.maybeGenerateMemoised(left);
const nodes = [];
const left = path.node.left.object;
const temp = path.scope.maybeGenerateMemoised(left);
if (temp) {
nodes.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", temp, left)));
nodes.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", temp, left)));
}
nodes.push(buildDefaultsCallExpression(path.node, _core.types.cloneNode(temp || left), file));
if (temp) nodes.push(_core.types.cloneNode(temp));
nodes.push(buildDefaultsCallExpression(path.node, _core().types.cloneNode(temp || left), file));
if (temp) nodes.push(_core().types.cloneNode(temp));
path.replaceWithMultiple(nodes);
},
ExpressionStatement: function ExpressionStatement(path, file) {
var expr = path.node.expression;
if (!_core.types.isAssignmentExpression(expr, {
ExpressionStatement(path, file) {
const expr = path.node.expression;
if (!_core().types.isAssignmentExpression(expr, {
operator: "="

@@ -63,13 +90,13 @@ })) return;

},
ObjectExpression: function ObjectExpression(path, file) {
var proto;
var node = path.node;
var _arr = node.properties;
for (var _i = 0; _i < _arr.length; _i++) {
var prop = _arr[_i];
ObjectExpression(path, file) {
let proto;
const {
node
} = path;
for (const prop of node.properties) {
if (isProtoKey(prop)) {
proto = prop.value;
(0, _pull.default)(node.properties, prop);
(0, _pull().default)(node.properties, prop);
}

@@ -79,7 +106,8 @@ }

if (proto) {
var args = [_core.types.objectExpression([]), proto];
const args = [_core().types.objectExpression([]), proto];
if (node.properties.length) args.push(node);
path.replaceWith(_core.types.callExpression(file.addHelper("extends"), args));
path.replaceWith(_core().types.callExpression(file.addHelper("extends"), args));
}
}
}

@@ -86,0 +114,0 @@ };

{
"name": "@babel/plugin-transform-proto-to-assign",
"version": "7.0.0-beta.42",
"version": "7.0.0-beta.43",
"description": "Babel plugin for turning __proto__ into a shallow property clone",

@@ -12,11 +12,11 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-proto-to-assign",

"dependencies": {
"@babel/helper-plugin-utils": "7.0.0-beta.42"
"@babel/helper-plugin-utils": "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"
}
}
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