Variable ArraysConst

Arrays: {
    empty: (<T>() => readonly T[]);
    compare(x, y) => number;
    equal(x, y) => boolean;
    equivalent(x, y, epsilon?) => boolean;
    hash(x) => number;
    inserted<T_1>(newElement, oldArray) => readonly T_1[];
    removed<T_2>(oldElement, oldArray) => readonly T_2[];
}

Utilities for immutably updating, comparing, and hashing arrays.

Type declaration

  • empty: (<T>() => readonly T[])
      • <T>(): readonly T[]
      • Type Parameters

        • T

        Returns readonly T[]

  • compare:function
    • Returns the relative order of x with respect to y. Returns -1 if the elements of array x order lexicographically before the elements of array y; returns 1 if the elements of array x order lexicographically after the elements of array y; and returns 0 if x and y are equal arrays. If either x or y is null or undefined, then arrays order before null, and null orders before undefined.

      Parameters

      • x: ArrayLike<unknown>
      • y: ArrayLike<unknown>

      Returns number

  • equal:function
    • Returns true if x and y are structurally equal arrays; otherwise returns x === y if either x or y is not an array.

      Parameters

      • x: ArrayLike<unknown>
      • y: ArrayLike<unknown>

      Returns boolean

  • equivalent:function
    • Returns true if x and y are structurally [[Equivalent.equivalentTo equivalent]] arrays; otherwise returns x === y if either x or y is not an array.

      Parameters

      • x: ArrayLike<unknown>
      • y: ArrayLike<unknown>
      • Optional epsilon: number

      Returns boolean

  • hash:function
    • Returns a 32-bit hash value for the elements of array x, if defined; otherwise returns 0 or 1 if x is undefined or null, respectively.

      Parameters

      • x: ArrayLike<unknown>

      Returns number

  • inserted:function
    • Returns a copy of an array with the given element inserted, if the element is not already present in the array; otherwise returns the input array if it already contains the specified element.

      Type Parameters

      • T_1

      Parameters

      • newElement: T_1
      • oldArray: readonly T_1[]

      Returns readonly T_1[]

  • removed:function
    • Returns a copy of an array with the given element removed; returns the input array if it does not contain the specified element.

      Type Parameters

      • T_2

      Parameters

      • oldElement: T_2
      • oldArray: readonly T_2[]

      Returns readonly T_2[]

Generated using TypeDoc