This library supports map/set comparison operations including .equals
: https://github.com/adamhamlin/deep-equality-data-structures?tab=readme-ov-file#comparable-interface
const map1 = new DeepMap([[1, "dog"], [2, "cat"]]);
const map2 = new DeepMap([[2, "cat"], [1, "dog"]]);
const map3 = new DeepMap([[1, "dog"], [2, "laser-cat"]]);
map1.equals(map2); // true
map1.equals(map3); // false
It also uses deep/structural equality for keys and values.
Full disclosure: I am the library author