Signature
tsSignature
export function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T;Imports
tsImport
import { unwrapOr } from "@/lib/flow/core/result";import { unwrapOr } from "@/lib/flow";Type Parameters
TSuccess value type.
EExpected error value type.
Parameters
Returns
The success value or fallback.
Return type
TDetails
Use this when a failure can be safely collapsed into a default value.
Examples
tsExample
const count = unwrapOr(result, 0);Related Symbols
Result
Explicit success-or-failure outcome used throughout Flow.
type
when
Branches between two behaviors using a predicate function.
function
Source
tsflow/core/result.ts:200-202
export function unwrapOr<T, E>(result: Result<T, E>, fallback: T): T { return result.ok ? result.value : fallback;}