Function createAsyncAllSettledPromise

Returns a single Promise instance that resolves to an array of the results from the input promises. This returned promise will resolve and execute it's pending chained operations based on the Aasynchronous promise implementation. Any chained operations will execute asynchronously when the final operation pending promises have resolved, or if the input contains no promises. It will resolve only after all of the input promises have either resolved or rejected, and will resolve with an array of IPromiseResult objects that each describe the outcome of each promise.

0.5.0

An array of promises to wait to be resolved / rejected before resolving or rejecting the new promise

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

A pending Promise that will resolve to an array of IPromiseResult objects that each describe the outcome of each promise.

const promises = [
createResolvedPromise(1),
createResolvedPromise(2),
createResolvedPromise(3),
createRejectedPromise("error"),
];

const results = await createAllSettledPromise(promises);

// results is:
// [
// { status: "fulfilled", value: 1 },
// { status: "fulfilled", value: 2 },
// { status: "fulfilled", value: 3 },
// { status: "rejected", reason: "error" }
// ]
  • Returns a single Promise instance that resolves to an array of the results from the input promises. This returned promise will resolve and execute it's pending chained operations based on the Aasynchronous promise implementation. Any chained operations will execute asynchronously when the final operation pending promises have resolved, or if the input contains no promises. It will resolve only after all of the input promises have either resolved or rejected, and will resolve with an array of IPromiseResult objects that each describe the outcome of each promise.

    Type Parameters

    • T

    Parameters

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

      The iterator of promises to wait to be resolved / rejected before resolving or rejecting the new promise

    • Optionaltimeout: number

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

    Returns IPromise<IPromiseResult<Awaited<T>>[]>

    A pending Promise that will resolve to an array of IPromiseResult objects that each describe the outcome of each promise.

    0.5.0

    const promises = [
    createResolvedPromise(1),
    createResolvedPromise(2),
    createResolvedPromise(3),
    createRejectedPromise("error"),
    ];

    const results = await createAllSettledPromise(promises);

    // results is:
    // [
    // { status: "fulfilled", value: 1 },
    // { status: "fulfilled", value: 2 },
    // { status: "fulfilled", value: 3 },
    // { status: "rejected", reason: "error" }
    // ]