• Wraps a function with a try catch, creating a new function with the same arguments but returning Ok if successful, Err if the function throws

    Type Parameters

    • Fn extends ((...args) => any)

    • E

    Parameters

    • fn: Fn

      function to wrap with ok on success or err on failure

    • Optional errorFn: ((e) => E)

      when an error is thrown, this will wrap the error result if provided

        • (e): E
        • Parameters

          • e: unknown

          Returns E

    Returns ((...args) => Result<ReturnType<Fn>, E>)

      • (...args): Result<ReturnType<Fn>, E>
      • Parameters

        • Rest ...args: Parameters<Fn>

        Returns Result<ReturnType<Fn>, E>

Generated using TypeDoc