Skip to content

ransu

Every random function you needed, in one package. Synchronous, zero dependencies, and correct where Math.random is not.
import ransu from 'ransu'
ransu.random() // 0.7263… β€” a Math.random() drop-in
ransu.integer(1, 6) // 4 β€” both ends included
ransu.pick(['🍎', '🍊']) // '🍊'
ransu.shuffle(deck) // a new array; the input is untouched
ransu.uuid.v7() // '01997a2c-…' β€” sortable by time
ransu.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.