npm-random
v1.0.2
Published
A collection of helper functions to make randomness easier
Downloads
12
Readme
npm-random
A collection of helper functions to make randomness easier
Install
npm install npm-random
Functions
bool
: Returnstrue
orfalse
float
: Returns a random number between min (inclusive) and max (exclusive)number
: Returns a random integer between min (included) and max (excluded)number_inclusive
: Returns a random integer between min(included) and max (included)choice
: Returns a random item from the input arrproperty
: Returns a random property from an object
Usage
const random = require('npm-random')
// True or False
random.bool()
// Random float between 1 and 5
random.float(1, 5)
// Random number between 1 and 5
random.number(1, 5)
// Random number between 1 and including 5
random.number_inclusive(1, 5)
// Picks a random item in the array
random.choice([1,2,3,4,5])
// Picks a random property
random.property({a: 1, b:2, c: 3})