Answer the question
In order to leave comments, you need to log in
Why is the TTY module needed in nodejs?
I read the documentation and did not understand why it is needed? After all, there are readline and REPL modules? Please tell me or give a description. Thank you in advance)))
Answer the question
In order to leave comments, you need to log in
In essence, the following happens inside the node:
const tty = require('tty');
if(tty.isatty(0)) {
process.stdin = new tty.ReadStream();
} else {
//init process.stdin from other stream
}
var outStream;
if(tty.isatty(1)) {
outStream = new tty.WriteStream();
process.stdout = outStream;
} else {
//init process.stdout from other stream
}
if(tty.isatty(2)) {
if(!outStream) {
outStream = new tty.WriteStream();
}
process.stderr = outStream;
} else {
//init process.stderr from other stream
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question