@usersatoshi/results
    Preparing search index...

    Function fromPromise

    • Convert a Promise<T> into a Promise<Result<T, E>>.

      Resolves to Ok<T, E> when the promise fulfills, or to Err<T, E> when it rejects after mapping the rejection with onErr.

      Type Parameters

      • T
      • E extends { kind: number }

      Parameters

      • promise: Promise<T>

        the promise to observe

      • onErr: (error: unknown) => E

        maps a thrown value to an error object of type E

      Returns Promise<Ok<T> | Err<E>>

      a Promise<Result<T, E>>