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

Function shallowEqualObjects

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

Source from the content-addressed store, hash-verified

445 * @returns `true` if both objects have the same keys, with strictly equal values for each key.
446 */
447export function shallowEqualObjects<T extends Record<string, any>>(
448 a: T,
449 b: T | undefined,
450): boolean {
451 if (!b || Object.keys(a).length !== Object.keys(b).length) {
452 return false
453 }
454
455 for (const key of Object.keys(a)) {
456 if (!hasOwn.call(b, key) || a[key] !== b[key]) {
457 return false
458 }
459 }
460
461 return true
462}
463
464/**
465 * Checks whether a value is an array with no holes and no extra properties.

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