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: am5.array.myVariable
 *                    am5.array.myFunction()
 * --------------------------------------------------------
 */
import * as am5 from "@amcharts/amcharts5";

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

/**
 * --------------------------------------------------------
 * Include via "index.js"
 * E.g.: "https://cdn.amcharts.com/lib/5/index.js"
 * Access items like: am5.array.myVariable
 *                    am5.array.myFunction()
 * --------------------------------------------------------
 */

Variables

Array does not have any variables.

Functions

add(

array: Array,
element: A,
index?: undefined | number

)

#

Returns void

Adds count units of time to date. Changes date itself and returns it.

any(

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

)

#

Returns boolean

Returns true if test returns true for any item of array, stopping at the first one.

copy(

array: ArrayLike

)

#

Returns Array

Returns a shallow copy of the object.

Returns a copy of the Date object.

Returns a copy of the Date object.

each(

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

)

#

Returns void

Iterates through all properties of the object calling f for each of them.

eachContinue(

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

)

#

Returns void

Iterates through all properties of the object calling fn for each of them.

If return value of the function evaluates to false further iteration is cancelled.

eachReverse(

array: ArrayLike,
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.

find(

array: ArrayLike,
matches: ( value: A, index: number) => boolean

)

#

Returns A | undefined

Returns the first item for which matches returns true, or undefined if there is none.

findIndex(

array: ArrayLike,
matches: ( value: A, index: number) => boolean

)

#

Returns number

Searches the array using custom function and returns index of the item if found.

Will call matches function on all items of the array. If return value evaluates to true, index is returned.

Otherwise returns -1.

findIndexReverse(

array: ArrayLike,
matches: ( value: A, index: number) => boolean

)

#

Returns number

This is the same as findIndex except it searches from right to left.

findMap(

array: ArrayLike,
matches: ( value: A, index: number) => B | undefined

)

#

Returns B | undefined

Calls matches on each item and returns the first value it returns that is not undefined, or undefined if there is none.

findReverse(

array: ArrayLike,
matches: ( value: A, index: number) => boolean

)

#

Returns A | undefined

This is the same as find except it searches from right to left.

first(

array: Array

)

#

Returns Optional

Returns the first item of the array.

has(

array: ArrayLike,
element: A

)

#

Returns boolean

Returns true if element exists in array.

indexOf(

array: ArrayLike,
value: A

)

#

Returns number

Searches array for value.

Returns -1 if not found.

insert(

array: Array,
element: A,
index: number

)

#

Returns void

Inserts element into array at index, clamped to 0 to array.length.

insertIndex(

array: Array,
index: number,
value: A

)

#

Returns void

Inserts a value into array at specific index.

keepIf(

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

)

#

Returns void

Removes in place every item for which keep returns false.

last(

array: Array

)

#

Returns Optional

Returns the last item of the array.

map(

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

)

#

Returns Array

Calls fn function for every member of array and returns a new array out of all outputs.

move(

array: Array,
element: A,
toIndex?: undefined | number

)

#

Returns void

Adds element to array at toIndex, or at the end if toIndex is not set. If array already contains element, its first copy is removed first.

pushAll(

array: Array,
input: Array

)

#

Returns void

Pushes all of the elements from input into array.

pushOne(

array: Array,
element: A

)

#

Returns void

Pushes element into array if it doesn't already exist.

remove(

array: Array,
element: A

)

#

Returns boolean

Removes element from array.

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

removeFirst(

array: Array,
element: A

)

#

Returns boolean

Removes the first copy of element from array.

removeIndex(

array: Array,
index: number

)

#

Returns void

Removes a value from array at specific index.

replace(

array: Array,
element: A,
index?: undefined | number

)

#

Returns void

Removes the first copy of 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,
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,
index: number

)

#

Returns void

Removes the first index items of array in place, moving the rest to the beginning.

shuffle(

array: Array

)

#

Returns void

Shuffles array in place into a random order.

slice(

array: ArrayLike,
start: number,
end: number

)

#

Returns Array

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.

toArray(

input: Array | A

)

#

Returns Array

Wraps input in an array, if it isn't already an array.