-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readline module and streams #16178
Comments
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 |
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. |
@Ginden You should go ahead and do a PR for this (the first option). FWIW, I'd really like to see this happen. |
Hello, I would like this in a future nodejs version please ;) |
Put into https://github.com/nodejs/node/projects/13 backlog |
I see that project is closed/archived. Is this being tracked elsewhere? Edit: Nevermind, I figured out you can do this with import { pipeline } from "node:stream";
import { createInterface } from "node:readline";
pipeline(
process.stdin,
(input) => createInterface({ input }),
process.stdout,
(err) => {
if (err) {
console.error('Pipeline failed.', err);
} else {
console.log('Pipeline succeeded.');
}
}
); |
Currently,
readline
module interface is rather special.Interface
class is EventEmitter acting as stream, but not conforming toStream
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:
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.readline.Interface
instances subclasses ofTransform
streamCompare:
vs.
User-land packages providing this functionality:
The text was updated successfully, but these errors were encountered: