MCPcopy Create free account
hub / github.com/Snapchat/Valdi / writeFileSync

Function writeFileSync

src/valdi_modules/src/valdi/file_system/web/FileSystem.ts:109–119  ·  view source on GitHub ↗
(path: string, data: ArrayBuffer | string)

Source from the content-addressed store, hash-verified

107 },
108
109 readFileSync(path: string, options?: ReadFileOptions): string | ArrayBuffer {
110 const p = norm(path);
111 const buf = files.get(p) ?? new Uint8Array(0);
112
113 const enc = options?.encoding;
114 if (enc === "utf8") return decUtf8.decode(buf);
115 if (enc === "utf16") return decodeUtf16LE(buf);
116 // undefined/null => raw bytes
117 return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
118 },
119
120 writeFileSync(path: string, data: WriteFileData): void {
121 const p = norm(path);
122 // ensure parent dir exists (be friendly in the stub)

Callers 2

touchMethod · 0.85
touchMethod · 0.85

Calls 6

normFunction · 0.85
parentDirFunction · 0.85
createDirectorySyncMethod · 0.80
hasMethod · 0.65
encodeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected