@tenets/result
v0.6.0
Published
Typed Result and ResultAsync primitives for recoverable failures — the API surface the tenets ruleset requires (Rule 7.6).
Readme
@tenets/result
Result<T, E> / ResultAsync<T, E> with ok, err, isOk, isErr, map, mapErr, andThen,
match, unwrapOr, combine, trySync, tryAsync — typed recoverable failures as values.
The tenets ruleset's TypeScript profile fixes these API names (Rule 7.6); your project guide records where the package lives.
Credit
The API shape follows neverthrow, the library that made
Result types idiomatic in TypeScript, with lineage back to Rust's Result, fp-ts's Either, and
Scott Wlaschin's railway-oriented programming. This package exists for a smaller, stricter core:
- Zero dependencies, plain frozen objects —
ok/errreturn frozen discriminated literals ({ ok: true, value }), so results serialize, structurally compare, and cross boundaries without class-instance identity problems. - Thenable async composition —
await resultAsyncyieldsResult<T, E>directly. combinefor first-error aggregation, and consumed-result discipline designed to pair with the ruleset's prohibitions (no dropped Results, no invariant laundering).
