Unbiased by construction
Math.floor(Math.random() * n) is subtly non-uniform for most n. Every
bounded integer here uses Lemireβs nearly-divisionless method, and anything
wider than 2^53 is refused rather than silently rounded.
import ransu from 'ransu'
ransu.random() // 0.7263β¦ β a Math.random() drop-inransu.integer(1, 6) // 4 β both ends includedransu.pick(['π', 'π']) // 'π'ransu.shuffle(deck) // a new array; the input is untouchedransu.uuid.v7() // '01997a2c-β¦' β sortable by timeransu.normal(170, 6) // 168.42β¦Unbiased by construction
Math.floor(Math.random() * n) is subtly non-uniform for most n. Every
bounded integer here uses Lemireβs nearly-divisionless method, and anything
wider than 2^53 is refused rather than silently rounded.
Reproducible
Nine engines, getState / setState / clone / split, and a stream that
stays identical across versions, runtimes and module systems.
Never asynchronous
No API returns a Promise β not even UUID v5, which needs a hash. That is a contract, checked in CI.
Runs everywhere
Node, Deno, Bun, browsers, Cloudflare Workers, Vercel Edge. Zero dependencies and no static import of any Node built-in.