Signature
tsSignature
export function match<T, E, R>( result: Result<T, E>, handlers: { ok: (value: T) => R; err: (error: E) => R; },): R;Imports
tsImport
import { match } from "@/lib/flow/core/result";import { match } from "@/lib/flow";Type Parameters
TSuccess value type.
EExpected error value type.
RHandler return type.
Parameters
Returns
The value returned by the matching handler.
Return type
RDetails
`match` keeps success and error handling explicit without manual branching at the call site.
Examples
tsExample
const label = match(result, { ok: (user) => user.name, err: (error) => error.kind,});Related Symbols
err
Re-exports core result helpers used by advanced record internals.
re-export
ok
Re-exports core result helpers used by advanced record internals.
re-export
Result
Explicit success-or-failure outcome used throughout Flow.
type
Source
tsflow/core/result.ts:154-162
export function match<T, E, R>( result: Result<T, E>, handlers: { ok: (value: T) => R; err: (error: E) => R; },): R { return result.ok ? handlers.ok(result.value) : handlers.err(result.error);}