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

Function partialMatchKey

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

Source from the content-addressed store, hash-verified

299 */
300export function partialMatchKey(a: QueryKey, b: QueryKey): boolean
301export function partialMatchKey(a: any, b: any): boolean {
302 if (a === b) {
303 return true
304 }
305
306 if (typeof a !== typeof b) {
307 return false
308 }
309
310 if (a && b && typeof a === 'object' && typeof b === 'object') {
311 if (Array.isArray(a) && Array.isArray(b)) {
312 if (b.length > a.length) return false
313 for (let i = 0; i < b.length; i++) {
314 if (!partialMatchKey(a[i], b[i])) {
315 return false
316 }
317 }
318 return true
319 }
320
321 const bKeys = Object.keys(b)
322 for (const key of bKeys) {
323 if (!partialMatchKey(a[key], b[key])) {
324 return false
325 }
326 }
327 return true
328 }
329
330 return false
331}
332
333const hasOwn = Object.prototype.hasOwnProperty
334

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