You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have an index argument for the partition predicate, to make the API more similar to the already existing array functions like map, filter, reduce and others.
While at it I noticed several other functions that operate on arrays could use the index as well. For starters it would be worth to take a look at the array utils.
Following the logic of "least surprise", what do you think that the array functions resembled the regular array function's signature as closely with all 3 parameters — value, index and array?
map(callbackfn: (value: T,index: number,array: readonlyT[])=>unknown,thisArg?: any
): unknown[]
In that case I can go over array functions and update their callback functions. Should I also do so for the lodash compat functions, or leave them as is?
Activity
T3sT3ro commentedon Dec 16, 2025
While at it I noticed several other functions that operate on arrays could use the index as well. For starters it would be worth to take a look at the array utils.
T3sT3ro commentedon Dec 16, 2025
Following the logic of "least surprise", what do you think that the array functions resembled the regular array function's signature as closely with all 3 parameters — value, index and array?
raon0211 commentedon Dec 18, 2025
As you mentioned, I think there should be three arguments (value, index, and the original array) given to array functions.
T3sT3ro commentedon Dec 18, 2025
In that case I can go over array functions and update their callback functions. Should I also do so for the lodash compat functions, or leave them as is?
feat(partition): add index and array parameters to callback
feat(takeWhile): add index and array parameters to callback
feat(takeRightWhile): add index and array parameters to callback
feat(groupBy): add index and array parameters to callback
feat(countBy): add index and array parameters to callback
feat(keyBy): add index and array parameters to callback
feat(maxBy): add index and array parameters to callback
feat(minBy): add index and array parameters to callback
feat(uniqBy): add index and array parameters to callback
6 remaining items
feat(countBy): add index and array parameters to callback
feat(keyBy): add index and array parameters to callback
feat(maxBy): add index and array parameters to callback
feat(minBy): add index and array parameters to callback
feat(uniqBy): add index and array parameters to callback
feat(flatMap): add index and array parameters to callback
feat(flatMapDeep): add index and array parameters to callback
feat(zipWith): add index parameter to combine callback
feat(uniqBy): add index and array parameters to callback, ignore in c…
feat(flatMap): add index and array parameters to callback
feat(flatMapDeep): add index and array parameters to callback
feat(zipWith): add index parameter to combine callback
fix: Add index and array parameters to array function callbacks (#1561)
raon0211 commentedon Jan 15, 2026
For lodash-compatible functions, we actually want to preserve lodash's original behavior—so no changes needed here. Thanks for helping out though!