random
Static Method Summary
Static Public Methods | ||
public static |
bool(): * Return a random Boolean value |
|
public static |
Returns a boolean result based on limit |
|
public static |
Return an item from an array of arrays where the first index in each sub-array denotes the weight |
|
public static |
float(): * Returns a float in [0, 1) (uniform distribution) |
|
public static |
hex(len: *): * |
|
public static |
Must be called before any other methods can be called to initialize MersenneTwister |
|
public static |
Returns a random index from a list |
|
public static |
Returns a random key of a provided object |
|
public static |
Returns a float in [1, limit). |
|
public static |
Returns an integer in [0, limit) (uniform distribution) |
|
public static |
pick(obj: *): * Recursively iterate over array until non-array item identified If item is a function, evaluate it with no args |
|
public static |
pop(arr: *): * Removes and returns a random item from an array. |
|
public static |
Returns an integer in [start, limit) (uniform distribution) |
|
public static |
shuffle(arr: *) Returns arr shuffled |
|
public static |
shuffled(arr: *): * Returns a shuffled copy of arr |
|
public static |
Select an array containing a subset of 'list' |
|
public static |
use(obj: *): * |
|
public static |
Return a flattened list of weighted values [{w: 1, v: 'foo'}, {w: 1, v: 'bar'}] |
Static Public Methods
public static chance(limit: *): boolean source
Returns a boolean result based on limit
Params:
Name | Type | Attribute | Description |
limit | * |
public static choose(list: Array, flat: Boolean): * source
Return an item from an array of arrays where the first index in each sub-array denotes the weight
Return:
* |
public static init(seed: number) source
Must be called before any other methods can be called to initialize MersenneTwister
Params:
Name | Type | Attribute | Description |
seed | number |
|
Value to initialize MersenneTwister |
public static item(list: Array): * source
Returns a random index from a list
Params:
Name | Type | Attribute | Description |
list | Array |
Return:
* |
public static key(obj: Object): * source
Returns a random key of a provided object
Params:
Name | Type | Attribute | Description |
obj | Object |
Return:
* |
public static ludOneTo(limit: number): * source
Returns a float in [1, limit). The logarithm has uniform distribution.
Params:
Name | Type | Attribute | Description |
limit | number |
Return:
* |
public static number(limit: number): * source
Returns an integer in [0, limit) (uniform distribution)
Params:
Name | Type | Attribute | Description |
limit | number |
Return:
* |
public static pick(obj: *): * source
Recursively iterate over array until non-array item identified If item is a function, evaluate it with no args
Params:
Name | Type | Attribute | Description |
obj | * |
Return:
* |
public static pop(arr: *): * source
Removes and returns a random item from an array.
Params:
Name | Type | Attribute | Description |
arr | * |
Return:
* |
public static range(start: number, limit: number): * source
Returns an integer in [start, limit) (uniform distribution)
Return:
* |
public static shuffle(arr: *) source
Returns arr shuffled
Params:
Name | Type | Attribute | Description |
arr | * |
public static shuffled(arr: *): * source
Returns a shuffled copy of arr
Params:
Name | Type | Attribute | Description |
arr | * |
Return:
* |