API/libsapojs/SAPO/Utility/Array

[Elements] are optional

Class SAPO.Utility.Array


class SAPO.Utility.Array
Utility functions to use with Arrays
Defined in Utility/Array/0.1/lib.js

Function Summary
Array each (Array arr, Function callBack)
runs a functions trou each of the elements of an array
Boolean inArray (Any value, Array array)
Check if value exists in array
Boolean|Number|Array keyValue (String value, Array array, [Boolean param])
returns the associated key of an array value
Boolean|Array shuffle (Array array)
returns the array shuffled
Array|Boolean sortMulti (String value, Array array)
Sort an array of object by an object property

Function Details

function each

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

function inArray

Boolean inArray(Any value, Array array)
Check if value exists in array
Parameters:
value
array
Returns:
true if the element exists

function keyValue

Boolean|Number|Array keyValue(String value, Array array, [Boolean param])
returns the associated key of an array value
Parameters:
value
array
[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 array)
returns the array shuffled
Parameters:
array
Returns:
false if the param is not an array or array shuffled

function sortMulti

Array|Boolean sortMulti(String value, Array array)
Sort an array of object by an object property
Parameters:
value property to sort by
array - array of objects to sort
Returns:
the sorted array or false if not an array