@jonahsnider/util

    Function identical

    • Check if 2 arrays have the same elements in the same order. Strict equality (===) is used to compare elements.

      Time complexity: O(n)

      Space complexity: O(1)

      Type Parameters

      • V

      Parameters

      • a: readonly V[]

        First array to compare

      • b: readonly V[]

        Second array to compare

      Returns boolean

      true if a and b have the same elements in the same order, false otherwise

      const a = [1, 2, 3];
      const b = [1, 2, 3];

      identical(a, b); // true
    • Check if 2 Sets have the same elements. Strict equality (===) is used to compare elements.

      Time complexity: O(n)

      Space complexity: O(1)

      Type Parameters

      • V

      Parameters

      • a: ReadonlySet<V>

        First Set to compare

      • b: ReadonlySet<V>

        Second Set to compare

      Returns boolean

      true if a and b have the same elements, false otherwise

      const a = new Set([1, 2, 3]);
      const b = new Set([3, 2, 1]);

      identical(a, b); // true
    • Check if 2 Maps have the same key-value pairs. Strict equality (===) is used to compare values.

      Time complexity: O(n)

      Space complexity: O(1)

      Type Parameters

      • K
      • V

      Parameters

      • a: ReadonlyMap<K, V>

        First Map to compare

      • b: ReadonlyMap<K, V>

        Second Map to compare

      Returns boolean

      true if a and b have the key-value pairs, false otherwise

      const a = new Map([['a', 1]]);
      const b = new Map([['a', 1]]);

      identical(a, b); // true
    MMNEPVFCICPMFPCPTTAAATR