Function settleObject

  • Settle all of the fields of an object in parallel

    Returns

    The same object with every field settled

    Example

    await settleObject({
    a: Promise.resolve('a'),
    b: Promise.resolve('b'),
    }) === {
    a: { status: 'fulfilled', value: 'a' },
    b: { status: 'fulfilled', value: 'b' },
    }

    Example

    await settleObject({
    a: Promise.resolve('a'),
    b: Promise.reject('b'),
    }) === {
    a: { status: 'fulfilled', value: 'a' },
    b: { status: 'rejected', reason: 'b' },
    }

    See

    resolveObject if you want to fail on any promise rejection

    Type Parameters

    • T extends Record<PropertyKey, Promise<unknown>>

    Parameters

    • object: T

      An object where every field is a promise

    Returns Promise<{
        [k in string | number | symbol]: PromiseSettledResult<T[k]>
    }>

Generated using TypeDoc