Evercatch - v0.10.0
    Preparing search index...

    Variable unwrapOrReadonly

    unwrapOr: <T, E extends unknown = Error>(
        resultAsync: ResultAsync<T, E>,
        fallback: T,
    ) => Promise<T> = unwrapAsyncOr

    Type declaration

      • <T, E extends unknown = Error>(
            resultAsync: ResultAsync<T, E>,
            fallback: T,
        ): Promise<T>
      • Unwraps a ResultAsync, returning a fallback value if it contains an error.

        Type Parameters

        • T

          The type of the value.

        • E extends unknown = Error

          The type of the error.

        Parameters

        • resultAsync: ResultAsync<T, E>

          The ResultAsync to unwrap.

        • fallback: T

          The value to return when the result contains an error.

        Returns Promise<T>

        A promise that resolves to the unwrapped value or the fallback.

        const value = await unwrapAsyncOr(Promise.resolve(ok(42)), 0);
        console.log(value); // 42
        const value = await unwrapAsyncOr(
        Promise.resolve(err(new Error("Oops"))),
        0,
        );
        console.log(value); // 0