0.0.2 • Published 9 years ago

random-array v0.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

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