mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
15 lines
550 B
JavaScript
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
|