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

Function partialMatchKey

packages/query-core/src/utils.ts:344–378  ·  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 return false
356 }
357
358 if (Array.isArray(a) && Array.isArray(b)) {
359 if (b.length > a.length) return false
360 for (let i = 0; i < b.length; i++) {
361 if (!partialMatchKey(a[i], b[i])) {
362 return false
363 }
364 }
365 return true
366 }
367
368 const bKeys = Object.keys(b)
369 for (const key of bKeys) {
370 if (!partialMatchKey(a[key], b[key])) {
371 return false
372 }
373 }
374 return true
375 }
376
377 return false
378}
379
380const hasOwn = Object.prototype.hasOwnProperty
381

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