1.1.0 • Published 7 years ago

gb-random v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Build Status Coverage Status MIT license

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 ]
});