Unwraps a Result, returning a fallback value if it contains an error.
The type of the value.
The type of the error.
The Result to unwrap.
The value to return when the result contains an error.
The unwrapped value or the fallback.
const value = unwrapOr(ok(42), 0);console.log(value); // 42 Copy
const value = unwrapOr(ok(42), 0);console.log(value); // 42
const value = unwrapOr(err(new Error("Oops")), 0);console.log(value); // 0 Copy
const value = unwrapOr(err(new Error("Oops")), 0);console.log(value); // 0
Unwraps a Result, returning a fallback value if it contains an error.