unreachable-branch-transform
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "unreachable-branch-transform", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Browserify transform to remove unreachable code", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"dependencies": { | ||
"recast": "^0.9.15", | ||
"recast": "^0.10.1", | ||
"through2": "^0.6.2" | ||
@@ -35,0 +35,0 @@ }, |
@@ -7,12 +7,12 @@ var booleanCondition = require('./lib/evaluator').booleanCondition; | ||
module.exports = removeUnreachable; | ||
var VISITOR_METHODS = { | ||
visitLogicalExpression: visitLogicalExp, | ||
visitIfStatement: visitCondition, | ||
visitConditionalExpression: visitCondition | ||
}; | ||
function removeUnreachable(branch) { | ||
recast.visit(branch, { | ||
visitLogicalExpression: visitLogicalExp, | ||
visitIfStatement: visitCondition, | ||
visitConditionalExpression: visitCondition | ||
}); | ||
module.exports = function(branch) { | ||
recast.visit(branch, VISITOR_METHODS); | ||
return branch; | ||
} | ||
}; | ||
@@ -35,3 +35,3 @@ | ||
path.replace(b.literal(true)); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
@@ -43,3 +43,3 @@ } | ||
path.replace(path.node.right); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
@@ -51,3 +51,3 @@ } | ||
path.replace(b.literal(false)); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
@@ -59,3 +59,3 @@ } | ||
path.replace(path.node.right); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
@@ -80,3 +80,3 @@ } | ||
path.replace(path.value.consequent); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
@@ -88,5 +88,5 @@ } | ||
path.replace(path.value.alternate); | ||
removeUnreachable(path); | ||
recast.visit(path, VISITOR_METHODS); | ||
return false; | ||
} | ||
} |
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
18141
+ Addedast-types@0.8.15(transitive)
+ Addedesprima-fb@15001.1001.0-dev-harmony-fb(transitive)
+ Addedrecast@0.10.43(transitive)
+ Addedsource-map@0.5.7(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedast-types@0.6.16(transitive)
- Removedesprima-fb@10001.1.0-dev-harmony-fb(transitive)
- Removedrecast@0.9.18(transitive)
- Removedsource-map@0.1.43(transitive)
Updatedrecast@^0.10.1