@naverpay/vanilla-store
Version:
  
27 lines (26 loc) • 745 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
function is(x, y) {
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
}
const objectIs = typeof Object.is === "function" ? Object.is : is;
function shallowEqual(a, b) {
if (objectIs(a, b)) {
return true;
}
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
return false;
}
const keysA = Object.keys(a);
const keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
for (const key of keysA) {
if (!Object.prototype.hasOwnProperty.call(b, key) || a[key] !== b[key]) {
return false;
}
}
return true;
}
exports.shallowEqual = shallowEqual;