Array
Type module
Sources
Items from Array can be imported/included and used via following ways.
/** * Import via main package * Access items like: am5.array.myVariable */import * as am5 from "@amcharts/amcharts5";
/** * Import via: Array.ts * Access items like: $array.myVariable */import * as $array from "@amcharts/amcharts5/Array";/** * Include via "index.js" * Access items like: am5.array.myVariable */Variables
Array does not have any variables.
Functions
add(array:Array,
element:A,
index?:undefined|number)Returns
voidAdds
countunits of time todate. Changesdateitself and returns it.any(array:ArrayLike,
test: (value:A) =>boolean)Returns
booleanReturns
trueiftestreturnstruefor any item ofarray, stopping at the first one.copy(array:ArrayLike)Returns
ArrayReturns a shallow copy of the object.
Returns a copy of the
Dateobject.Returns a copy of the
Dateobject.each(array:ArrayLike,
fn: (value:A, index:number) =>void)Returns
voidIterates through all properties of the object calling
ffor each of them.eachContinue(array:ArrayLike,
fn: (value:A, index:number) =>boolean)Returns
voidIterates through all properties of the object calling
fnfor each of them.If return value of the function evaluates to
falsefurther iteration is cancelled.eachReverse(array:ArrayLike,
fn: (value:A, index:number) =>void)Returns
voidIterates through all items in array in reverse order and calls
fnfunction for each of them.find(array:ArrayLike,
matches: (value:A, index:number) =>boolean)Returns
A|undefinedReturns the first item for which
matchesreturnstrue, orundefinedif there is none.findIndex(array:ArrayLike,
matches: (value:A, index:number) =>boolean)Returns
numberSearches the array using custom function and returns index of the item if found.
Will call
matchesfunction on all items of the array. If return value evaluates totrue, index is returned.Otherwise returns -1.
findIndexReverse(array:ArrayLike,
matches: (value:A, index:number) =>boolean)Returns
numberThis is the same as
findIndexexcept it searches from right to left.findMap(array:ArrayLike,
matches: (value:A, index:number) =>B|undefined)Returns
B|undefinedCalls
matcheson each item and returns the first value it returns that is notundefined, orundefinedif there is none.findReverse(array:ArrayLike,
matches: (value:A, index:number) =>boolean)Returns
A|undefinedThis is the same as
findexcept it searches from right to left.first(array:Array)Returns
OptionalReturns the first item of the array.
has(array:ArrayLike,
element:A)Returns
booleanReturns
trueifelementexists inarray.indexOf(array:ArrayLike,
value:A)Returns
numberSearches
arrayforvalue.Returns -1 if not found.
insert(array:Array,
element:A,
index:number)Returns
voidInserts
elementintoarrayatindex, clamped to0toarray.length.insertIndex(array:Array,
index:number,
value:A)Returns
voidInserts a value into array at specific index.
keepIf(array:Array,
keep: (value:A) =>boolean)Returns
voidRemoves in place every item for which
keepreturnsfalse.last(array:Array)Returns
OptionalReturns the last item of the array.
map(array:ArrayLike,
fn: (value:A, index:number) =>B)Returns
ArrayCalls
fnfunction for every member of array and returns a new array out of all outputs.move(array:Array,
element:A,
toIndex?:undefined|number)Returns
voidAdds
elementtoarrayattoIndex, or at the end iftoIndexis not set. Ifarrayalready containselement, its first copy is removed first.pushAll(array:Array,
input:Array)Returns
voidPushes all of the elements from
inputintoarray.pushOne(array:Array,
element:A)Returns
voidPushes
elementintoarrayif it doesn't already exist.remove(array:Array,
element:A)Returns
booleanRemoves
elementfromarray.If there are multiple copies of
element, they are all removed.removeFirst(array:Array,
element:A)Returns
booleanRemoves the first copy of
elementfromarray.removeIndex(array:Array,
index:number)Returns
voidRemoves a value from array at specific index.
replace(array:Array,
element:A,
index?:undefined|number)Returns
voidRemoves the first copy of
elementfromarray(if it exists) and then insertselementatindex.If
indexis not provided, it will insertelementat the end ofarray.setIndex(array:Array,
element:A,
index:number)Returns
voidRemoves all copies of
elementfromarray(if they exist) and then insertselementatindex.shiftLeft(array:Array,
index:number)Returns
voidRemoves the first
indexitems ofarrayin place, moving the rest to the beginning.shuffle(array:Array)Returns
voidShuffles
arrayin place into a random order.slice(array:ArrayLike,
start:number,
end:number)Returns
ArrayReturns a copy of
arraywhich contains all the elements betweenstartandend. (includingstartand excludingend)Ifendis not provided, it defaults toarray.length.toArray(input:Array|A)Returns
ArrayWraps
inputin an array, if it isn't already an array.