📖 Documentation · API Reference
pnpm add @unthrown/boxed @bloodyowl/boxedBoxed's Result has two channels (Ok/Error) and no defect channel. Coming
in, every Boxed result is an Ok or Error — never a Defect. Going
out, a Defect has nowhere to live, so toBoxed forces you to triage it
with onDefect — no defect is ever silently folded into your domain error type.
import { Ok } from "unthrown";
import { toBoxed, fromBoxed } from "@unthrown/boxed";
import { Result } from "@bloodyowl/boxed";
toBoxed(Ok(1), (cause) => ({ _tag: "Bug", cause })); // Result.Ok(1)
fromBoxed(Result.Ok(1)); // Result<number, never>toBoxed(r, onDefect)/fromBoxed(r)— syncResult ↔ Result.toBoxedFuture(ar, onDefect)/fromBoxedFuture(future)— asyncAsyncResult ↔ Future<Result>.
Boxed's
Optionhas no analogue here — per unthrown's design, absence is expressed withT | undefinedorResult<T, NotFound>(seefromNullable), not a dedicatedOptiontype.
@bloodyowl/boxed is a peer dependency. (Boxed was formerly published as
@swan-io/boxed, now deprecated in favour of this maintained scope.)
MIT © Benoit TRAVERS