-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Readable stream documentation is unclear #14124
Comments
Also, the |
Part of the problem it seems, is that node.js essentially has 2 different stream APIs mangled together. You guys should never have modified streams1 into streams2. Instead you should have made a completely separate streams2 module, and deprecated streams1. The Please make a separate module for this and throw out legacy flowing mode. |
@fresheneesz ... interested in putting together a quick PR (targeted at either v0.12 or master) that clarifies the documentation? |
@jasnell I'm really not sure I understand streams enough to be trusted with something like that. Honestly I wouldn't trust myself not to get 50% of it wrong. |
I guess I could clarify just the parts I'm most confident about.. I'll give it a go |
Is this the right file to edit? https://github.com/joyent/node/blob/master/doc/api/stream.markdown |
Yes, that's the right place! |
@jasnell Do you know the answers to some of my questions? Eg about |
…their implementation/usage easier to understand. nodejs#14124 (comment)
…their implementation/usage easier to understand. nodejs#14124 (comment)
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. nodejs#14124 (comment)
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. #14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. nodejs#14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. #14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: #25591
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. nodejs/node-v0.x-archive#14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs/node-v0.x-archive#25591
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. nodejs#14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25591
The documentation makes it really unclear how to implement Readable streams.
I get it, don't call read directly. Don't need to be told 4 separate times. This redundancy obscures the very small amount of useful information written about this method. Lets contract this into something less redundant like: "_Note: Implement this function, but do NOT call it directly. _This method is prefixed with an underscore because it is internal to the class that defines it and only the internal Readable class methods should call it. All Readable stream implementations must provide a read method to fetch data from the underlying resource."
What in god's name does this mean about _read? This is documentation under the
_read
method. Is it saying that the whole point of_read
is to indicate that the stream should pull from its data source after having stopped doing that? What is it talking about "again"? It never mentioned _read being called before that. When is_read
called initially?Perhaps that paragraph should be changed to: "__read will be called [insert when read is first called here]. When the object stops reading as a result of
push
returning false, the object should only continue reading from the resource when_read
is called again._"What's the return value for _read? Nothing?
For push:
Once again, the documentation refers to calling
_read
"again" even tho it never mentions anything about calling it before. What does this mean?The way the documentation describes things seems like a chicken and egg problem.
_read
won't be called untilpush
is called (with something other than null), andpush
shouldn't be called until a call to _read requests more data. How does this make sense?How would I implement a simple passthrough that properly handles backpressure and all that? Would it be something like this?:
The text was updated successfully, but these errors were encountered: