1.0.1 • Published 4 years ago

xrand v1.0.1

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

This is a simple tiny library to generate numbers between two integers (both inclusive) randomly without repetition.

    npm install --save xrand
const Xrand = require("xrand");

// supply two numbers to generate unique random numbers

const xrand = new Xrand(1, 3);

To generate random number call xrand.generate() method

// to generate a number random number;

console.log(xrand.generate());

console.log(xrand.generate());

console.log(xrand.generate());

after 3 random numbers between 1 to 3 further call to generate returns false

console.log(xrand.generate());

// returns false
const myRand = new Xrand(1, 100);

for (let i = 1; i <= 100; i++) {

    // this will print 100 numbers between 1 to 100 
    // (both inclusive) randomly without repetition
    
    console.log(myRand.generate());
}

// further call to myRand.generate() return false

console.log(myRand.generate());

To get all numbers between two integers randomly at once use xrand.generateAll()

 const values = new Xrand(-5, 5).generateAll();
1.0.1

4 years ago

1.0.0

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago