Arrays BinarySearchType firstGreater Default value: 1
Class LinkedList Converts an array to a linked list data structure.
constructor (items: Array<T>): LinkedList<T> Name Type Default Description items
Array<T>
Method .delete (node: LinkedListItem<T>): undefined Name Type Default Description node
LinkedListItem<T>
Method .traverse (): Generator<LinkedListItem<T>, void, unknown> Type alias BinarySearchArray : Array<{item: T, val: number}> binaryIndexOf (array: BinarySearchArray<T>, item: T, value: number): number Name Type Default Description array
BinarySearchArray<T> item
T value
number
binarySearch (array: BinarySearchArray<T>, value: number, type: BinarySearchType): number Performs binary search on array
, finding elements with value value
based on the type
criteria. The array is assumed to be sorted (small to large) in oder of the value returned by the getValue()
method.
Name Type Default Description array
BinarySearchArray<T> value
number type
BinarySearchType
chunk (array: Array<T>, n: number): Array<Array<T>> Breaks an array into chunks of size at most n.
Name Type Default Description array
Array<T> n
number
cumulative (array: Array<number>): Array<number> Creates a cumulative array by adding its elements.
Name Type Default Description array
Array<number>
difference (a1: Array<T>, a2: Array<T>): Array<T> Returns all elements that are only in one of a1 and a2.
Name Type Default Description a1
Array<T> a2
Array<T>
flatten (array: Nested<T>): Array<T> Flattens a nested array into a single list.
Name Type Default Description array
Nested<T>
intersect (a1: Array<T>, a2: Array<T>): Array<T> Returns all elements that are in both a1 and a2.
Name Type Default Description a1
Array<T> a2
Array<T>
join (arrays: Array<Array<T>>): Array<T> Join multiple Arrays
Name Type Default Description arrays
Array<Array<T>>
last (array: Array<T>, i: number): T Returns the last item in an array, or the ith item from the end.
Name Type Default Description array
Array<T> i
number 0
list (a: number, b: number, step: number): Array<number> Creates an array of numbers from 0 to a, or from a to b.
Name Type Default Description a
number b
number step
number 1
loop (array: Array<T>): (): T Returns a function that can be called repeatedly, and returns items of the array, continuously looping
Name Type Default Description array
Array<T>
repeat (value: T, n: number): Array<T> Creates an array of size n
, containing value
at every entry.
Name Type Default Description value
T n
number
repeat2D (value: T, x: number, y: number): Array<Array<T>> Creates a 2D array of size x
by y
, containing value
at every entry.
Name Type Default Description value
T x
number y
number
rotate (array: Array<T>, offset: number): Array<T> Rotates the elements of an array by offset.
Name Type Default Description array
Array<T> offset
number 1
sortBy (array: Array<T>, fn: (x: T): S, reverse: boolean): Array<T> Sorts an array by the return value when evaluating a given function.
Name Type Default Description array
Array<T> fn
(x: T): S reverse
boolean false
tabulate (fn: (i: number): T, n: number): Array<T> Creates an array of size n
, with the result of fn(i)
at position i.
Name Type Default Description fn
(i: number): T n
number
tabulate2D (fn: (i: number, j: number): T, x: number, y: number): Array<Array<T>> Creates a 2D array of size x
by y
, with the result of fn(i, j)
at position (i, j).
Name Type Default Description fn
(i: number, j: number): T x
number y
number
toCSV (data: Array<Array<unknown>>): string Converts a 2D array to CSV data.
Name Type Default Description data
Array<Array<unknown>>
total (array: Array<number>): number Finds the sum of all elements in an numeric array.
Name Type Default Description array
Array<number>
unique (array: Array<T>): Array<T> Filters all duplicate elements from an array.
Name Type Default Description array
Array<T>