Unwraps a ResultAsync, returning a fallback value if it contains an error.
The type of the value.
The type of the error.
The ResultAsync to unwrap.
The value to return when the result contains an error.
A promise that resolves to the unwrapped value or the fallback.
const value = await unwrapAsyncOr(Promise.resolve(ok(42)), 0);console.log(value); // 42 Copy
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 Copy
const value = await unwrapAsyncOr( Promise.resolve(err(new Error("Oops"))), 0,);console.log(value); // 0
Unwraps a ResultAsync, returning a fallback value if it contains an error.