starry.async-race

4.0.1 • Public • Published

Member of the starry suite—modular functions for iterable objects.

npm node

Status

Applies to the whole suite.

Build Status Coverage Status

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.

Package Sidebar

Install

npm i starry.async-race

Weekly Downloads

0

Version

4.0.1

License

MIT

Unpacked Size

3.51 kB

Total Files

9

Last publish

Collaborators

  • seangenabe