Skip to content
The @xtandard/lib logoThe @xtandard/lib logo

@xtandard/lib

Lightweight, type-safe TypeScript utilities. A zero-dependency core, plus opt-in entry points for intervals, pagination, filters, URL state and the libraries you already use.
Terminal window
npm install @xtandard/lib

One package, many entry points. Import only what you need: every entry point is tree-shakeable, and each one’s dependencies are optional peer dependencies, installed only when you use it.

import { tryCatch, collect, defer } from "@xtandard/lib";
const [config, parseError] = tryCatch(() => JSON.parse(raw)); // sync in → sync out
const [user, fetchError] = await tryCatch(fetchUser(id)); // promise in → promise out
const rows = await collect(streamRows()); // drain any iterable or async iterable
async function job() {
await using _ = defer(() => console.log("cleanup")); // runs when the scope ends
}

Errors as values, async primitives (Completer, AsyncChannel), iterables, disposables, type guards and string helpers. Zero dependencies. Explore the core →

Zero-dependency core

The bare @xtandard/lib import uses only standard JavaScript, so the same code runs in Node, Bun, Deno, browsers and edge runtimes.

Pay only for what you import

Each integration is its own entry point with optional peers. Importing the filters never pulls in React; importing the core pulls in nothing. Entry points →

As synchronous as your input

tryCatch, collect, createPaginator and friends return plain values for sync input and Promises for async input, and their types say which. Sync/async-adaptive APIs →

Safe on both sides

The core, /interval, /pagination, /filters and /tanstack/server are frontend-safe, so the filter model and its URL codec can be shared between your server and your browser bundle.

Every box is an import path. The core is standalone; each family adds optional entry points for the libraries it works with.

flowchart LR
  CORE["<b>@xtandard/lib</b><br/>core · zero deps"]
  subgraph DATA["Data & queries"]
    direction TB
    INT["<b>/interval</b><br/>/dinero · /decimal · /big · /bignumber<br/>/fraction · /semver · /ip"]
    PAG["<b>/pagination</b><br/>/drizzle · /kysely · /knex · /mongo · /prisma"]
    FIL["<b>/filters</b><br/>schemas: /valibot · /zod · /arktype · /effect<br/>adapters: /drizzle · /kysely · /knex · /mongo · /prisma"]
  end
  subgraph UI["UI & URL"]
    direction TB
    TS["<b>/tanstack</b><br/>/server · /testing · /temporal · /rison"]
    RE["<b>/react</b> · <b>/sonner</b> · <b>/web</b>"]
  end
  subgraph LIBS["Library helpers"]
    direction TB
    LH["<b>/temporal</b> · <b>/ulid</b><br/><b>/dataloader</b> · <b>/unstorage</b><br/><b>/valibot</b> · <b>/zod</b> · <b>/arktype</b> · <b>/effect</b>"]
  end
  CORE --- DATA
  CORE --- UI
  CORE --- LIBS

@xtandard/lib has siblings: open-source, MIT-licensed projects that share the xtandard name. Each one stands on its own.

All of them, with npm and GitHub links: the xtandard ecosystem.