gb-random
v1.1.0
Published
An alternative implementation of Math.random using crypto.getRandomBytes
Downloads
2
Maintainers
Readme
gb-random
An alternative implementation of Math.random using crypto.getRandomBytes
Usage
npm install gb-random --save
const gbrandom = require("gb-random");
const rand = new gbrandom.Random();
// just replace Math.random with rand.getRandomSync
// console.log(Math.random(), "Math.random()");
console.log(rand.getRandomSync(), "gb-random");
// you can also use async
rand.getRandom().then(random => {
console.log(random); // 0.3879
});
// or even better in an async function
const rando = await rnd.getRandom();
console.log(rando);
rand.getRandoms(3).then(randoms => {
console.log(randoms); // [ 0.3879, 0.9659, 0.3019 ]
});