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

Function upsert

packages/opencode/src/cli/cmd/run/session-data.ts:263–271  ·  view source on GitHub ↗
(list: T[], item: T)

Source from the content-addressed store, hash-verified

261}
262
263function upsert<T extends { id: string }>(list: T[], item: T) {
264 const idx = list.findIndex((entry) => entry.id === item.id)
265 if (idx === -1) {
266 list.push(item)
267 return
268 }
269
270 list[idx] = item
271}
272
273function remove(list: Array<{ id: string }>, id: string): boolean {
274 const idx = list.findIndex((entry) => entry.id === id)

Callers 2

bootstrapSessionDataFunction · 0.70
reduceSessionDataFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected