• Public
  • Public/Protected
  • All

Namespace ArrayUtils



HeadAndChildrenImpl: { children: any; head: any } = ...

Type declaration

TailImpl: { tail: any } = ...

Type declaration


  • asTail<T>(array: T[]): Tail<T>
  • binarySearch2(length: number, compareToKey: ((index: number) => number)): number
  • Performs a binary search algorithm over a sorted collection. Useful for cases when we need to perform a binary search over something that isn't actually an array, and converting data to an array would defeat the use of binary search in the first place.


    • length: number

      The collection length.

    • compareToKey: ((index: number) => number)

      A function that takes an index of an element in the collection and returns zero if the value at this index is equal to the search key, a negative number if the value precedes the search key in the sorting order, or a positive number if the search key precedes the value.

        • (index: number): number
        • Parameters

          • index: number

          Returns number

    Returns number

    A non-negative index of an element, if found. If not found, the result is -(n+1) (or ~n, using bitwise notation), where n is the index where the key should be inserted to maintain the sorting order.

  • coalesce<T>(array: readonly (undefined | null | T)[]): T[]
  • partition<T>(array: T[], filter: ((e: T, idx: number, arr: T[]) => undefined | boolean)): [T[], T[]]
  • Type Parameters

    • T


    • array: T[]
    • filter: ((e: T, idx: number, arr: T[]) => undefined | boolean)
        • (e: T, idx: number, arr: T[]): undefined | boolean
        • Parameters

          • e: T
          • idx: number
          • arr: T[]

          Returns undefined | boolean

    Returns [T[], T[]]