@babel/helper-wrap-function
Advanced tools
Comparing version 7.16.7 to 7.16.8
@@ -60,3 +60,3 @@ "use strict"; | ||
function plainFunction(path, callId, noNewArrows) { | ||
function plainFunction(path, callId, noNewArrows, ignoreFunctionLength) { | ||
const node = path.node; | ||
@@ -80,2 +80,12 @@ const isDeclaration = path.isFunctionDeclaration(); | ||
const built = callExpression(callId, [node]); | ||
const params = []; | ||
for (const param of node.params) { | ||
if (isAssignmentPattern(param) || isRestElement(param)) { | ||
break; | ||
} | ||
params.push(path.scope.generateUidIdentifier("x")); | ||
} | ||
const container = wrapper({ | ||
@@ -85,14 +95,3 @@ NAME: functionId || null, | ||
FUNCTION: built, | ||
PARAMS: node.params.reduce((acc, param) => { | ||
acc.done = acc.done || isAssignmentPattern(param) || isRestElement(param); | ||
if (!acc.done) { | ||
acc.params.push(path.scope.generateUidIdentifier("x")); | ||
} | ||
return acc; | ||
}, { | ||
params: [], | ||
done: false | ||
}).params | ||
PARAMS: params | ||
}); | ||
@@ -114,3 +113,3 @@ | ||
if (!retFunction || retFunction.id || node.params.length) { | ||
if (!retFunction || retFunction.id || !ignoreFunctionLength && params.length) { | ||
path.replaceWith(container); | ||
@@ -123,8 +122,8 @@ } else { | ||
function wrapFunction(path, callId, noNewArrows = true) { | ||
function wrapFunction(path, callId, noNewArrows = true, ignoreFunctionLength = false) { | ||
if (path.isMethod()) { | ||
classOrObjectMethod(path, callId); | ||
} else { | ||
plainFunction(path, callId, noNewArrows); | ||
plainFunction(path, callId, noNewArrows, ignoreFunctionLength); | ||
} | ||
} |
{ | ||
"name": "@babel/helper-wrap-function", | ||
"version": "7.16.7", | ||
"version": "7.16.8", | ||
"description": "Helper to wrap functions inside a function call.", | ||
@@ -19,4 +19,4 @@ "repository": { | ||
"@babel/template": "^7.16.7", | ||
"@babel/traverse": "^7.16.7", | ||
"@babel/types": "^7.16.7" | ||
"@babel/traverse": "^7.16.8", | ||
"@babel/types": "^7.16.8" | ||
}, | ||
@@ -23,0 +23,0 @@ "engines": { |
5300
102
Updated@babel/traverse@^7.16.8
Updated@babel/types@^7.16.8