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

Function runInflight

packages/app/src/context/server-session.ts:85–93  ·  view source on GitHub ↗
(map: Map<string, Promise<void>>, key: string, task: () => Promise<void>)

Source from the content-addressed store, hash-verified

83}
84
85function runInflight(map: Map<string, Promise<void>>, key: string, task: () => Promise<void>) {
86 const pending = map.get(key)
87 if (pending) return pending
88 const promise = task().finally(() => {
89 if (map.get(key) === promise) map.delete(key)
90 })
91 map.set(key, promise)
92 return promise
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))

Callers 4

syncFunction · 0.85
prefetchFunction · 0.85
diffFunction · 0.85
todoFunction · 0.85

Calls 4

taskFunction · 0.85
getMethod · 0.65
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected