Closed MajorBreakfast closed 3 years ago
Why not just (await pMap(…)).flat()
?
I used pFlatMap
for better readability. With (await pMap(…)).flat()
the intention behind the code was less obvious.
I personally think the intention is quite clear, even more so than pFlatMap
.
Why not just
(await pMap(…)).flat()
?
Apart from the IMO worse readability due to the required parentheses there is also the disadvantage of requiring slightly more memory. That, however, would also not be solved by the simple implementation proposed above but would require touching more code
Why not just
(await pMap(…)).flat()
?
Another limitation which more people might be stumble upon is that this simply not possible when using pMapIterable
. In those cases one has to construct a nested loop which is definitely less readable than pFlatMapIterable
I encountered the need for
p-flat-map
. Here's what I came up with:Usage example:
Would it be possible to add this to the collection?