MCPcopy
hub / github.com/anomalyco/opencode / update

Function update

packages/opencode/src/storage/storage.ts:280–294  ·  view source on GitHub ↗
(key: string[], fn: (draft: T) => void)

Source from the content-addressed store, hash-verified

278 })
279
280 const update: Interface["update"] = <T>(key: string[], fn: (draft: T) => void) =>
281 Effect.gen(function* () {
282 const value = yield* withResolved(key, (target, rw) =>
283 TxReentrantLock.withWriteLock(
284 rw,
285 Effect.gen(function* () {
286 const content = yield* wrap(target, fs.readJson(target))
287 fn(content as T)
288 yield* writeJson(target, content)
289 return content
290 }),
291 ),
292 )
293 return value as T
294 })
295
296 const write: Interface["write"] = (key: string[], content: unknown) =>
297 Effect.gen(function* () {

Callers 4

project.tsFile · 0.50
processor.tsFile · 0.50
auth.tsFile · 0.50
session.tsFile · 0.50

Calls 4

withResolvedFunction · 0.85
writeJsonFunction · 0.85
wrapFunction · 0.70
fnFunction · 0.50

Tested by

no test coverage detected