@tanstack/query-core 5.85.6 → 5.85.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/{hydration-DTop62kY.d.cts → hydration-BC7iBQD-.d.cts} +2 -2
- package/build/legacy/{hydration-Dh_94ejg.d.ts → hydration-BpLOP9Dw.d.ts} +2 -2
- package/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/streamedQuery.d.cts +1 -1
- package/build/legacy/streamedQuery.d.ts +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.cjs +24 -21
- package/build/legacy/utils.cjs.map +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/legacy/utils.js +24 -21
- package/build/legacy/utils.js.map +1 -1
- package/build/modern/{hydration-DTop62kY.d.cts → hydration-BC7iBQD-.d.cts} +2 -2
- package/build/modern/{hydration-Dh_94ejg.d.ts → hydration-BpLOP9Dw.d.ts} +2 -2
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/streamedQuery.d.cts +1 -1
- package/build/modern/streamedQuery.d.ts +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.cjs +24 -21
- package/build/modern/utils.cjs.map +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/build/modern/utils.js +24 -21
- package/build/modern/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/utils.ts +37 -30
package/src/utils.ts
CHANGED
|
@@ -245,6 +245,8 @@ export function partialMatchKey(a: any, b: any): boolean {
|
|
|
245
245
|
return false
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
const hasOwn = Object.prototype.hasOwnProperty
|
|
249
|
+
|
|
248
250
|
/**
|
|
249
251
|
* This function returns `a` if `b` is deeply equal.
|
|
250
252
|
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
@@ -258,37 +260,43 @@ export function replaceEqualDeep(a: any, b: any): any {
|
|
|
258
260
|
|
|
259
261
|
const array = isPlainArray(a) && isPlainArray(b)
|
|
260
262
|
|
|
261
|
-
if (array
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
263
|
+
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b
|
|
264
|
+
|
|
265
|
+
const aItems = array ? a : Object.keys(a)
|
|
266
|
+
const aSize = aItems.length
|
|
267
|
+
const bItems = array ? b : Object.keys(b)
|
|
268
|
+
const bSize = bItems.length
|
|
269
|
+
const copy: any = array ? new Array(bSize) : {}
|
|
270
|
+
|
|
271
|
+
let equalItems = 0
|
|
272
|
+
|
|
273
|
+
for (let i = 0; i < bSize; i++) {
|
|
274
|
+
const key: any = array ? i : bItems[i]
|
|
275
|
+
const aItem = a[key]
|
|
276
|
+
const bItem = b[key]
|
|
277
|
+
|
|
278
|
+
if (aItem === bItem) {
|
|
279
|
+
copy[key] = aItem
|
|
280
|
+
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++
|
|
281
|
+
continue
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (
|
|
285
|
+
aItem === null ||
|
|
286
|
+
bItem === null ||
|
|
287
|
+
typeof aItem !== 'object' ||
|
|
288
|
+
typeof bItem !== 'object'
|
|
289
|
+
) {
|
|
290
|
+
copy[key] = bItem
|
|
291
|
+
continue
|
|
286
292
|
}
|
|
287
293
|
|
|
288
|
-
|
|
294
|
+
const v = replaceEqualDeep(aItem, bItem)
|
|
295
|
+
copy[key] = v
|
|
296
|
+
if (v === aItem) equalItems++
|
|
289
297
|
}
|
|
290
298
|
|
|
291
|
-
return
|
|
299
|
+
return aSize === bSize && equalItems === aSize ? a : copy
|
|
292
300
|
}
|
|
293
301
|
|
|
294
302
|
/**
|
|
@@ -311,13 +319,12 @@ export function shallowEqualObjects<T extends Record<string, any>>(
|
|
|
311
319
|
return true
|
|
312
320
|
}
|
|
313
321
|
|
|
314
|
-
export function isPlainArray(value: unknown) {
|
|
322
|
+
export function isPlainArray(value: unknown): value is Array<unknown> {
|
|
315
323
|
return Array.isArray(value) && value.length === Object.keys(value).length
|
|
316
324
|
}
|
|
317
325
|
|
|
318
326
|
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
319
|
-
|
|
320
|
-
export function isPlainObject(o: any): o is Object {
|
|
327
|
+
export function isPlainObject(o: any): o is Record<PropertyKey, unknown> {
|
|
321
328
|
if (!hasObjectPrototype(o)) {
|
|
322
329
|
return false
|
|
323
330
|
}
|