babel-plugin-minify-simplify
Advanced tools
Comparing version 0.5.0-alpha.18dcfe13 to 0.5.0-alpha.1cb46b73
@@ -117,2 +117,10 @@ "use strict"; | ||
}, | ||
BinaryExpression(path) { | ||
if (["!=", "=="].indexOf(path.node.operator) !== -1) { | ||
undefinedToNull(path.get("left")); | ||
undefinedToNull(path.get("right")); | ||
} | ||
}, | ||
LogicalExpression: { | ||
@@ -1148,2 +1156,20 @@ exit: logicalExpression.simplifyPatterns | ||
} | ||
function isPureVoid(path) { | ||
return path.isUnaryExpression({ | ||
operator: "void" | ||
}) && path.isPure(); | ||
} | ||
function isGlobalUndefined(path) { | ||
return path.isIdentifier({ | ||
name: "undefined" | ||
}) && !path.scope.getBinding("undefined"); | ||
} | ||
function undefinedToNull(path) { | ||
if (isGlobalUndefined(path) || isPureVoid(path)) { | ||
path.replaceWith(t.nullLiteral()); | ||
} | ||
} | ||
}; |
{ | ||
"name": "babel-plugin-minify-simplify", | ||
"version": "0.5.0-alpha.18dcfe13", | ||
"version": "0.5.0-alpha.1cb46b73", | ||
"description": "", | ||
@@ -15,6 +15,6 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.18dcfe13", | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.1cb46b73", | ||
"babel-helper-is-nodes-equiv": "^0.0.1", | ||
"babel-helper-to-multiple-sequence-expressions": "^0.5.0-alpha.18dcfe13" | ||
"babel-helper-to-multiple-sequence-expressions": "^0.5.0-alpha.1cb46b73" | ||
} | ||
} |
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
58566
1480