@util.js/arrays
v0.41.3
Published
JavaScript utility methods for arrays
Downloads
14
Maintainers
Readme
@util.js/arrays
JavaScript utility methods for arrays
@util.js/arrays is part of Util.js.
This class contains all the non-instance methods of Array in addition to:
Arrays API
Kind: global class
Access: public
- Arrays
- .from(arrayLike, [mapFn], [thisArg]) ⇒ Array
- .isArray(obj) ⇒ boolean
- .of(...elementN) ⇒ Array
- .shuffle(array) ⇒ Array
arrays.from(arrayLike, [mapFn], [thisArg]) ⇒ Array
Creates a new, shallow-copied Array instance from an array-like or iterable object.
See MDN's documentation about from.
Kind: instance method of Arrays
Returns: Array - A new Array instance
Access: public
| Param | Type | Description | | --------- | --------------------- | ------------------------------------------------------- | | arrayLike | | An array-like or iterable object to convert to an array | | [mapFn] | function | Map function to call on every element of the array | | [thisArg] | Object | Value to use as this when executing mapFn |
arrays.isArray(obj) ⇒ boolean
Determines whether the passed value is an Array.
See MDN's documentation about isArray.
Kind: instance method of Arrays
Returns: boolean - true if the object is an Array or false otherwise
Access: public
| Param | Type | Description | | ----- | --------------- | ------------------------ | | obj | * | The object to be checked |
arrays.of(...elementN) ⇒ Array
Creates a new Array instance with a variable number of arguments, regardless of number or type of the arguments
See MDN's documentation about of.
Kind: instance method of Arrays
Returns: Array - A new Array instance
Access: public
| Param | Type | Description | | ----------- | --------------- | ------------------------------------- | | ...elementN | * | Elements of which to create the array |
arrays.shuffle(array) ⇒ Array
Shuffles the elements of the specified array.
See knuth-shuffle.
Kind: instance method of Arrays
Returns: Array - A new Array instance
Access: public
| Param | Type | Description | | ----- | ------------------ | -------------------- | | array | Array | The array to shuffle |