-
Notifications
You must be signed in to change notification settings - Fork 7.3k
doc: several documentation improvements #25635
Conversation
Clarifies that emitter.listener() returns a copy, not a reference Resolves issue nodejs#9022
per: nodejs#14596 1. document that a runtime error will occur if you attempt to unshift after the end event 2. document that calling read after the end event will return null and will not trigger a runtime error
Minor clarifications around Readable._read and Readable.push to make their implementation/usage easier to understand. nodejs#14124 (comment)
Fix for nodejs#25559 (Typo in example of util.deprecate() documentation)
Per nodejs#14604, Document that performing an `unshift` during a read can have unexpected results. Following the `unshift` with a `push('')` resets the reading state appropriately. Also indicate that doing an `unshift` during a read is not optimal and should be avoided.
@joyent/node-collaborators |
var fs = require('fs'); | ||
var rr = fs.createReadStream('foo.txt'); | ||
rr.on('readable', function() { | ||
var chunk; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this variable only for demonstration? Not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah...right, just mentally zoned on that one ;-). I'll remove the variable really quick
One question. Otherwise LGTM |
per nodejs#14597 Indicate that `'readable'` indicates only that data can be read from the stream, not that there is actually data to be consumed. `readable.read([size])` can still return null. Includes an example that illustrates the point.
1b9d4f3
to
970e2f1
Compare
@@ -167,6 +167,32 @@ again when more data is available. | |||
The `readable` event is not emitted in the "flowing" mode with the | |||
sole exception of the last one, on end-of-stream. | |||
|
|||
Note that the `'readable'` event indicates only that data *can* be | |||
read from the stream. It does not indicate whether there is actual | |||
data to be consumed. The callback passed to handle the `'readable'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first two sentences are pretty confusing. Maybe:
The
'readable'
event indicates that the stream has new information: either new data is available or the end of the stream has been reached. In the former case,.read()
will return that data. In the latter case,.read()
will returnnull
. For instance, in the following example, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 will make that change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisdickinson ... done... if it looks good to you I'll get it landed
Per nodejs#25635 (comment) Additional refinement to the clarification on the `readable` event
Clarifies that emitter.listener() returns a copy, not a reference Resolves issue #9022 Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
per: #14596 1. document that a runtime error will occur if you attempt to unshift after the end event 2. document that calling read after the end event will return null and will not trigger a runtime error 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. #14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
Fix for #25559 (Typo in example of util.deprecate() documentation) Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
Per #14604, Document that performing an `unshift` during a read can have unexpected results. Following the `unshift` with a `push('')` resets the reading state appropriately. Also indicate that doing an `unshift` during a read is not optimal and should be avoided. Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
per #14597 Indicate that `'readable'` indicates only that data can be read from the stream, not that there is actually data to be consumed. `readable.read([size])` can still return null. Includes an example that illustrates the point. Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
Per #25635 (comment) Additional refinement to the clarification on the `readable` event Reviewed-By: James M Snell <[email protected]> PR-URL: #25635
Clarifies that emitter.listener() returns a copy, not a reference Resolves issue nodejs#9022 Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
per: nodejs#14596 1. document that a runtime error will occur if you attempt to unshift after the end event 2. document that calling read after the end event will return null and will not trigger a runtime error 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. nodejs#14124 (comment) Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
Fix for nodejs#25559 (Typo in example of util.deprecate() documentation) Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
Per nodejs#14604, Document that performing an `unshift` during a read can have unexpected results. Following the `unshift` with a `push('')` resets the reading state appropriately. Also indicate that doing an `unshift` during a read is not optimal and should be avoided. Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
per nodejs#14597 Indicate that `'readable'` indicates only that data can be read from the stream, not that there is actually data to be consumed. `readable.read([size])` can still return null. Includes an example that illustrates the point. Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
Per nodejs#25635 (comment) Additional refinement to the clarification on the `readable` event Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25635
Per #25635 (comment) Additional refinement to the clarification on the `readable` event Reviewed-By: James M Snell <[email protected]> PR-URL: #25591
Per nodejs/node-v0.x-archive#25635 (comment) Additional refinement to the clarification on the `readable` event Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs/node-v0.x-archive#25591
Per nodejs#25635 (comment) Additional refinement to the clarification on the `readable` event Reviewed-By: James M Snell <[email protected]> PR-URL: nodejs#25591
bundled together to make landing them easier.