Another promise limiter (adding concurrency to promises). This library uses rxjs to control concurrency, it also adds a little bit of extra functionality around how you get the results.
To install this package, run,
npm install --save promax
Once it's installed, you can use
Promax to run your promises with a specified concurrency value. Pretend we had the following promise function:
Our code with
Promax could be used in many ways:
NOTE: In this case, we didn't change the settings at the start so if a promise is rejected, it'll throw and end the call.
What if we don't want it do throw?
When it doesn't throw, it wraps errored results in an
ErrorResult instance. Using
insanceof ErrorResult will tell you whether or not there was an error in your array of results. Let's assume we have the following function,
Then we may get the following,
IMPORTANT: If you don't need the functionality above, you can chain everything into one call:
And you can send in the result map by reference: