Socket
Socket
Sign inDemoInstall

@babel/helper-member-expression-to-functions

Package Overview
Dependencies
4
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.0-alpha.2 to 8.0.0-alpha.3

54

lib/index.js

@@ -156,7 +156,8 @@ import * as _t from '@babel/types';

argument: node
}) || rootParentPath.isAssignmentExpression({
left: node
})) {
throw member.buildCodeFrameError(`can't handle assignment`);
throw member.buildCodeFrameError(`can't handle update expression`);
}
const isAssignment = rootParentPath.isAssignmentExpression({
left: endPath.node
});
const isDeleteOperation = rootParentPath.isUnaryExpression({

@@ -204,2 +205,4 @@ operator: "delete"

parentPath.replaceWith(this.delete(member));
} else if (parentPath.isAssignmentExpression()) {
handleAssignment(this, member, parentPath);
} else {

@@ -233,3 +236,3 @@ member.replaceWith(this.get(member));

let replacementPath = endPath;
if (isDeleteOperation) {
if (isDeleteOperation || isAssignment) {
replacementPath = endParentPath;

@@ -298,22 +301,3 @@ regular = endParentPath.node;

})) {
if (this.simpleSet) {
member.replaceWith(this.simpleSet(member));
return;
}
const {
operator,
right: value
} = parentPath.node;
if (operator === "=") {
parentPath.replaceWith(this.set(member, value));
} else {
const operatorTrunc = operator.slice(0, -1);
if (LOGICAL_OPERATORS.includes(operatorTrunc)) {
this.memoise(member, 1);
parentPath.replaceWith(logicalExpression(operatorTrunc, this.get(member), this.set(member, value)));
} else {
this.memoise(member, 2);
parentPath.replaceWith(this.set(member, binaryExpression(operatorTrunc, this.get(member), value)));
}
}
handleAssignment(this, member, parentPath);
return;

@@ -364,2 +348,24 @@ }

};
function handleAssignment(state, member, parentPath) {
if (state.simpleSet) {
member.replaceWith(state.simpleSet(member));
return;
}
const {
operator,
right: value
} = parentPath.node;
if (operator === "=") {
parentPath.replaceWith(state.set(member, value));
} else {
const operatorTrunc = operator.slice(0, -1);
if (LOGICAL_OPERATORS.includes(operatorTrunc)) {
state.memoise(member, 1);
parentPath.replaceWith(logicalExpression(operatorTrunc, state.get(member), state.set(member, value)));
} else {
state.memoise(member, 2);
parentPath.replaceWith(state.set(member, binaryExpression(operatorTrunc, state.get(member), value)));
}
}
}
function memberExpressionToFunctions(path, visitor, state) {

@@ -366,0 +372,0 @@ path.traverse(visitor, Object.assign({}, handle, state, {

{
"name": "@babel/helper-member-expression-to-functions",
"version": "8.0.0-alpha.2",
"version": "8.0.0-alpha.3",
"description": "Helper function to replace certain member expressions with function calls",

@@ -18,6 +18,6 @@ "repository": {

"dependencies": {
"@babel/types": "^8.0.0-alpha.2"
"@babel/types": "^8.0.0-alpha.3"
},
"devDependencies": {
"@babel/traverse": "^8.0.0-alpha.2"
"@babel/traverse": "^8.0.0-alpha.3"
},

@@ -24,0 +24,0 @@ "engines": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc