namespace SAPO.Utility.Array
Utility functions to use with Arrays

Function Summary
Convert lists type to type array
Array each (Array arr, Function cb)
runs a functions through each of the elements of an array
Boolean inArray (Any value, Array arr)
checks if value exists in array
Array insert (Array arr, Number idx, Any value)
Insert value into the array on specified idx
Array intersect (Array arr1, Array arr2)
Returns an array containing every item that is shared between the two given arrays
Boolean|Number|Array keyValue (String value, Array arr, [Boolean param])
returns the associated key of an array value
Boolean|Array shuffle (Array arr)
returns the array shuffled, false if the param is not an array
Array|Boolean sortMulti (Array arr, String value)
sorts an array of object by an object property

Function Details

function convert

Array convert(Array arr)
Convert lists type to type array
Parameters:
arr

function each

Array each(Array arr, Function cb)
runs a functions through each of the elements of an array
Parameters:
arr
cb - the function recieves as arguments value, index and array

function inArray

Boolean inArray(Any value, Array arr)
checks if value exists in array
Parameters:
value
arr

function insert

Array insert(Array arr, Number idx, Any value)
Insert value into the array on specified idx
Parameters:
arr
idx
value

function intersect

Array intersect(Array arr1, Array arr2)
Returns an array containing every item that is shared between the two given arrays
Parameters:
arr1
arr2

function keyValue

Boolean|Number|Array keyValue(String value, Array arr, [Boolean param])
returns the associated key of an array value
Parameters:
value
arr
[param] to set if want the key of the first found value
Returns:
false if not exists | number if exists and 3rd input param is true | array if exists and 3rd input param is not set or it is !== true

function shuffle

Boolean|Array shuffle(Array arr)
returns the array shuffled, false if the param is not an array
Parameters:
arr

function sortMulti

Array|Boolean sortMulti(Array arr, String value)
sorts an array of object by an object property
Parameters:
arr array of objects to sort
value property to sort by