Introduction


This namespace provides fast and simple API to work with arrays


Functions



spa.array.insertLast(array, item)


Add item to the end of array.

Parameter Type Description
array array Array
item object Item to be added

spa.array.insertFirst(array, item)


Add item to the beginning of array.

Parameter Type Description
array array Array
item object Item to be added

spa.array.insertAt(array, index, item)


Insert item at certain index.

Parameter Type Description
array array Array
index integer Index
item object Item to be added

spa.array.removeLast(array)


Remove item from the end of array.

Parameter Type Description
array array Array

spa.array.removeFirst(array)


Remove item from the beginning of array.

Parameter Type Description
array array Array

spa.array.removeAt(array, index)


Remove item from certain index.

Parameter Type Description
array array Array
index integer Index

spa.array.searchGetBool(array, fn)


Search for item in array and return true or false.

Parameter Type Description
array array Array
fn function The search callback function. For each item in the array, this function will be passed the item and it's index: (item, index)

spa.array.searchGetIndex(array, fn)


Search for item in array and return the item's index.

Parameter Type Description
array array Array
fn function The search callback function. For each item in the array, this function will be passed the item and it's index: (item, index)

spa.array.searchGetItem(array, fn)


Search for item in array and return the item.

Parameter Type Description
array array Array
fn function The search callback function. For each item in the array, this function will be passed the item and it's index: (item, index)

spa.array.foreach(array, fn)


Loop throughout array from the beginning to the end.

Parameter Type Description
array array Array
fn function The callback function. For each item in the array, this function will be passed the item and it's index: (item, index). To break the loop, simply return false from this callback.

spa.array.foreachReversed(array, fn)


Loop throughout array in reversed order i.e. from the end to the beginning.

Parameter Type Description
array array Array
fn function The callback function. For each item in the array, this function will be passed the item and it's index: (item, index). To break the loop, simply return false from this callback.

spa.array.toString(array)


Return string representation of the array. For example: [1, 2, 'value3'].

Parameter Type Description
array array Array

spa.array.copy(array)


Return return a deep copy of array.

Parameter Type Description
array array Array