Function createNativeAllSettledPromise

Returns a single asynchronous 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 using native environment promise implementation, if the runtime does not provide any native then the optional provided timeout value will be used to schedule when the chained items will be executed 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 = [
createNativeResolvedPromise(1),
createNativeResolvedPromise(2),
createNativeResolvedPromise(3),
createNativeRejectedPromise("error"),
];

const results = await createNativeAllSettledPromise(promises);

// results is:
// [
// { status: "fulfilled", value: 1 },
// { status: "fulfilled", value: 2 },
// { status: "fulfilled", value: 3 },
// { status: "rejected", reason: "error" }
// ]
  • Returns a single asynchronous 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 using native environment promise implementation, if the runtime does not provide any native then the optional provided timeout value will be used to schedule when the chained items will be executed 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 = [
    createNativeResolvedPromise(1),
    createNativeResolvedPromise(2),
    createNativeResolvedPromise(3),
    createNativeRejectedPromise("error"),
    ];

    const results = await createNativeAllSettledPromise(promises);

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