Functions

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>(
outcome: O,
message: string
): Exclude<O, Any>

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>(
outcome: O,
fallback: U
): Exclude<O, Any> | U

Returns the success value, or fallback if the outcome is a failure.

Type Aliases

T
Result<T, E = Any> = T | E

The success value or a declared failure — a bare union, discriminated by the Failure brand.