scroll/src/bun/mod.ts

26 lines
645 B
JavaScript
Raw Normal View History

2023-10-31 14:47:59 -04:00
/**
* The main entrypoint when using Bun as the runtime
2023-10-31 14:47:59 -04:00
*/
import { IRuntime, RunTimeType } from '../common/mod.ts';
import BunFFI from './ffi.ts';
import BunTerminalIO from './terminal_io.ts';
2023-11-13 15:33:56 -05:00
import BunFileIO from './file_io.ts';
const BunRuntime: IRuntime = {
name: RunTimeType.Bun,
2023-11-13 15:33:56 -05:00
file: BunFileIO,
ffi: BunFFI,
2023-11-13 15:33:56 -05:00
term: BunTerminalIO,
onEvent: (eventName: string, handler: (e: Event) => void) =>
process.on(eventName, handler),
onExit: (cb: () => void): void => {
process.on('beforeExit', cb);
process.on('exit', cb);
process.on('SIGINT', cb);
},
exit: (code?: number) => process.exit(code),
};
export default BunRuntime;