• Executes all Promises in serial order and returns either the first result or throws an AggregateError containing all errors.

    An optional defaultValue can be provided that will be returned if promises is empty.

    If no Promises and no defaultValue were provided undefined will be returned.

    Example

    Execute all Promises in serial

    const promise = anySerial([
    Promise.reject("err"),
    Promise.resolve(1)
    ]);

    promise.then(v => console.log(v)); // 1

    Returns

    a Promise that executes all Promises in serial

    Type Parameters

    • T

    Parameters

    Returns Promise<undefined | T>

  • Executes all Promises in serial order and returns either the first result or throws an AggregateError containing all errors.

    An optional defaultValue can be provided that will be returned if promises is empty.

    If no Promises and no defaultValue were provided undefined will be returned.

    Example

    Execute all Promises in serial

    const promise = anySerial([
    Promise.reject("err"),
    Promise.resolve(1)
    ]);

    promise.then(v => console.log(v)); // 1

    Returns

    a Promise that executes all Promises in serial

    Type Parameters

    • T

    Parameters

    • promises: Iterable<Promise<T>>

      the Promises to execute in serial order

    • defaultValue: T

      the default value to return if no promise was provided

    Returns Promise<T>

Generated using TypeDoc