babel-helper-flip-expressions
Advanced tools
Comparing version 0.4.0-alpha.6546ad11 to 0.4.0-alpha.caaefb4c
@@ -15,3 +15,2 @@ "use strict"; | ||
var savings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
visit(topNode); | ||
@@ -21,3 +20,5 @@ return savings > 0; | ||
function visit(node) { | ||
if (t.isUnaryExpression(node, { operator: "!" })) { | ||
if (t.isUnaryExpression(node, { | ||
operator: "!" | ||
})) { | ||
savings++; | ||
@@ -41,5 +42,4 @@ return; | ||
flip(node, resultNotUsed) { | ||
var lastNodeDesc = void 0; | ||
var lastNodeDesc; | ||
var ret = visit(node); | ||
ret[flipSeen] = true; | ||
@@ -52,3 +52,5 @@ | ||
if (parent && key && t.isUnaryExpression(parent[key], { operator: "!" })) { | ||
if (parent && key && t.isUnaryExpression(parent[key], { | ||
operator: "!" | ||
})) { | ||
parent[key] = parent[key].argument; | ||
@@ -61,5 +63,10 @@ } | ||
function visit(node, parent, key) { | ||
lastNodeDesc = { parent, key }; | ||
lastNodeDesc = { | ||
parent, | ||
key | ||
}; | ||
if (t.isUnaryExpression(node, { operator: "!" })) { | ||
if (t.isUnaryExpression(node, { | ||
operator: "!" | ||
})) { | ||
return node.argument; | ||
@@ -76,3 +83,4 @@ } | ||
if (t.isBinaryExpression(node)) { | ||
var operator = void 0; | ||
var operator; | ||
switch (node.operator) { | ||
@@ -82,8 +90,11 @@ case "!==": | ||
break; | ||
case "===": | ||
operator = "!=="; | ||
break; | ||
case "!=": | ||
operator = "=="; | ||
break; | ||
case "==": | ||
@@ -97,5 +108,4 @@ operator = "!="; | ||
return node; | ||
} | ||
} // Falls through to unary expression | ||
// Falls through to unary expression | ||
} | ||
@@ -106,3 +116,4 @@ | ||
} | ||
}; | ||
}; |
{ | ||
"name": "babel-helper-flip-expressions", | ||
"version": "0.4.0-alpha.6546ad11", | ||
"version": "0.4.0-alpha.caaefb4c", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
3069
87