API Reference
class CryptoRng
Non-deterministic OS entropy for keys and tokens. Never seed-dependent.
fn int(): IntOne cryptographic random word from the OS.
returns — unsigned 64-bit value as Int.
class Rng
Seeded Xoshiro256++ stream. Same seed replays the same sequence, which makes randomized tests reproducible.
init(seed: Int)
fields
- state: Array<Int>
fn bool(): BoolFair coin flip.
returns — true on even draws, false on odd draws.
fn int(min: Int, max: Int): IntDraw an integer in [min, max], inclusive on both ends.
min — lower bound.
max — upper bound.
returns — deterministic draw from the stream.
import { Rng } from "@std/random";
let r = Rng.seeded(7);
print(r.int(1, 10));fn next(): IntNext raw word of the stream, advancing internal state.
returns — signed 64-bit draw.
fn seeded(seed: Int): RngConstruct a stream from a seed.
seed — any integer; equal seeds give equal streams.
returns — fresh Rng.
import { Rng } from "@std/random";
let a = Rng.seeded(7);
let b = Rng.seeded(7);
print(a.next() == b.next());