@usersatoshi/results
    Preparing search index...

    Function fromAsync

    • Helper to run an async function and capture errors as a Result.

      Equivalent to fromPromise(fn(), onErr) but convenient for passing a function instead of a promise value.

      Type Parameters

      • T
      • E extends { kind: number }

      Parameters

      • fn: () => Promise<T>

        async function producing T

      • onErr: (error: unknown) => E

        maps thrown values to an error of type E

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

      a Promise<Result<T, E>>