| 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) |