Closed
Description
Currently, readline
module interface is rather special. Interface
class is EventEmitter acting as stream, but not conforming to Stream
interface. It's possible to redirect output to stream, but it's significantly less convenient than just .pipe
.
Then I propose one of the following:
- add class
readline.Stream
subclassingTransform
.readline.Interface
can be backed by this stream, then no code duplication occurs. Though, I'm not sure about viability of this approach, asInterface
contains lots of code related to TTY handling.
- make
readline.Interface
instances subclasses ofTransform
stream
Compare:
foo = getReadableStream();
bar = transformStream();
foo
.pipe(readline.Stream())
.pipe(bar)
.pipe(process.stdout)
vs.
foo = getReadableStream();
bar = transformStream();
readline.createInterface({
input: foo,
output: bar
}); // We are using factory function for side effects.
bar.pipe(process.stdout);
User-land packages providing this functionality:
- byline (423k downloads per month)