You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
quick - Default method used. Provides 32 bits of randomness in a float. Can either be called by calling generator instance directly (ex.generator()) or by name (ex.generator.quick()).
double - Provides 56 bits of randomness.
int32 - Providers a 32 bit (signed) integer.
state - Provides internal generator state. Used for saving and restoring states.
You also have the option of saving and restoring state of your generator.
import{prngAlea}from'ts-seedrandom';constaleaGenerator=prngAlea('seed');constfirstValue=aleaGenerator();// Return internal generator state, which you can use in other generator instancesconststate=aleaGenerator.state();// This generator starts from the same state as first generator, but runs independentlyconstsecondAleaGenerator=prngAlea('seed',state);
Available Algorithms
The following PRNG algorithms are available:
prngAlea: Alea algorithm
prngArc4: ARC4 algorithm
prngTychei: Tyche-i algorithm
prngXor128: XorShift128 algorithm
prngXor4096: XorShift4096 algorithm
prngXorshift7: XorShift7 algorithm
prngXorwow: Xorwow algorithm
prngMulberry32: Mulberry 32 algorithm
prngXoshiro128Plus: Xoshiro128+ algorithm
prngXoshiro128PlusPlus: Xoshiro128++ algorithm
prngSplitMix64: SplitMix64 algorithm
prngSplitMix32: SplitMix32 algorithm
prngSfc32: SFC32 algorithm
prngJsf32: JSF32 algorithm
prngXoroshiro128ss: Xoshiro128** algorithm
prngXoroshiro128+: Xoroshiro128plus algorithm
prngParkMiller: Lehrer (Park-Miller) algorithm
You can import and use any of these algorithms in the same way as demonstrated in the usage examples above.
Test details / machine:Lenovo Legion 5 Pro 16ACH6H (Ryzen 7 5800H — 8 cores / 16 threads, base ≈ 3.2 GHz, turbo ≈ 4.4 GHz, DDR4-3200 memory); Node.js v24.10.0.
Why numbers vary: JIT warm-up, Node version, single vs multi-thread scheduling, background load, and micro-optimizations in each PRNG implementation all affect timings. Use these as a relative ranking on this machine, not an absolute cross-platform benchmark.
You can replicate this exact table by runningnpm run compare:performance