Skip to content

Commit 9ac7835

Browse files
committed
Extended arity cases
1 parent 422a2e4 commit 9ac7835

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/function/matrix/map.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ export const createMap = /* #__PURE__ */ factory(name, dependencies, ({ typed })
140140
}
141141

142142
function _getCallbackCase (callback, numberOfArrays) {
143+
const callbackStr = callback.toString()
144+
// Check if the callback function uses `arguments`
145+
if (/arguments/.test(callbackStr)) return 2
146+
147+
// Extract the parameters of the callback function
148+
const paramsStr = callbackStr.match(/\(.*?\)/)
149+
// Check if the callback function uses rest parameters
150+
if (/\.\.\./.test(paramsStr)) return 2
143151
if (callback.length > numberOfArrays + 1) { return 2 }
144152
if (callback.length === numberOfArrays + 1) { return 1 }
145153
return 0

0 commit comments

Comments
 (0)