@zedtech/zedkit-core
v1.0.0
Published
Typed Result helpers, safe try/catch wrappers, and prefixed IDs for any JS/TS project — stop writing the same utilities in every repo. Original work by the same author.
Maintainers
Readme
@zedtech/zedkit-core
Typed Result helpers, safe try/catch wrappers, and prefixed IDs for any JS/TS project. Original work by the same author.
Install from npm only (no shadcn registry copy path). See install or copy on the docs site for how that differs from UI bricks.
Install
pnpm add @zedtech/zedkit-coreUsage
import { tryCatch } from "@zedtech/zedkit-core";
const parsed = tryCatch(() => JSON.parse(input));
if (!parsed.ok) return fallback(parsed.error);When to use
Reach for this package when you handle errors, generate IDs, or hash
values in TypeScript. For server hardening (rate limiting, log
redaction) see @zedtech/zedkit-server instead.
API
Result<T, E = Error>—{ ok: true, value: T } | { ok: false, error: E }ok(value),err(error),isOk(result),isErr(result)mapResult(result, fn),unwrapOr(result, fallback)tryCatch(fn),tryCatchAsync(fn)— never swallow; non-Errorthrows becomeErrorwithcauseset. Rawtry/catchstays banned everywhere else.newPrefixedId(prefix),isPrefixedId(id, prefix)—"<prefix>_<ulid>"IDs via a thin wrapper over theulidpackage (see the golden rule).
Find helpers by need in CATALOG.md.
Install or copy?
result and try-catch are tiny and dependency-free: source-copying the
two files is a sane alternative to installing (MIT allows it). Install
the package when you also want ids (which needs the ulid
dependency) or versioned updates.
Verify
pnpm --filter @zedtech/zedkit-core typecheck && pnpm --filter @zedtech/zedkit-core lint && pnpm --filter @zedtech/zedkit-core build && pnpm --filter @zedtech/zedkit-core test