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

Function shallowEqualObjects

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

Source from the content-addressed store, hash-verified

328 * Shallow compare objects.
329 */
330export function shallowEqualObjects<T extends Record<string, any>>(
331 a: T,
332 b: T | undefined,
333): boolean {
334 if (!b || Object.keys(a).length !== Object.keys(b).length) {
335 return false
336 }
337
338 for (const key in a) {
339 if (a[key] !== b[key]) {
340 return false
341 }
342 }
343
344 return true
345}
346
347export function isPlainArray(value: unknown): value is Array<unknown> {
348 return Array.isArray(value) && value.length === Object.keys(value).length

Callers 6

setOptionsMethod · 0.90
getOptimisticResultMethod · 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