Array
Type module
Sources
Items from Array can be imported/included and used via following ways.
/** * Import via main package * Access items like: am4core.array.myVariable */import * as am4core from "@amcharts/amcharts4";
/** * Import via: Array.ts * Access items like: $array.myVariable */import * as $array from "@amcharts/amcharts4/Array";/** * Include via "core.js" * Access items like: am4core.array.myVariable */Variables
Array does not have any variables.
Functions
any(array:ArrayLike<A>,
test: (value:A) =>boolean)Returns
booleanCalls
testfor each element inarray.If
testreturnstruethen it immediately returnstrue.If
testreturnsfalsefor all of the elements inarraythen it returnsfalse.eachReverse(array:ArrayLike<A>,
fn: (value:A, index:number) =>void)Returns
voidIterates through all items in array in reverse order and calls
fnfunction 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
booleanReturns
trueifelementexists inarray.indexOf(array:ArrayLike<A>,
value:A)Returns
numberSearches
arrayforvalue.Returns -1 if not found.
insert(array:Array<A>,
element:A,
index:number)Returns
voidInserts
elementintoarrayatindex.Caps
indexto be between0andarray.lengthinsertIndex(array:Array<A>,
index:number,
value:A)Returns
voidInserts a value into array at specific index.
keepIf(array:Array<A>,
keep: (value:A) =>boolean)Returns
voidlast(array:Array<A>)Returns
Optional<A>Returns the last item of the array.
move(array:Array<A>,
element:A,
toIndex?:number)Returns
voidAdds an
elementtoarray.If array already contains and item like this, it is removed before adding it again.
Optionally
toIndexcan be specified to add element at specific index.pushAll(array:Array<A>,
input:Array<A>)Returns
voidPushes all of the elements from
inputintoarray.remove(array:Array<A>,
element:A)Returns
booleanRemoves
elementfromarray.If there are multiple copies of
element, they are all removed.removeIndex(array:Array<A>,
index:number)Returns
voidRemoves a value from array at specific index.
replace(array:Array<A>,
element:A,
index?:number)Returns
voidRemoves
elementfromarray(if it exists) and then insertselementatindex.If
indexis not provided, it will insertelementat the end ofarray.setIndex(array:Array<A>,
element:A,
index:number)Returns
voidRemoves all copies of
elementfromarray(if they exist) and then insertselementatindex.shiftLeft(array:Array<A>,
index:number)Returns
voidShifts an item at
indextowards beginning of the array.shuffle(array:Array<A>)Returns
voidIterates through all items in array and calls
fnfunction for each of them.slice(array:ArrayLike<A>,
start:number,
end:number)Returns
Array<A>Returns a copy of
arraywhich contains all the elements betweenstartandend. (includingstartand excludingend)Ifendis not provided, it defaults toarray.length.