MCPcopy
hub / github.com/angular/angular / shallowEqual

Function shallowEqual

packages/router/src/utils/collection.ts:21–40  ·  view source on GitHub ↗
(
  a: {[key: string | symbol]: any},
  b: {[key: string | symbol]: any},
)

Source from the content-addressed store, hash-verified

19}
20
21export function shallowEqual(
22 a: {[key: string | symbol]: any},
23 b: {[key: string | symbol]: any},
24): boolean {
25 // While `undefined` should never be possible, it would sometimes be the case in IE 11
26 // and pre-chromium Edge. The check below accounts for this edge case.
27 const k1 = a ? getDataKeys(a) : undefined;
28 const k2 = b ? getDataKeys(b) : undefined;
29 if (!k1 || !k2 || k1.length != k2.length) {
30 return false;
31 }
32 let key: string | symbol;
33 for (let i = 0; i < k1.length; i++) {
34 key = k1[i];
35 if (!equalArraysOrString(a[key], b[key])) {
36 return false;
37 }
38 }
39 return true;
40}
41
42/**
43 * Gets the keys of an object, including `symbol` keys.

Callers 7

advanceActivatedRouteFunction · 0.90
equalParamsFunction · 0.90
equalSegmentsFunction · 0.90
compareFunction · 0.90
shallowEqualArraysFunction · 0.85

Calls 2

getDataKeysFunction · 0.85
equalArraysOrStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…