Hyrax is a TypeScript toolkit for the helpers every project ends up writing: range math, case conversion, a seeded random generator you can replay, and the DOM and React plumbing for listeners and clicks outside. No runtime dependencies.
1.0.0-rc.0 is a release candidate: not on npm yet.
Nothing here is mocked. The answers are computed in your browser by the code these docs document.
A stale example is worse than none. npm run docs:examples type-checks every example in the guides and in the TSDoc against the built package, resolved through its exports map, and runs the core ones. A trailing // => 10 is an assertion: the build fails the day clamp stops returning 10.
Run, answers asserted. The core guides and API pages. Each // => literal must equal what the code returns.
Type-checked, not run. /dom and /react, which need a browser or a component to mean anything.
Not checked. Skipped by hand, such as an example that is meant to throw.
clamp(15, 0, 10)// => 10ratio(30, 60)// => 0.5remap(5, [0, 10], [0, 100])// => 50lerp(0, 10, 0.5)// => 5toCamelCase("XMLHttpRequest")// => "xmlHttpRequest"toKebabCase("Ação rápida")// => "ação-rápida"coalesce(null, undefined, 0, "x")// => 0new Random("level-1").int(1, 100)// => 25 Import only what your runtime has. The core never touches the DOM, /dom never touches React, and /react is a thin layer over /dom. Named exports only, no side effects on import: a bundler keeps exactly what you use.
import { clamp, Random } from "@gabreusi/hyrax";Pure functions and three small classes. No DOM and no React in its types; the compiler enforces it.
Every function is its own export and nothing runs on import, so one function costs what it weighs. Each import also has a size budget that fails the build when it grows.
| You import | Scale | Costs about |
|---|---|---|
clamp | 76 B | |
listen from /dom | 85 B | |
useForceUpdate from /react | 96 B | |
hx from /react | 630 B | |
the whole of /dom | 1.1 kB | |
the whole of /react | 1.5 kB | |
Random | 3.2 kB | |
the whole core | 4.6 kB |