random-array

0.0.2 • Public • Published

random-array Build Status

Generating array of random numbers

Install

npm install random-array

Usage

var random = require('random-array');
//Generate array of size 10 between 1 and 10
random(1,10).oned(10);
//Generate array of width 3 and height 2 between 1 and 10
random(1,10).twod(3,2);
//Generate array of size 10 and round numbers between 1 and 10
random(1,10).oned(10, {round: true});

Generate array of random numbers, while function is false.

var random = require('random-array');
random(1,10).genWhile(function(x){ return Math.round(x) > 8;});

and output:

[ 4.424256478203461,
  4.920260030310601,
  4.706073637586087,
  5.157449695048854,
  9.543757784646004 ]

Because was found value 9.5437, function returns true and generation was stopped.

You can limit number of generation values:

random(1,10).genWhile(function(x){ return x === 11;}, {limit: 10});

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i random-array

Weekly Downloads

3

Version

0.0.2

License

MIT

Last publish

Collaborators

  • saromanov