A Promise collection exposes useful methods for handling a collection of promises and their results.

Type Parameters

  • T

Hierarchy

  • default
    • PromiseCollection

Constructors

Accessors

Methods

Constructors

  • Type Parameters

    • T

    Parameters

    • source: undefined | null | PromiseLike<T>[]

    Returns PromiseCollection<T>

Accessors

  • get promises(): PromiseLike<T>[]
  • Returns a copy of the source promises.

    Returns

    Returns PromiseLike<T>[]

Methods

  • Returns void

  • Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.

    Returns

    Returns ArrayPromise<T>

  • Waits for all the values to resolve and then applies a transform.

    Returns

    Type Parameters

    • U

    Parameters

    • transform: ((value: T) => U)
        • (value: T): U
        • Parameters

          • value: T

          Returns U

    Returns ArrayPromise<U>

  • Applies a transform to each promise and defers the result. Unlike map, this doesn't wait for all promises to resolve, ultimately improving the async nature of the request.

    Returns

    Type Parameters

    • U

    Parameters

    • transform: ((value: T) => U | PromiseLike<U>)
        • (value: T): U | PromiseLike<U>
        • Parameters

          • value: T

          Returns U | PromiseLike<U>

    Returns PromiseCollection<U>

  • Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.

    Returns

    A new Promise.

    Returns PromiseBase<T>

  • Behaves like array reduce. Creates the promise chain necessary to produce the desired result.

    Returns

    Parameters

    • reduction: ((previousValue: T, currentValue: T, i?: number, array?: PromiseLike<T>[]) => T)
        • (previousValue: T, currentValue: T, i?: number, array?: PromiseLike<T>[]): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • Optional i: number
          • Optional array: PromiseLike<T>[]

          Returns T

    • Optional initialValue: T | PromiseLike<T>

    Returns PromiseBase<T>

  • Behaves like array reduce. Creates the promise chain necessary to produce the desired result.

    Returns

    Type Parameters

    • U

    Parameters

    • reduction: ((previousValue: U, currentValue: T, i?: number, array?: PromiseLike<T>[]) => U)
        • (previousValue: U, currentValue: T, i?: number, array?: PromiseLike<T>[]): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • Optional i: number
          • Optional array: PromiseLike<T>[]

          Returns U

    • initialValue: U | PromiseLike<U>

    Returns PromiseBase<U>

  • Returns a promise that is fulfilled with array of provided promises when all provided promises have resolved (fulfill or reject). Unlike .all this method waits for all rejections as well as fulfillment.

    Returns

    Returns ArrayPromise<PromiseLike<T>>

Generated using TypeDoc