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

Function shallowEqualObjects

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

Source from the content-addressed store, hash-verified

441 * @returns `true` if both objects have the same keys, with strictly equal values for each key.
442 */
443export function shallowEqualObjects<T extends Record<string, any>>(
444 a: T,
445 b: T | undefined,
446): boolean {
447 if (!b || Object.keys(a).length !== Object.keys(b).length) {
448 return false
449 }
450
451 for (const key of Object.keys(a)) {
452 if (!hasOwn.call(b, key) || a[key] !== b[key]) {
453 return false
454 }
455 }
456
457 return true
458}
459
460/**
461 * 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