You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 subclassing Transform.
readline.Interface can be backed by this stream, then no code duplication occurs. Though, I'm not sure about viability of this approach, as Interface contains lots of code related to TTY handling.
make readline.Interface instances subclasses of Transform stream
foo=getReadableStream();bar=transformStream();readline.createInterface({input: foo,output: bar});// We are using factory function for side effects.bar.pipe(process.stdout);
We could do this but I would like to point out that it specifically does not pretend to act like a stream, nor do the docs state that it is any type of stream, it merely acts on a stream and can provide an output stream. That makes it transform-like but does not inherently make it a "transform stream".
I'm willing to make a pull request if there is green light for this.
I believe that Interface instance is conceptually a stream. It reads data in chunks and emits other chunks based on source asynchronously. Making it implement Stream semantics is a change in interface, not in principle of working.
Fair enough. I think I'd prefer if the first option was attempted first, not sure how backwards-compat and API surface overlap would work out for the second option.
Activity
Fishrock123 commentedon Oct 13, 2017
We could do this but I would like to point out that it specifically does not pretend to act like a stream, nor do the docs state that it is any type of stream, it merely acts on a stream and can provide an output stream. That makes it transform-like but does not inherently make it a "transform stream".
Ginden commentedon Oct 14, 2017
I'm willing to make a pull request if there is green light for this.
I believe that
Interfaceinstance is conceptually a stream. It reads data in chunks and emits other chunks based on source asynchronously. Making it implementStreamsemantics is a change in interface, not in principle of working.Fishrock123 commentedon Oct 15, 2017
Fair enough. I think I'd prefer if the first option was attempted first, not sure how backwards-compat and API surface overlap would work out for the second option.
bengl commentedon Oct 25, 2017
@Ginden You should go ahead and do a PR for this (the first option). FWIW, I'd really like to see this happen.
clakech commentedon Feb 23, 2018
Hello, I would like this in a future nodejs version please ;)
refack commentedon Nov 11, 2018
Put into https://github.com/nodejs/node/projects/13 backlog
zavan commentedon Feb 9, 2024
I see that project is closed/archived. Is this being tracked elsewhere?
Edit: Nevermind, I figured out you can do this with
pipeline: