MCPcopy Create free account
hub / github.com/cortexkit/magic-context / writeJsonAtomic

Function writeJsonAtomic

packages/plugin/scripts/longmemeval/runner.ts:65–72  ·  view source on GitHub ↗
(filePath: string, value: unknown)

Source from the content-addressed store, hash-verified

63}
64
65async function writeJsonAtomic(filePath: string, value: unknown): Promise<void> {
66 await enqueueWrite(async () => {
67 await ensureParentDirectory(filePath);
68 const tempPath = `${filePath}.${crypto.randomUUID()}.tmp`;
69 await writeFile(tempPath, `${JSON.stringify(value, null, 2)}\n`, "utf8");
70 await rename(tempPath, filePath);
71 });
72}
73
74async function appendLine(filePath: string, line: string): Promise<void> {
75 await enqueueWrite(async () => {

Callers 2

persistStateFunction · 0.85
writeSummaryFunction · 0.85

Calls 2

enqueueWriteFunction · 0.85
ensureParentDirectoryFunction · 0.85

Tested by

no test coverage detected