MCPcopy
hub / github.com/angular/angular / valuesMatching

Function valuesMatching

packages/core/src/render3/list_reconciliation.ts:57–73  ·  view source on GitHub ↗
(
  liveIdx: number,
  liveValue: V,
  newIdx: number,
  newValue: V,
  trackBy: TrackByFunction<V>,
)

Source from the content-addressed store, hash-verified

55}
56
57function valuesMatching<V>(
58 liveIdx: number,
59 liveValue: V,
60 newIdx: number,
61 newValue: V,
62 trackBy: TrackByFunction<V>,
63): number {
64 if (liveIdx === newIdx && Object.is(liveValue, newValue)) {
65 // matching and no value identity to update
66 return 1;
67 } else if (Object.is(trackBy(liveIdx, liveValue), trackBy(newIdx, newValue))) {
68 // matching but requires value identity update
69 return -1;
70 }
71
72 return 0;
73}
74
75function recordDuplicateKeys(keyToIdx: Map<unknown, Set<number>>, key: unknown, idx: number): void {
76 const idxSoFar = keyToIdx.get(key);

Callers 1

reconcileFunction · 0.85

Calls 1

trackByFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…