Add concurrency option
niftylettuce opened this issue · 3 comments
Similar to p-map
, it would be nice to have this built-in rather than have to use p-limit
for instance.
How would this even work? Reduce depends on the last value. If it doesn't, then why do you need reduce
?
How would this even work? Reduce depends on the last value. If it doesn't, then why do you need
reduce
?
One potential use-case would be when the values can be determined asynchronously and independent from each other. Currently this can mostly be archived with pMapIterable, however, that requires a for loop and thus cannot easily be used in e.g. an expression.
Or in other words: pReduce
should be able to accept not only Iterable<Promise|any>
but also AsyncIterator<any>
. This way one could write pReduce(pMapIterable(values, mapper), reducer, initialVal)