MCPcopy Create free account
hub / github.com/dailydotdev/apps / isDeepEqual

Function isDeepEqual

packages/shared/src/graphql/common.ts:67–104  ·  view source on GitHub ↗
(a: unknown, b: unknown)

Source from the content-addressed store, hash-verified

65}
66
67const isDeepEqual = (a: unknown, b: unknown): boolean => {
68 if (a === b) {
69 return true;
70 }
71
72 if (typeof a !== typeof b) {
73 return false;
74 }
75
76 if (a === null || b === null) {
77 return a === b;
78 }
79
80 if (Array.isArray(a) && Array.isArray(b)) {
81 if (a.length !== b.length) {
82 return false;
83 }
84 return a.every((item, i) => isDeepEqual(item, b[i]));
85 }
86
87 if (typeof a === 'object' && typeof b === 'object') {
88 const keysA = Object.keys(a);
89 const keysB = Object.keys(b);
90
91 if (keysA.length !== keysB.length) {
92 return false;
93 }
94
95 return keysA.every((key) =>
96 isDeepEqual(
97 (a as Record<string, unknown>)[key],
98 (b as Record<string, unknown>)[key],
99 ),
100 );
101 }
102
103 return false;
104};
105
106export const isQueryKeySame = (left: QueryKey, right: QueryKey): boolean => {
107 return isDeepEqual(left, right);

Callers 1

isQueryKeySameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected