// Sets Math.random to a PRNG initialized using the given explicit seed. Math.seedrandom('hello.'); console.log(Math.random()); // Always 0.9282578795792454 console.log(Math.random()); // Always 0.3752569768646784
// Sets Math.random to an ARC4-based PRNG that is autoseeded using the // current time, dom state, and other accumulated local entropy. // The generated seed string is returned. Math.seedrandom(); console.log(Math.random()); // Reasonably unpredictable.
// Seeds using the given explicit seed mixed with accumulated entropy. Math.seedrandom('added entropy.', { entropy: true }); console.log(Math.random()); // As unpredictable as added entropy.
// Use "new" to create a local prng without altering Math.random. var myrng = new Math.seedrandom('hello.'); console.log(myrng()); // Always 0.9282578795792454
// Use "quick" to get only 32 bits of randomness in a float. console.log(myrng.quick()); // Always 0.3752569768112153
// Use "int32" to get a 32 bit (signed) integer console.log(myrng.int32()); // Always 986220731
// Local PRNG: does not affect Math.random. var seedrandom = require('seedrandom'); var rng = seedrandom('hello.'); console.log(rng()); // Always 0.9282578795792454
// Global PRNG: set Math.random. seedrandom('hello.', { global: true }); console.log(Math.random()); // Always 0.9282578795792454