promise-race-map
A Promise.race
implementation that works with JavaScript map.
Background
Promise.race
is useful when you need either one of the Promise to complete before proceeding. But if you need to process the result, it isn't easy to distinguish between two promises.
promise-race-map
Before using Before using this package, you will need to write code like this.
const p1 = ;const p2 = ; // Given both Promise do not return falsy valuesconst r1 r2 = await Promise; if r1 // Process result from fn1() else // Process result from fn2()
promise-race-map
After using After using this package, you can write shorter and more readable code like this.
const r1 r2 = await Promise; if r1 // Process result from fn1() else // Process result from fn2()
Contributions
Like us? Star us.
Want to make it better? File us an issue.
Don't like something you see? Submit a pull request.