bm-random
v1.0.0
Published
A collection of some useful functions that use random
Downloads
7
Readme
#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 tomin
step
should be positive- the difference between
max
andmin
should be a multiple ofstep
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