babel-plugin-minify-guarded-expressions
Advanced tools
Comparing version 0.3.0-alpha.7f4dc3d4 to 0.3.0-alpha.8857f145
"use strict"; | ||
module.exports = function (_ref) { | ||
var t = _ref.types; | ||
module.exports = function ({ types: t }) { | ||
const flipExpressions = require("babel-helper-flip-expressions")(t); | ||
var flipExpressions = require("babel-helper-flip-expressions")(t); | ||
return { | ||
@@ -17,7 +15,7 @@ name: "minify-guarded-expressions", | ||
enter: [function (path) { | ||
var node = path.node; | ||
const node = path.node; | ||
var left = path.get("left"); | ||
var right = path.get("right"); | ||
const left = path.get("left"); | ||
const right = path.get("right"); | ||
@@ -31,6 +29,6 @@ // issues - 171, 174, 176 | ||
// we can safely replace the entire expression | ||
var shouldBail = !path.parentPath.isExpressionStatement(); | ||
const shouldBail = !path.parentPath.isExpressionStatement(); | ||
if (node.operator === "&&") { | ||
var leftTruthy = left.evaluateTruthy(); | ||
const leftTruthy = left.evaluateTruthy(); | ||
if (leftTruthy === false) { | ||
@@ -45,6 +43,6 @@ // Short-circuit | ||
} else if (node.operator === "||") { | ||
var _leftTruthy = left.evaluateTruthy(); | ||
if (_leftTruthy === false && left.isPure()) { | ||
const leftTruthy = left.evaluateTruthy(); | ||
if (leftTruthy === false && left.isPure()) { | ||
path.replaceWith(node.right); | ||
} else if (_leftTruthy === true) { | ||
} else if (leftTruthy === true) { | ||
// Short-circuit | ||
@@ -57,3 +55,3 @@ path.replaceWith(node.left); | ||
}, function (path) { | ||
var node = path.node; | ||
const node = path.node; | ||
@@ -72,3 +70,3 @@ | ||
if (flipExpressions.shouldFlip(node, 1)) { | ||
var newNode = flipExpressions.flip(node, true); | ||
const newNode = flipExpressions.flip(node, true); | ||
path.replaceWith(newNode); | ||
@@ -75,0 +73,0 @@ } |
{ | ||
"name": "babel-plugin-minify-guarded-expressions", | ||
"version": "0.3.0-alpha.7f4dc3d4", | ||
"version": "0.3.0-alpha.8857f145", | ||
"description": "", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-flip-expressions": "^0.3.0-alpha.7f4dc3d4" | ||
"babel-helper-flip-expressions": "^0.3.0-alpha.8857f145" | ||
} | ||
} |
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
62