MCPcopy Create free account
hub / github.com/anomalyco/opencode / merge

Function merge

packages/app/src/context/server-session.ts:95–99  ·  view source on GitHub ↗
(a: readonly T[], b: readonly T[])

Source from the content-addressed store, hash-verified

93}
94
95function merge<T extends { id: string }>(a: readonly T[], b: readonly T[]) {
96 const items = new Map(a.map((item) => [item.id, item] as const))
97 for (const item of b) items.set(item.id, item)
98 return [...items.values()].sort((x, y) => cmp(x.id, y.id))
99}
100
101function reconcileFetched<T extends { id: string }>(
102 fetched: T[],

Callers 4

mergeOptimisticPageFunction · 0.70
confirmOptimisticPartFunction · 0.70
confirmOptimisticFunction · 0.70
addFunction · 0.70

Calls 3

cmpFunction · 0.70
setMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected