MCPcopy Create free account
hub / github.com/TanStack/query / partialMatchKey

Function partialMatchKey

packages/query-core/src/utils.ts:249–278  ·  view source on GitHub ↗
(a: any, b: any)

Source from the content-addressed store, hash-verified

247 */
248export function partialMatchKey(a: QueryKey, b: QueryKey): boolean
249export function partialMatchKey(a: any, b: any): boolean {
250 if (a === b) {
251 return true
252 }
253
254 if (typeof a !== typeof b) {
255 return false
256 }
257
258 if (a && b && typeof a === 'object' && typeof b === 'object') {
259 if (Array.isArray(a) && Array.isArray(b)) {
260 for (let i = 0; i < b.length; i++) {
261 if (!partialMatchKey(a[i], b[i])) {
262 return false
263 }
264 }
265 return true
266 }
267
268 const bKeys = Object.keys(b)
269 for (const key of bKeys) {
270 if (!partialMatchKey(a[key], b[key])) {
271 return false
272 }
273 }
274 return true
275 }
276
277 return false
278}
279
280const hasOwn = Object.prototype.hasOwnProperty
281

Callers 7

restoreQueriesFunction · 0.90
removeQueriesFunction · 0.90
getQueryDefaultsMethod · 0.90
getMutationDefaultsMethod · 0.90
utils.test.tsxFile · 0.90
matchQueryFunction · 0.85
matchMutationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected