@a11d/equals
Version:
A value equality utility library.
22 lines (21 loc) • 492 B
JavaScript
import { equals } from './symbol.js';
Map.prototype[equals] = function (other) {
if (this === other) {
return true;
}
if (!(other instanceof Map)) {
return false;
}
if (this.size !== other.size) {
return false;
}
for (const [key, value] of this) {
if (!other.has(key)) {
return false;
}
if (Object[equals](value, other.get(key)) === false) {
return false;
}
}
return true;
};