gb-random
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

/gb-random/

    Package Sidebar

    Install

    npm i gb-random

    Weekly Downloads

    0

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • garyb432