@mohayonao/randgen
v0.2.0
Published
simple random generator
Downloads
2
Readme
RANDGEN
simple random generator
Installation
npm install @mohayonao/randgen
API
RandGen
constructor([ seed: number ])
Instance attributes
random(): number
Examples
import RandGen from "@mohayonao/randgen";
function sample(list, rand = Math.random) {
return list[(rand() * list.length)|0];
}
let rand = new RandGen(123456789).random;
let list = [ 1, 2, 3, 4, 5 ];
console.log(sample(list, rand)); // 5
console.log(sample(list, rand)); // 3
console.log(sample(list, rand)); // 2
License
MIT