#BM-Random
This module provides some useful functions that uses random.
##Installation
$ npm install bm-random
##API:
####fromArray
.fromArray(array: array<any>): any
Returns a random element of array
or undefined
if array
is empty
####fromRange
.fromRange(min: number, max: number, step: number = 1): number
.fromRange(options: { min: number, max: number, step: number = 1 })
Preconditions:
max
should be greater than or equal to min
step
should be positive- the difference between
max
and min
should be a multiple of step
Returns a random number in [min
; max
] whose distance from min
is a multiple of step
####neutral
.neutral(n: number): number
Preconditions:
n
should be a neutral number
Returns a neutral number that is lesser than n