1.0.2 • Published 8 years ago

npm-random v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

npm-random

A collection of helper functions to make randomness easier

Install

npm install npm-random

Functions

  • bool: Returns true or false
  • 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 arr
  • property: 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})

NPM

https://www.npmjs.com/package/npm-random

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago