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
stream.compose documentation could be better #40812
Comments
Can you try: const duplexStream = compose({ writable: subprocess.stdin, readable: subprocess.stdout }) |
Thanks.
|
Can you provide a full repro example? |
Took my time to do this now and the last error message was because I piped it to stdout (which closes it when done) and tried to print to stdout after that. So the only bug then is having to specify the readable/writeable for it to work. |
That's more of a feature request rather than a bug. I'm not sure I see the value of it. |
No, it's a bug because the doc says I can use it the way I tried to use it and that didn't work: |
Not sure how it improve that wording. PR is welcome. |
The wording in the documentation is fine, this is not a documentation bug. This is what's documented Your syntax Btw, I don't submit PR's, that's why I wrote a bug report. Someone else will need to fix them. |
I disagree.
This needs to be documented.
Let's hope someone will fix it then. |
Then the differences between |
Exactly, compose takes many.
This is not true. If there are multiple streams then all but the last must be readable. Otherwise we can't connect them. |
I'm very confused by your statement. How can you compose them into a new duplex stream if the first is not writeable and the last is not readable? I didn't specify writeable or readable in an exclusive form. EDIT: So if I try to re-understand Can you explain how compose is supposed to be used together with streams according to your description ( |
I'm sorry, I edited again after your thumb up... I am having a brain meltdown I guess. If documentation must be fixed, it needs to avoid others getting melted brains. Hence why I want a better understanding of the use case. |
So I'm thinking that the documentation could be changed to something like this (my changes in bold): Combines two or more Duplex streams (e.g. transforms) into a Duplex stream that writes to the first stream and reads from the last. Each provided stream is piped into the next, using stream.pipeline. If any of the streams error then all are destroyed, including the outer Duplex stream. It should not be confused with Because stream.compose returns a new stream that in turn can (and should) be piped into other streams, it enables composition. In contrast, when passing streams to stream.pipeline, typically the first stream is a readable stream and the last a writable stream, forming a closed circuit. If passed a Function it must be a factory method taking a source Iterable. |
Good job! Sounds great. |
I think this issue is still relevant? and the PR linked to it was closed without landing, should we maybe reland the previous PR or a fresh one? |
Version
17.1.0
Platform
Linux
Subsystem
stream
What steps will reproduce the bug?
No response
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
Is it not supposed to work the same as duplexer3?
The error I get:
The argument 'streams[0]' must be readable.
EDIT:
This was a misunderstanding on my behalf, I tried to find an alternative to duplexer3 and mistook
stream.compose
for having the same functionality. Insteadstream.Duplex.from({writable, readable})
actually has the functionality I was looking for!Further down I figured out my mistake and suggested which changes could be done to the documentation to make it clearer.
The text was updated successfully, but these errors were encountered: