scroll/src/bun/terminal_io.ts

24 lines
443 B
JavaScript
Raw Normal View History

/**
* Wrap the runtime-specific hook into stdin
*/
import { ITerminalIO } from '../common/mod.ts';
export async function* inputLoop() {
for await (const chunk of Bun.stdin.stream()) {
yield chunk;
}
}
export async function write(s: string): Promise<void> {
const buffer = new TextEncoder().encode(s);
await Bun.write(Bun.stdout, buffer);
}
const BunTerminalIO: ITerminalIO = {
inputLoop,
write,
};
export default BunTerminalIO;