arrayEx

aeq. arrayEx

new arrayEx(arr)

Source:

Array with some extensions that mimics modern JavaScript.

Parameters:
Name Type Description
arr Array

The array object to extend. If not supplied, an empty arrayEx will be returned.

Methods

(static) attr(attributeName, newValueopt) → {Any}

Source:
See:

Sets or gets an attribute value for all objects in the array. When getting a value, it only returns the valure from the first object.

Parameters:
Name Type Attributes Description
attributeName string

The name of the attribute to get or set.

newValue Any <optional>

The value to set. If not given, will only get the value of the first object.

Returns:

when getting, the value of the attribute. When setting, undefined.

Type
Any

(static) every(callback) → {boolean}

Source:

Loops through the elements in the array and returns true if callback returns true for all elements

Parameters:
Name Type Description
callback function

Function to execute for each element

Returns:

Whether the function returned true for ALL elements

Type
boolean

(static) filter(callback) → {aeq.arrayEx}

Source:

Runs callback on each element, and returns a new arrayEx of elements that trigger callback === true

Parameters:
Name Type Description
callback function

Function to execute for each element

Returns:

ArrayEx of filtered elements

Type
aeq.arrayEx

(static) find(callback, defopt) → {any}

Source:

Returns array element that triggers callback === true

Parameters:
Name Type Attributes Description
callback function

Function to execute for each element

def any <optional>

Default element to return if target be found

Returns:

Array element that triggered callback, or default

Type
any

(static) findIndex(callback) → {any}

Source:

Returns index of array element that triggers callback === true

Parameters:
Name Type Description
callback function

Function to execute for each element

Returns:

Index of array element that triggered callback, or -1

Type
any

(static) first() → {any}

Source:

Gets first element in array

Returns:

First element in array

Type
any

(static) forEach(callback)

Source:

Loops through the elements in the array and executes a function.

Parameters:
Name Type Description
callback forEachArrayCallback

Function to execute for each element

(static) groupBy(callback) → {object}

Source:

Groups an array by some condition as determined by each element

Parameters:
Name Type Description
callback function

Function to determine the key to group by

Returns:

An object whose keys are the result of callback and each value is an array of elements matching key

Type
object

(static) indexOf(searchElement, fromIndexopt) → {number}

Source:

Returns index of searchElement in an array, or -1 if not found

Parameters:
Name Type Attributes Default Description
searchElement any

Element to find in arrayEx

fromIndex number <optional>
0

Index to start searching from, or 0 if not passed

Returns:

-1 if element is not found, else index number

Type
number

(static) insertAt(insert, index)

Source:

Inserts an element into arrayEx at specified index

Parameters:
Name Type Description
insert any

Element to insert

index number

Index to insert element at

(static) map(callback) → {aeq.arrayEx}

Source:
See:

Creates a new array with the results of calling a provided function on every element in the calling array

Parameters:
Name Type Description
callback function

Function to execute for each element

Returns:

A new array with each element being the result of the callback function

Type
aeq.arrayEx

(static) some(callback) → {boolean}

Source:

Loops through the elements in the array and returns true if callback returns true for any element

Parameters:
Name Type Description
callback function

Function to execute for each element

Returns:

Whether the function returned true for any element

Type
boolean