@babel/plugin-transform-parameters
Advanced tools
Comparing version 7.20.7 to 7.21.3
@@ -30,3 +30,2 @@ "use strict"; | ||
}); | ||
if (!path.isFunctionExpression()) return; | ||
@@ -33,0 +32,0 @@ } |
@@ -27,3 +27,2 @@ "use strict"; | ||
`); | ||
function convertFunctionParams(path, ignoreFunctionLength, shouldTransformParam, replaceRestElement) { | ||
@@ -112,7 +111,5 @@ const params = path.get("params"); | ||
} | ||
if (firstOptionalIndex !== null) { | ||
node.params = node.params.slice(0, firstOptionalIndex); | ||
} | ||
path.ensureBlock(); | ||
@@ -126,6 +123,4 @@ const { | ||
path.set("body", _core.types.blockStatement(body)); | ||
const bodyPath = path.get("body.body"); | ||
const arrowPath = bodyPath[bodyPath.length - 1].get("argument.callee"); | ||
arrowPath.arrowFunctionToExpression(); | ||
@@ -132,0 +127,0 @@ arrowPath.node.generator = generator; |
@@ -48,3 +48,2 @@ "use strict"; | ||
state.noOptimise = oldNoOptimise; | ||
path.skip(); | ||
@@ -56,7 +55,5 @@ }, | ||
} = path; | ||
if (node.name === "arguments") { | ||
state.deopted = true; | ||
} | ||
if (!referencesRest(path, state)) return; | ||
@@ -69,7 +66,5 @@ if (state.noOptimise) { | ||
} = path; | ||
if (parentPath.listKey === "params" && parentPath.key < state.offset) { | ||
return; | ||
} | ||
if (parentPath.isMemberExpression({ | ||
@@ -79,12 +74,5 @@ object: node | ||
const grandparentPath = parentPath.parentPath; | ||
const argsOptEligible = !state.deopted && !( | ||
grandparentPath.isAssignmentExpression() && parentPath.node === grandparentPath.node.left || | ||
grandparentPath.isLVal() || | ||
grandparentPath.isForXStatement() || | ||
grandparentPath.isUpdateExpression() || | ||
grandparentPath.isUnaryExpression({ | ||
const argsOptEligible = !state.deopted && !(grandparentPath.isAssignmentExpression() && parentPath.node === grandparentPath.node.left || grandparentPath.isLVal() || grandparentPath.isForXStatement() || grandparentPath.isUpdateExpression() || grandparentPath.isUnaryExpression({ | ||
operator: "delete" | ||
}) || | ||
(grandparentPath.isCallExpression() || grandparentPath.isNewExpression()) && parentPath.node === grandparentPath.node.callee); | ||
}) || (grandparentPath.isCallExpression() || grandparentPath.isNewExpression()) && parentPath.node === grandparentPath.node.callee); | ||
if (argsOptEligible) { | ||
@@ -99,4 +87,3 @@ if (parentPath.node.computed) { | ||
} | ||
} else if ( | ||
parentPath.node.property.name === "length") { | ||
} else if (parentPath.node.property.name === "length") { | ||
state.candidates.push({ | ||
@@ -110,3 +97,2 @@ cause: "lengthGetter", | ||
} | ||
if (state.offset === 0 && parentPath.isSpreadElement()) { | ||
@@ -125,3 +111,2 @@ const call = parentPath.parentPath; | ||
}, | ||
BindingIdentifier(path, state) { | ||
@@ -180,3 +165,2 @@ if (referencesRest(path, state)) { | ||
const replacedParentPath = parentPath; | ||
const offsetTestPath = replacedParentPath.get("test"); | ||
@@ -229,3 +213,2 @@ const valRes = offsetTestPath.get("left").evaluate(); | ||
node.params.pop(); | ||
if (_core.types.isPattern(rest)) { | ||
@@ -242,3 +225,2 @@ const pattern = rest; | ||
const paramsCount = getParamsCount(node); | ||
const state = { | ||
@@ -254,3 +236,2 @@ references: [], | ||
path.traverse(memberExpressionOptimisationVisitor, state); | ||
if (!state.deopted && !state.references.length) { | ||
@@ -284,3 +265,2 @@ for (const { | ||
arrKey = _core.types.binaryExpression("-", _core.types.cloneNode(key), _core.types.cloneNode(start)); | ||
arrLen = _core.types.conditionalExpression(_core.types.binaryExpression(">", _core.types.cloneNode(len), _core.types.cloneNode(start)), _core.types.binaryExpression("-", _core.types.cloneNode(len), _core.types.cloneNode(start)), _core.types.numericLiteral(0)); | ||
@@ -304,3 +284,2 @@ } else { | ||
let target = path.getEarliestCommonAncestorFrom(state.references).getStatementParent(); | ||
target.findParent(path => { | ||
@@ -307,0 +286,0 @@ if (path.isLoop()) { |
{ | ||
"name": "@babel/plugin-transform-parameters", | ||
"version": "7.20.7", | ||
"version": "7.21.3", | ||
"description": "Compile ES2015 default and rest parameters to ES5", | ||
@@ -26,3 +26,3 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.20.7", | ||
"@babel/core": "^7.21.3", | ||
"@babel/helper-plugin-test-runner": "^7.18.6" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
64663
1
15
528