Files
v10/dist/object/shallow-equal.js

15 lines
550 B
JavaScript

//#region src/object/shallow-equal.ts
const hasOwn = Object.prototype.hasOwnProperty;
function shallowEqual(a, b) {
if (Object.is(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 (!hasOwn.call(b, key) || !Object.is(a[key], b[key])) return false;
return true;
}
//#endregion
export { shallowEqual };
//# sourceMappingURL=shallow-equal.js.map