stack

Home > @infiniteobjects/core-library-node > Random

Random class

Utilities to generate random values

Signature:

export declare class Random 

Remarks

Uses the [Mersenne Twister Algorithm](https://en.wikipedia.org/wiki/Mersenne_Twister) as the underlying engine for consistency between browser and node environments

Methods

Method Modifiers Description
boolean() static Produce a boolean with a 50% chance of it being true.
float(min, max, inclusive) static Produce a floating point number within the range
hex(length) static Produce a random string comprised of numbers or the characters abcdef of length length.
integer(min, max) static Produce an integer within the inclusive range [min, max].
pick(array) static Return a random value within the provided array
sample(population, sampleSize) static From the population array, produce an array with sampleSize elements that are randomly chosen without repeats.
string(length, pool) static Produce a random string of size ‘length’
uuid4() static Produce a Universally Unique Identifier Version 4.