ts-data-forge
    Preparing search index...
    • Checks if two IMap instances are structurally equal.

      Two IMaps are considered equal if they have the same size and contain exactly the same key-value pairs. The order of entries does not matter for equality comparison. Values are compared using JavaScript's === operator.

      Performance: O(n) where n is the size of the smaller map.

      Type Parameters

      • K extends Primitive

        The type of the keys.

      • V

        The type of the values.

      Parameters

      • a: IMap<K, V>

        The first IMap instance to compare.

      • b: IMap<K, V>

        The second IMap instance to compare.

      Returns boolean

      true if the maps contain exactly the same key-value pairs, false otherwise.

      const first = IMap.create<'a' | 'b', number>([
      ['a', 1],
      ['b', 2],
      ]);

      const second = IMap.create<'a' | 'b', number>([
      ['b', 2],
      ['a', 1],
      ]);

      const third = IMap.create<'a' | 'b', number>([
      ['a', 1],
      ['b', 3],
      ]);

      assert.ok(IMap.equal(first, second));
      assert.notOk(IMap.equal(first, third));