scroll/src/bun/file_io.ts

23 lines
647 B
JavaScript
Raw Normal View History

import { IFIO } from '../common/runtime.ts';
2023-11-13 15:33:56 -05:00
2023-11-16 13:00:02 -05:00
import { appendFileSync, readFileSync } from 'node:fs';
import { appendFile } from 'node:fs/promises';
2023-11-13 15:33:56 -05:00
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();
2023-11-13 15:33:56 -05:00
},
appendFile: async function (path: string, contents: string): Promise<void> {
2023-11-16 13:00:02 -05:00
return await appendFile(path, contents);
},
appendFileSync: function (path: string, contents: string) {
return appendFileSync(path, contents);
},
2023-11-13 15:33:56 -05:00
};
export default BunFileIO;