Function createRacePromise

The createRacePromise method takes an array of promises as input and returns a single Promise. This returned promise settles with the eventual state of the first promise that settles.

The createRacePromise method is one of the promise concurrency methods. It's useful when you want the first async task to complete, but do not care about its eventual state (i.e. it can either succeed or fail). If the iterable contains one or more non-promise values and/or an already settled promise, then Promise.race() will settle to the first of these values found in the iterable.

0.5.0

An the array of promises.

Optional timeout to wait before processing the items, defaults to zero, only used when Native promises are not available.

A Promise that settles with the eventual state of the first promise in the iterable to settle. In other words, it fulfills if the first promise to settle is fulfilled, and rejects if the first promise to settle is rejected. The returned promise remains pending forever if the iterable passed is empty. If the iterable passed is non-empty but contains no pending promises, the returned promise will settle based on the current promise implementation.

  • The createRacePromise method takes an array of promises as input and returns a single Promise. This returned promise settles with the eventual state of the first promise that settles.

    Type Parameters

    • T

    Parameters

    • values: Iterable<T | PromiseLike<T>>

      An iterable object of promises.

    • Optionaltimeout: number

      Optional timeout to wait before processing the items, defaults to zero, only used when Native promises are not available.

    Returns IPromise<Awaited<T>>

    A Promise that settles with the eventual state of the first promise in the iterable to settle. In other words, it fulfills if the first promise to settle is fulfilled, and rejects if the first promise to settle is rejected. The returned promise remains pending forever if the iterable passed is empty. If the iterable passed is non-empty but contains no pending promises, the returned promise will settle based on the current promise implementation.

    The createRacePromise method is one of the promise concurrency methods. It's useful when you want the first async task to complete, but do not care about its eventual state (i.e. it can either succeed or fail). If the iterable contains one or more non-promise values and/or an already settled promise, then Promise.race() will settle to the first of these values found in the iterable.

    0.5.0