Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

random-array

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

random-array

Create array with random numbers

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 19 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc