Methods
(static) arrayAssign(array, props)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array of Objects |
props |
Object | Properties to add to each object in array |
(static) arrayCreate(count, callback)
- Description:
Creates a new array of X length and fills the array using callback
- Source:
Parameters:
Name | Type | Description |
---|---|---|
count |
Number | Number of elements to create |
callback |
Funtion | Callback to template the array element (passed only index) |
Returns:
Array
(static) arrayHas(array, required) → {Boolean}
- Description:
Tests an array agains another array, returns true if the array has all items in the required array
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to test on |
required |
Array | Elements that should be present in the array |
Returns:
- Type
- Boolean
(static) createEmptyMatrix(columnCount, rowCount, value) → {Array.Array}
Parameters:
Name | Type | Description |
---|---|---|
columnCount |
Number | |
rowCount |
Number | |
value |
* | Value to set, default is null |
Returns:
Matrix (array of arrays)
- Type
- Array.Array
(static) filterInPlace(array, test) → {Array}
- Description:
Filter Array In Place
- Will not copy array, mutates the array passed (instead of copy [ie. Array.filter()])
- Note, removes items in reverse order (end-to-start of array), test will be called on last item first and so on
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | The array to filter items from |
test |
function | A function to filter elements based on a truthy/falsy condition |
Returns:
The original array
- Type
- Array
(static) getFirstLast(array, index) → {Object}
- Description:
Test whether an index in an array is first or last
- Returns an object with both first/last keys (true/false)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to check index against (uses .length) |
index |
Number | Index to get info for |
Returns:
{ first: {Boolean}, last: {Boolean} }
- Type
- Object
(static) joinForSentence(arr) → {String}
- Description:
Joins an array into sentence form
- IE ["2013", "2015", "2020"] --> "2013, 2015 and 2020"
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array.<String, Number> | Array to join |
Returns:
- Type
- String
(static) offsetFindIndexOf(array, start, callback)
- Description:
Searches array for first item matching test, beginning at a start index but searching the entire array
- Source:
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to search |
start |
Number | The index in the array to start the search from |
callback |
function | A test function that is passed array item and index |
(static) removeArrayElement(array, element)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to remove element from |
element |
Element | Array element to remove |
(static) removeDuplicates(array) → {Array}
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | Array to remove duplicates from |
Returns:
New array with duplicates removed
- Type
- Array