utils.array

namespace array

a collection of array utility functions

Summary


Public Methods


random array.js:28
random(arr: Array<number | string | Object>) → {any}

return a random array element

// Select a random array element
let arr = [ "foo", "bar", "baz" ];
console.log(me.utils.array.random(arr));
Parameters:
Name Type Description
arr Array<number | string | Object>

array to pick a element

Returns:
Type Description
any

random member of array

remove array.js:8
remove(arr: Array<number | string | Object>, obj: object) → {Array<number | string | Object>}

Remove the specified object from the given Array

Parameters:
Name Type Description
arr Array<number | string | Object>

array from which to remove an object

obj object

to be removed

Returns:
Type Description
Array<number | string | Object>

the modified Array let arr = [ "foo", "bar", "baz" ]; // remove "foo" from the array me.utils.array.remove(arr, "foo");

weightedRandom array.js:44
weightedRandom(arr: Array<number | string | Object>) → {any}

return a weighted random array element, favoring the earlier entries

Parameters:
Name Type Description
arr Array<number | string | Object>

array to pick a element

Returns:
Type Description
any

random member of array


Powered by webdoc!