Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4475611
tty_readstream_setencoding_child.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
643 B
Referenced Files
None
Subscribers
None
tty_readstream_setencoding_child.cjs
View Options
const fs = require('fs');
const tty = require('tty');
const fd = fs.openSync('/dev/tty', 'r');
const stream = new tty.ReadStream(fd);
function cleanup() {
try { stream.destroy(); } catch {}
}
stream.setEncoding('utf8');
process.stdout.write('READY\n');
const timeout = setTimeout(() => {
cleanup();
console.log('TIMEOUT');
process.exit(3);
}, 2000);
stream.on('data', chunk => {
clearTimeout(timeout);
cleanup();
if (typeof chunk !== 'string') {
console.log('TYPE', typeof chunk);
process.exit(4);
}
console.log('DATA', JSON.stringify(chunk));
process.exit(chunk === 'A€\n' ? 0 : 5);
});
stream.resume();
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 10:16 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
542178
Default Alt Text
tty_readstream_setencoding_child.cjs (643 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment