Files
scriptc/tests/fixtures/event-loop/stdio-read.mjs
Chris Tate a36b356a6c Support native callable properties and terminal streams
- Preserve callable properties, descriptors, and shared module bindings across native JavaScript code.
- Add stored process streams with input control, output callbacks, and write interception.
- Preserve Error identity and classification through native rethrows and promise rejection.
2026-09-29 00:52:01 -05:00

15 lines
386 B
JavaScript

const input = process.stdin;
input.pause();
console.log('initial', input.read() === null);
let text = '';
let polls = 0;
const timer = setInterval(() => {
let chunk;
while ((chunk = input.read()) !== null) text += String(chunk);
if (text === 'hello' || ++polls > 100) {
clearInterval(timer);
input.pause();
console.log('read', text, input.readableLength);
}
}, 10);