Function settled

  • Category

    Settle a promise by returning a tuple of the resolved value or rejected error. This function never rejects.

    Time complexity: O(1)

    Space complexity: O(1)

    Type Parameters

    • E
    • T

    Parameters

    • promise: PromiseLike<T>

      The promise to settle

    Returns Promise<Result<T, E>>

    A tuple of the resolved value or rejected error

    Promise

    Example

    const [value, error] = await settled(promise);