Documentation

Overview

Koyo is a zero-dependency standard library for TypeScript and JavaScript — string, number, array, object, and math utilities, plus reactive state, a typed DOM layer, and one error hierarchy across all of it. Everything behaves identically on Node.js, Bun, browsers, and edge runtimes.

Installation

npm
npm install koyojs
bun
bun add koyojs

Import styles

Koyo supports two import patterns:

index.ts
// 1. Named exports from the root (simple)
import { slugify, clamp, chunk, pick } from "koyojs";

// 2. Per-module imports (better tree-shaking)
import { toCamelCase } from "koyojs/String";
import { randomInt }   from "koyojs/Number";
import { chunk }       from "koyojs/Array";
import { pick }        from "koyojs/Object";
import { gcd }         from "koyojs/Math";
import { signal }      from "koyojs/State";
import { $ }           from "koyojs/DOM";
import { KoyoError }   from "koyojs/Error";

Modules

Philosophy

JavaScript has no proper standard library. The same operation behaves differently across environments, and every project ends up pulling in dozens of micro-packages to fill the gaps — one for string casing, one for deep cloning, one for reactivity, one for DOM helpers, each with its own conventions and its own error types.

Koyo covers that ground as a single, coherent piece: zero external dependencies, one module per concern, and consistent behaviour across every runtime. The utility modules stay one file per function so bundlers can drop what you don't import; State and DOM are larger by necessity, but remain separate entry points you only pay for when you reach for them.