MCPcopy Create free account
hub / github.com/arktypeio/arktype / writeFileUpdates

Function writeFileUpdates

ark/attest/cache/snapshots.ts:261–274  ·  view source on GitHub ↗
(path: string, updates: QueuedUpdate[])

Source from the content-addressed store, hash-verified

259}
260
261const writeFileUpdates = (path: string, updates: QueuedUpdate[]) => {
262 let fileText = readFile(path)
263 let offSet = 0
264 for (const update of updates) {
265 const { pos, end } = update.snapCallArgs
266 fileText =
267 fileText.slice(0, pos + offSet) +
268 update.newArgText +
269 fileText.slice(end + offSet)
270 offSet += update.newArgText.length - (end - pos)
271 summarizeSnapUpdate(update)
272 }
273 writeFile(path, fileText)
274}
275
276const summarizeSnapUpdate = (update: QueuedUpdate) => {
277 const previousValue = update.snapCallArgs.firstArgText

Callers 1

writeUpdatesFunction · 0.85

Calls 3

readFileFunction · 0.90
writeFileFunction · 0.90
summarizeSnapUpdateFunction · 0.85

Tested by

no test coverage detected