f
all<O>(outcomes: ReadonlyArray<O>): Result<Exclude<O, Any>[], Extract<O, Any>>
Collects an array of outcomes into an array of values, short-circuiting on the first
failure — the Result-shaped analogue of Promise.all.
f
expect<O>(): Exclude<O, Any>
outcome: O,
message: string
Returns the success value, or throws new Error(message, { cause: failure }).
f
partition<O>(outcomes: ReadonlyArray<O>): { values: Exclude<O, Any>[]; errors: Extract<O, Any>[]; }
Splits outcomes into their successes and their failures, keeping both.
f
unwrap<O>(outcome: O): Exclude<O, Any>
Returns the success value, or throws the failure.
f
unwrapOr<O, U>(): Exclude<O, Any> | U
outcome: O,
fallback: U
Returns the success value, or fallback if the outcome is a failure.
T
Result<T, E = Any> = T | E
The success value or a declared failure — a bare union, discriminated by the Failure
brand.
Usage
import * as mod from "lib/result/result.ts";