A generator backed by Web Crypto (crypto.getRandomValues), available in
every modern browser and in Node >= 15. It holds no state: every instance
draws from the same platform source. fillBytes accepts any length; the
platform's 65,536-byte per-call quota is handled by filling in chunks.
Throws
CryptoUnavailable from any draw when the environment has no Web Crypto API.
Debug label: Object.prototype.toString reports the class name.
Returns string
Methods
nextU32
nextU32():number
The low 32 bits of an 8-byte draw.
Returns number
nextU64
nextU64():bigint
An 8-byte draw as a little-endian u64.
Returns bigint
nextU64Low32
nextU64Low32():number
The samplers' fast path: one 8-byte draw, low 32 bits, no bigint.
Returns number
fillBytes
fillBytes(dest:Uint8Array):void
Fill dest with secure random bytes. Any length: buffers above 65,536
bytes are filled in chunks of at most that size (subarray views, no
copies); shorter ones take one getRandomValues call.
A generator backed by Web Crypto (
crypto.getRandomValues), available in every modern browser and in Node >= 15. It holds no state: every instance draws from the same platform source.fillBytesaccepts any length; the platform's 65,536-byte per-call quota is handled by filling in chunks.Throws
CryptoUnavailablefrom any draw when the environment has no Web Crypto API.