easy-random.js
An easy to use random helper for your applications.
Install
You can get it on npm.
npm install easy-random --save
Setup
First, you need to instantiate it using Node.js module loading system.
const random = ;
Or ES6 module, too.
;
Usage
nextBool
You can generate random booleans:
random; // true or false
nextInt
Generate random int numbers:
random; // Between 0 and 9
nextDouble
Generate random double numbers:
random; // Between 0.0 and 1.0: [0, 1)
choice
Choose a random element:
random; // choose a random char on a Stringrandom; // choose a random item on a Array
shuffle
Shuffle the sequence in place:
const items = 1 2 3 4 5 6 7;random; // [7, 3, 2, 5, 6, 4, 1]
sample
Return a x length list of unique elements chosen from the population sequence.
random; // Choose 3 elements. [4, 1, 5]
License
MIT License © Cesar William