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

Function partialMatchKey

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

Source from the content-addressed store, hash-verified

342 */
343export function partialMatchKey(a: QueryKey, b: QueryKey): boolean
344export function partialMatchKey(a: any, b: any): boolean {
345 if (a === b) {
346 return true
347 }
348
349 if (typeof a !== typeof b) {
350 return false
351 }
352
353 if (a && b && typeof a === 'object' && typeof b === 'object') {
354 if (Array.isArray(a) && Array.isArray(b)) {
355 if (b.length > a.length) return false
356 for (let i = 0; i < b.length; i++) {
357 if (!partialMatchKey(a[i], b[i])) {
358 return false
359 }
360 }
361 return true
362 }
363
364 const bKeys = Object.keys(b)
365 for (const key of bKeys) {
366 if (!partialMatchKey(a[key], b[key])) {
367 return false
368 }
369 }
370 return true
371 }
372
373 return false
374}
375
376const hasOwn = Object.prototype.hasOwnProperty
377

Callers 8

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

Calls

no outgoing calls

Tested by

no test coverage detected