scroll/src/bun/file_io.ts

19 lines
528 B
JavaScript

import { IFileIO } from '../common/runtime.ts';
import { appendFile } from 'node:fs/promises';
const BunFileIO: IFileIO = {
openFile: async (path: string): Promise<string> => {
const file = await Bun.file(path);
return await file.text();
},
appendFile: async function (path: string, contents: string): Promise<void> {
return await appendFile(path, contents);
},
saveFile: async function (path: string, contents: string): Promise<void> {
await Bun.write(path, contents);
return;
},
};
export default BunFileIO;