Function safeAsync

Run an async function safely and return the result (or the thrown error).

  • Type Parameters

    • T = unknown
    • E = Error

    Parameters

    • fn: () => Promise<T>

      Async function to run

    Returns Promise<SafeRunResult<T, E>>

    Result of the run