babel-plugin-minify-simplify
Advanced tools
Comparing version 0.5.0-alpha.540d75e7 to 0.5.0-alpha.5a128fd5
@@ -963,13 +963,15 @@ "use strict"; | ||
function earlyReturnTransform(path) { | ||
const node = path.node; | ||
const block = path.get("body"); | ||
if (!t.isBlockStatement(node.body)) { | ||
if (!block.isBlockStatement()) { | ||
return; | ||
} | ||
for (let i = node.body.body.length; i >= 0; i--) { | ||
const statement = node.body.body[i]; | ||
const body = block.get("body"); | ||
if (t.isIfStatement(statement) && !statement.alternate && t.isReturnStatement(statement.consequent) && !statement.consequent.argument) { | ||
genericEarlyExitTransform(path.get("body").get("body")[i]); | ||
for (let i = body.length - 1; i >= 0; i--) { | ||
const statement = body[i]; | ||
if (t.isIfStatement(statement.node) && !statement.node.alternate && t.isReturnStatement(statement.node.consequent) && !statement.node.consequent.argument) { | ||
genericEarlyExitTransform(statement); | ||
} | ||
@@ -980,19 +982,23 @@ } | ||
function earlyContinueTransform(path) { | ||
const node = path.node; | ||
const block = path.get("body"); | ||
if (!t.isBlockStatement(node.body)) { | ||
if (!block.isBlockStatement()) { | ||
return; | ||
} | ||
for (let i = node.body.body.length; i >= 0; i--) { | ||
const statement = node.body.body[i]; | ||
let body = block.get("body"); | ||
if (t.isIfStatement(statement) && !statement.alternate && t.isContinueStatement(statement.consequent) && !statement.consequent.label) { | ||
genericEarlyExitTransform(path.get("body").get("body")[i]); | ||
for (let i = body.length - 1; i >= 0; i--) { | ||
const statement = body[i]; | ||
if (t.isIfStatement(statement.node) && !statement.node.alternate && t.isContinueStatement(statement.node.consequent) && !statement.node.consequent.label) { | ||
genericEarlyExitTransform(statement); | ||
} | ||
} // We may have reduced the body to a single statement. | ||
} // because we might have folded or removed statements | ||
if (node.body.body.length === 1 && !needsBlock(node.body, node)) { | ||
path.get("body").replaceWith(node.body.body[0]); | ||
body = block.get("body"); // We may have reduced the body to a single statement. | ||
if (body.length === 1 && !needsBlock(block.node, path.node)) { | ||
block.replaceWith(body[0].node); | ||
} | ||
@@ -999,0 +1005,0 @@ } |
{ | ||
"name": "babel-plugin-minify-simplify", | ||
"version": "0.5.0-alpha.540d75e7", | ||
"version": "0.5.0-alpha.5a128fd5", | ||
"description": "", | ||
@@ -15,6 +15,6 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.540d75e7", | ||
"babel-helper-flip-expressions": "^0.5.0-alpha.5a128fd5", | ||
"babel-helper-is-nodes-equiv": "^0.0.1", | ||
"babel-helper-to-multiple-sequence-expressions": "^0.5.0-alpha.540d75e7" | ||
"babel-helper-to-multiple-sequence-expressions": "^0.5.0-alpha.5a128fd5" | ||
} | ||
} |
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
58673
1483