babel-plugin-minify-guarded-expressions
Advanced tools
Comparing version 0.4.0-alpha.6546ad11 to 0.4.0-alpha.caaefb4c
@@ -18,8 +18,4 @@ "use strict"; | ||
var node = path.node; | ||
var left = path.get("left"); | ||
var right = path.get("right"); | ||
// issues - 171, 174, 176 | ||
var right = path.get("right"); // issues - 171, 174, 176 | ||
// we assume that it is returned/assigned/part of a bigger expression | ||
@@ -31,2 +27,3 @@ // or utilized somehow | ||
// we can safely replace the entire expression | ||
var shouldBail = !path.parentPath.isExpressionStatement(); | ||
@@ -36,2 +33,3 @@ | ||
var leftTruthy = left.evaluateTruthy(); | ||
if (leftTruthy === false) { | ||
@@ -47,2 +45,3 @@ // Short-circuit | ||
var _leftTruthy = left.evaluateTruthy(); | ||
if (_leftTruthy === false && left.isPure()) { | ||
@@ -60,3 +59,2 @@ path.replaceWith(node.right); | ||
if (flipExpressions.hasSeen(node)) { | ||
@@ -68,6 +66,6 @@ return; | ||
return; | ||
} | ||
} // Start counting savings from one since we can ignore the last | ||
// expression. | ||
// Start counting savings from one since we can ignore the last | ||
// expression. | ||
if (flipExpressions.shouldFlip(node, 1)) { | ||
@@ -74,0 +72,0 @@ var newNode = flipExpressions.flip(node, true); |
{ | ||
"name": "babel-plugin-minify-guarded-expressions", | ||
"version": "0.4.0-alpha.6546ad11", | ||
"version": "0.4.0-alpha.caaefb4c", | ||
"description": "", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-flip-expressions": "^0.4.0-alpha.6546ad11" | ||
"babel-helper-flip-expressions": "^0.4.0-alpha.caaefb4c" | ||
} | ||
} |
@@ -46,5 +46,5 @@ # babel-plugin-minify-guarded-expressions | ||
```javascript | ||
require("babel-core").transform("code", { | ||
require("@babel/core").transform("code", { | ||
plugins: ["minify-guarded-expressions"] | ||
}); | ||
``` |
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
3680
61