Closed Richienb closed 9 months ago
Bump :)
What's left to do here?
What's left to do here?
docs
Why do we need the separate backpressure
option?
Why do we need the separate
backpressure
option?
Values returned by the async iterator can only be consumed one at a time. However, we can run the mapper function concurrency
times in parallel. This means there will end up being a backlog of values that are waiting to be consumed. We limit the size of the backlog using backpressure
such that we don't allow further calls to the mapper function if doing so would cause it to exceed the backpressure
.
Might be a good idea to try re-implement pMap
using pMapIterable
to simplify the code and see where its holes are.
Values returned by the async iterator can only be consumed one at a time. However, we can run the mapper function concurrency times in parallel. This means there will end up being a backlog of values that are waiting to be consumed. We limit the size of the backlog using backpressure such that we don't allow further calls to the mapper function if doing so would cause it to exceed the backpressure.
👍
What should happen when the mapper function returns an error?
pMap
simply throws the error because it only returns the values when everything finishes. However, pMapIterable
streams returned values. Should it just prevent future values down the iterable from running and let the ones before it finish?
An error should generally make things stop as soon as possible, so I don't think it should even let the current ones finish.
Ok I guess I'll throw out values that arrived out of order after an error.
@sindresorhus I did stuff
Nice! Big improvement.
Nice work 🙏
Main differences from
pMap()
:stopOnError
is not available because this can now be done by the user themselvessignal
is also not available for the same reasonIf you're ok with this, I'll add docs and tests
Fixes https://github.com/sindresorhus/promise-fun/issues/21