scroll/src/bun/file_io.ts

23 lines
653 B
JavaScript

import { IFileIO } from '../common/runtime.ts';
import { appendFileSync, readFileSync } from 'node:fs';
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();
},
openFileSync: (path: string): string => {
return readFileSync(path).toString();
},
appendFile: async function (path: string, contents: string): Promise<void> {
return await appendFile(path, contents);
},
appendFileSync: function (path: string, contents: string) {
return appendFileSync(path, contents);
},
};
export default BunFileIO;