starry.async-race
v4.0.1
Published
Member of the starry suite—modular functions for iterable objects.
Downloads
10
Maintainers
Readme
Member of the starry suite—modular functions for iterable objects.
Status
Applies to the whole suite.
Usage
function asyncRace<T = any, U = any>(
iterable: Iterable<T>,
asyncAction: (item: T) => PromiseLike<U>
)
Returns a promise that resolves with the first, of the return values of asyncAction
called upon each element of iterable
, which resolved.
Parameters:
- iterable:
Iterable<T>
- An iterable collection - asyncAction:
(T) => PromiseLike<U>
- A thenable called with each item
Returns: Promise<U>
A handy shortcut for:
Promise.race([].map(async function() { ... }))
But with iterable support. ☺