MCPcopy Create free account
hub / github.com/arctic-cli/interface / update

Function update

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

Source from the content-addressed store, hash-verified

179 }
180
181 export async function update<T>(key: string[], fn: (draft: T) => void) {
182 const dir = await state().then((x) => x.dir)
183 const target = path.join(dir, ...key) + ".json"
184 return withErrorHandling(async () => {
185 using _ = await Lock.write(target)
186 const content = await Bun.file(target).json()
187 fn(content)
188 await Bun.write(target, JSON.stringify(content, null, 2))
189 return content as T
190 })
191 }
192
193 export async function write<T>(key: string[], content: T) {
194 const dir = await state().then((x) => x.dir)

Callers

nothing calls this directly

Calls 4

stateFunction · 0.85
withErrorHandlingFunction · 0.85
jsonMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected