random-array-generator

1.0.7 • Public • Published

Description

Generates an array of unique random integers using a Mersenne-twister algorithm.

Install

npm install random-array-generator

Usage

Add the following line of code to your project:

var generator = require('random-array-generator');

To generate an array of random numbers, pass an object into the "randomArray()" function, which will then return an array containing the generated numbers. The object must be in the form:

generator.randomArray({min: x, max: y, elements: z});

Where x and y represents the range (inclusive) of the random numbers to be generated and z is the number of random integers to be generated.

Example:

// import package into your project
var generator = require('random-array-generator');
 
// Generate 6 random numbers between 1 and 49 (inclusive) and log to the console.
console.log(generator.randomArray({min: 1, max: 49, elements: 6}));
 
// Result: [2, 34, 17, 11, 47, 25]

Acknowledgments

mersenne-twister

License

MIT

Package Sidebar

Install

npm i random-array-generator

Weekly Downloads

15

Version

1.0.7

License

MIT

Unpacked Size

2.35 kB

Total Files

3

Last publish

Collaborators

  • williepotgieter