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

Function shallowEqualObjects

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

Source from the content-addressed store, hash-verified

337 * Shallow compare objects.
338 */
339export function shallowEqualObjects<T extends Record<string, any>>(
340 a: T,
341 b: T | undefined,
342): boolean {
343 if (!b || Object.keys(a).length !== Object.keys(b).length) {
344 return false
345 }
346
347 for (const key in a) {
348 if (a[key] !== b[key]) {
349 return false
350 }
351 }
352
353 return true
354}
355
356export function isPlainArray(value: unknown): value is Array<unknown> {
357 return Array.isArray(value) && value.length === Object.keys(value).length

Callers 6

setOptionsMethod · 0.90
updateResultMethod · 0.90
setOptionsMethod · 0.90
setQueriesMethod · 0.90
utils.test.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected