scroll/src/bun/file_io.ts

20 lines
518 B
JavaScript

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