export type RngAlgorithm = 'pcg64' | 'xoroshiro128+' | 'xorshift128+' | 'mersenne' | 'lcg32'; export declare class Rng { private engine; /** * Pass a seed for deterministic output, or omit for system entropy. * `algorithm` selects the PRNG backend (default: `'pcg64'`). * * String seeds are hashed to a u64 via FNV-1a 64-bit (UTF-8 bytes) inside * the WebAssembly layer, so `new Rng('hello.')` is fully deterministic and * cross-platform. Note that `new Rng('42')` and `new Rng(42)` produce * different sequences. */ constructor(seed?: number | bigint | string, algorithm?: RngAlgorithm); /** Random unsigned 32-bit integer [0, 2^32). */ int(): number; /** Random unsigned 64-bit integer as a BigInt in [0, 2^64). */ bigInt(): bigint; /** * Returns a high-throughput closure for sequential integer generation. * Pre-fetches `bufferSize` integers per WASM boundary crossing, * amortizing the per-call overhead across multiple invocations. * * The closure is independent of the parent Rng instance's single-call * methods — calling `rng.int()` after creating a stream does NOT * invalidate the stream's buffer. */ intStream(bufferSize?: number): () => number; /** * Generates an array of `length` random unsigned 32-bit integers * in a single WebAssembly boundary crossing. * Returns a Uint32Array view into WASM memory — valid until the next * call on this instance. Call `.slice()` if you need a persistent copy. */ ints(length: number): Uint32Array; /** Random float in [0, 1). */ float(): number; /** * Generates an array of `length` random floats in [0, 1) * in a single WebAssembly boundary crossing. * Returns a Float64Array view into WASM memory — valid until the next * call on this instance. Call `.slice()` if you need a persistent copy. */ floats(length: number): Float64Array; /** Random integer in [min, max). */ range(min: number, max: number): number; /** * Generates an array of `length` random integers in [min, max) * in a single WebAssembly boundary crossing. * Returns a Uint32Array view into WASM memory — valid until the next * call on this instance. Call `.slice()` if you need a persistent copy. */ ranges(min: number, max: number, length: number): Uint32Array; /** * Random boolean. `probability` controls the chance of * returning `true` (default 0.5). */ bool(probability?: number): boolean; /** * Pick a uniformly random element from a non-empty array. * Throws if the array is empty. */ pick(array: readonly T[]): T; /** * Return a new array with the same elements in a random * order (Fisher-Yates). The original is not mutated. */ shuffle(array: readonly T[]): T[]; /** Free Wasm memory. Call when the instance is no longer needed. */ free(): void; }