Array

Type module

Sources

Items from Array can be imported/included and used via following ways.

/**
 * --------------------------------------------------------
 * Import via main package: core.ts
 * Access items like: am4core.array.myVariable
 *                    am4core.array.myFunction()
 * --------------------------------------------------------
 */
import * as am4core from "@amcharts/amcharts4";

/**
 * --------------------------------------------------------
 * Import via: Array.ts
 * Access items like: $array.myVariable
 *                    $array.myFunction()
 * --------------------------------------------------------
 */
import * as $array from "@amcharts/amcharts4/Array";

/**
 * --------------------------------------------------------
 * Include via "core.js"
 * Access items like: am4core.array.myVariable
 *                    am4core.array.myFunction()
 * --------------------------------------------------------
 */

Variables

Array does not have any variables.

Functions

any(

array: ArrayLike < A > ,
test: ( value: A) => boolean

)

#

Returns boolean

Calls test for each element in array.

If test returns true then it immediately returns true.

If test returns false for all of the elements in array then it returns false.

eachReverse(

array: ArrayLike < A > ,
fn: ( value: A, index: number) => void

)

#

Returns void

Iterates through all items in array in reverse order and calls fn function for each of them.

first(

array: Array < A >

)

#

Returns Optional < A >

Returns the first item of the array.

has(

array: ArrayLike < A > ,
element: A

)

#

Returns boolean

Returns true if element exists in array.

indexOf(

array: ArrayLike < A > ,
value: A

)

#

Returns number

Searches array for value.

Returns -1 if not found.

insert(

array: Array < A > ,
element: A,
index: number

)

#

Returns void

Inserts element into array at index.

Caps index to be between 0 and array.length

insertIndex(

array: Array < A > ,
index: number,
value: A

)

#

Returns void

Inserts a value into array at specific index.

keepIf(

array: Array < A > ,
keep: ( value: A) => boolean

)

#

Returns void

last(

array: Array < A >

)

#

Returns Optional < A >

Returns the last item of the array.

move(

array: Array < A > ,
element: A,
toIndex?: number

)

#

Returns void

Adds an element to array.

If array already contains and item like this, it is removed before adding it again.

Optionally toIndex can be specified to add element at specific index.

pushAll(

array: Array < A > ,
input: Array < A >

)

#

Returns void

Pushes all of the elements from input into array.

remove(

array: Array < A > ,
element: A

)

#

Returns boolean

Removes element from array.

If there are multiple copies of element, they are all removed.

removeIndex(

array: Array < A > ,
index: number

)

#

Returns void

Removes a value from array at specific index.

replace(

array: Array < A > ,
element: A,
index?: number

)

#

Returns void

Removes element from array (if it exists) and then inserts element at index.

If index is not provided, it will insert element at the end of array.

setIndex(

array: Array < A > ,
element: A,
index: number

)

#

Returns void

Removes all copies of element from array (if they exist) and then inserts element at index.

shiftLeft(

array: Array < A > ,
index: number

)

#

Returns void

Shifts an item at index towards beginning of the array.

shuffle(

array: Array < A >

)

#

Returns void

Iterates through all items in array and calls fn function for each of them.

slice(

array: ArrayLike < A > ,
start: number,
end: number

)

#

Returns Array < A >

Returns a copy of array which contains all the elements between start and end. (including start and excluding end)If end is not provided, it defaults to array.length.