Module: alfresco/core/ArrayUtils

alfresco/core/ArrayUtils

A utility class for working with arrays. The functions in this module are based on those originally found in the YUI based alfresco.js file.
Author:
  • Dave Draper
License:
Source:

Methods

arrayContains(arr, el) → {boolean}

Check if an array contains an object
Parameters:
Name Type Description
arr array Array to convert to object
el object The element to be searched for in the array
Source:
Returns:
True if arr contains el
Type
boolean

arrayIndex(arr, value, attr) → {integer}

Finds the index of an object in an array
Parameters:
Name Type Description
arr array Array to search in
value object The element to find the index for in the array
attr string (Optional) If provided, valu ewill be compared to an attribute inside the object, instead of compared to the object itself.
Source:
Returns:
-1 if not found, other wise the index
Type
integer

arrayRemove(arr, el) → {boolean}

Removes element el from array arr
Parameters:
Name Type Description
arr array Array to remove el from
el object The element to be removed
Source:
Returns:
The array now without the element
Type
boolean

findInArray(arr, el) → {int|null}

Returns the index of an object in an array
Parameters:
Name Type Description
arr array Array to search through
el object The element to be searched for in the array
Source:
Returns:
element index within array (or null if not found).
Type
int | null