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

Function shallowEqualObjects

packages/query-core/src/utils.ts:392–407  ·  view source on GitHub ↗
(
  a: T,
  b: T | undefined,
)

Source from the content-addressed store, hash-verified

390 * Shallow compare objects.
391 */
392export function shallowEqualObjects<T extends Record<string, any>>(
393 a: T,
394 b: T | undefined,
395): boolean {
396 if (!b || Object.keys(a).length !== Object.keys(b).length) {
397 return false
398 }
399
400 for (const key in a) {
401 if (a[key] !== b[key]) {
402 return false
403 }
404 }
405
406 return true
407}
408
409export function isPlainArray(value: unknown): value is Array<unknown> {
410 return Array.isArray(value) && value.length === Object.keys(value).length

Callers 7

setOptionsMethod · 0.90
getOptimisticResultMethod · 0.90
updateResultMethod · 0.90
setOptionsMethod · 0.90
setQueriesMethod · 0.90
utils.test-d.tsxFile · 0.90
utils.test.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected