17 lines
367 B
JavaScript
17 lines
367 B
JavaScript
/**
|
|
* Wrap the runtime-specific hook into stdin
|
|
*/
|
|
export async function* inputLoop() {
|
|
for await (const chunk of Deno.stdin.readable) {
|
|
yield chunk;
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|