babel-plugin-minify-guarded-expressions
Advanced tools
Comparing version 0.5.0-alpha.8b905991 to 0.5.0-alpha.91ed3622
"use strict"; | ||
const evaluate = require("babel-helper-evaluate-path"); | ||
function evaluateTruthy(path) { | ||
const res = evaluate(path); | ||
if (res.confident) return !!res.value; | ||
} | ||
module.exports = function ({ | ||
@@ -30,3 +37,3 @@ types: t | ||
if (node.operator === "&&") { | ||
const leftTruthy = left.evaluateTruthy(); | ||
const leftTruthy = evaluateTruthy(left); | ||
@@ -38,7 +45,7 @@ if (leftTruthy === false) { | ||
path.replaceWith(node.right); | ||
} else if (right.evaluateTruthy() === false && right.isPure() && !shouldBail) { | ||
} else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) { | ||
path.replaceWith(node.left); | ||
} | ||
} else if (node.operator === "||") { | ||
const leftTruthy = left.evaluateTruthy(); | ||
const leftTruthy = evaluateTruthy(left); | ||
@@ -50,3 +57,3 @@ if (leftTruthy === false && left.isPure()) { | ||
path.replaceWith(node.left); | ||
} else if (right.evaluateTruthy() === false && right.isPure() && !shouldBail) { | ||
} else if (evaluateTruthy(right) === false && right.isPure() && !shouldBail) { | ||
path.replaceWith(node.left); | ||
@@ -53,0 +60,0 @@ } |
{ | ||
"name": "babel-plugin-minify-guarded-expressions", | ||
"version": "0.5.0-alpha.8b905991", | ||
"version": "0.5.0-alpha.91ed3622", | ||
"description": "", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.8b905991" | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.91ed3622" | ||
} | ||
} |
@@ -22,3 +22,3 @@ # babel-plugin-minify-guarded-expressions | ||
```sh | ||
npm install babel-plugin-minify-guarded-expressions | ||
npm install babel-plugin-minify-guarded-expressions --save-dev | ||
``` | ||
@@ -25,0 +25,0 @@ |
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
3852
67