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