scroll/src/deno/terminal_io.ts

26 lines
512 B
JavaScript
Raw Normal View History

import { ITerminalIO } from '../common/types.ts';
/**
* Wrap the runtime-specific hook into stdin
*/
export async function* inputLoop() {
for await (const chunk of Deno.stdin.readable) {
yield chunk;
}
}
2023-11-08 11:11:19 -05:00
export async function write(s: string): Promise<void> {
const buffer = new TextEncoder().encode(s);
const stdout = Deno.stdout.writable.getWriter();
await stdout.write(buffer);
stdout.releaseLock();
}
const DenoTerminalIO: ITerminalIO = {
inputLoop,
write,
};
export default DenoTerminalIO;