babel-plugin-minify-guarded-expressions
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -22,2 +22,12 @@ "use strict"; | ||
var right = path.get("right"); | ||
// issues - 171, 174, 176 | ||
// we assume that it is returned/assigned/part of a bigger expression | ||
// or utilized somehow | ||
// we check if we shouldBail only when evaluating | ||
// the rightside of the expression; | ||
// if the left side is evaluated to be deterministic, | ||
// we can safely replace the entire expression | ||
var shouldBail = !path.parentPath.isExpressionStatement(); | ||
if (node.operator === "&&") { | ||
@@ -30,3 +40,3 @@ var leftTruthy = left.evaluateTruthy(); | ||
path.replaceWith(node.right); | ||
} else if (right.evaluateTruthy() === false && right.isPure()) { | ||
} else if (right.evaluateTruthy() === false && right.isPure() && !shouldBail) { | ||
path.replaceWith(node.left); | ||
@@ -41,3 +51,3 @@ } | ||
path.replaceWith(node.left); | ||
} else if (right.evaluateTruthy() === false && right.isPure()) { | ||
} else if (right.evaluateTruthy() === false && right.isPure() && !shouldBail) { | ||
path.replaceWith(node.left); | ||
@@ -44,0 +54,0 @@ } |
{ | ||
"name": "babel-plugin-minify-guarded-expressions", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/babel/babili#readme", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3731
63
0