Open mass8326 opened 3 months ago
this is expected behavior. for lazy functions, the third parameter is always the array as it is being built, because otherwise it can't be lazy
i'm not sure where we can document this better—we have this pattern for nearly all of our lazy indexed functions.
You can disable lazy invocation by wrapping a data-first call:
remeda.pipe(
[1, 2, 3, 4],
($) => remeda.map($, (val, i, arr) => console.log(arr))
);
@cjquines, we could add an article to the top of the docs explaining this behavior. I'll remove the wontfix tag so we can track this, but I admit it's gonna be pretty low-pri as I wouldn't add an article about this before we also add other articles first.
Description
The parameters passed into
map()
do not match between data-first/data-last vs pipe/piped.It seems to happen in the latest version v2.0.9 with
map()
and seems to go as far back as v1.0.0 withmap.indexed()
Is this expected behavior? I didn't seem to catch this in the documentation for either
map()
orpipe()
.REPL: https://stackblitz.com/edit/remeda-piped-map-issue?file=index.js
Input
Output