mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 07:36:42 +08:00
5e9ad634b7
now we can debug indexeddb performance by devtool 
35 lines
703 B
TypeScript
35 lines
703 B
TypeScript
// credit: https://github.com/facebook/fbjs/blob/main/packages/fbjs/src/core/shallowEqual.js
|
|
export function shallowEqual(objA: any, objB: any) {
|
|
if (Object.is(objA, objB)) {
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
typeof objA !== 'object' ||
|
|
objA === null ||
|
|
typeof objB !== 'object' ||
|
|
objB === null
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
const keysA = Object.keys(objA);
|
|
const keysB = Object.keys(objB);
|
|
|
|
if (keysA.length !== keysB.length) {
|
|
return false;
|
|
}
|
|
|
|
// Test for A's keys different from B.
|
|
for (const key of keysA) {
|
|
if (
|
|
!Object.prototype.hasOwnProperty.call(objB, key) ||
|
|
!Object.is(objA[key], objB[key])
|
|
) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|