@zedtech/zedkit-core
Model success or failure without throwing
@zedtech/zedkit-core — beta
beta
At a glance
- Who: TypeScript developers who want typed outcomes instead of try/catch everywhere.
- What: Return
ok/errResults so failures are values the compiler forces you to handle. - Use when: For fallible operations (parsing, lookups, validation) where the caller must handle failure.
- Avoid when: For truly exceptional programmer bugs — throw (or assert) instead of returning
err. - See also: Handle errors without try/catch
Install
pnpm add @zedtech/zedkit-coreLatest: 0.1.2 (via changesets).
Example
import { isOk, ok, unwrapOr } from "@zedtech/zedkit-core";
const found = ok({ name: "zed" });
if (isOk(found)) console.log(found.value.name);
const name = unwrapOr(found, { name: "?" }).name;Wraps: (none)