-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
doc: add note to readable stream async iterator docs #19331
doc: add note to readable stream async iterator docs #19331
Conversation
doc/api/stream.md
Outdated
@@ -1197,7 +1197,9 @@ print(fs.createReadStream('file')).catch(console.log); | |||
|
|||
If the loop terminates with a `break` or a `throw`, the stream will be | |||
destroyed. In other terms, iterating over a stream will consume the stream | |||
fully. | |||
fully. | |||
Note that by default file iteration would be by the chunks of the size equal |
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.
Thanks for the pull request! If this is a new paragraph, please put a blank line between it and the previous line. If it is not, please remove the newline. Thanks!
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.
Not sure what you mean by that. There is a 80 chars per line restriction:
Running Markdown linter on docs...
doc/api/stream.md
1201:153 warning Line must be at most 80 characters maximum-line-length remark-lint
doc/api/stream.md
Outdated
fully. | ||
fully. | ||
Note that by default file iteration would be by the chunks of the size equal | ||
to [`highWaterMark`][] value(default is 16kb). |
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.
There appears to be no link for highWaterMark
so this does not render as a link.
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.
Please put a space between value
and (
.
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.
fixed
Left some comments, but I'm happy to make the changes myself to your branch if you want. But I'm not exactly sure what the text means. Is it saying that the size of chunks read from the stream will be 16Kb by default? Or is something else 16Kb by default? I'm not sure what "file iteration" is. Does that mean reading the contents of a file? |
Oh if its not clear from the first glance then I guess my note should be refactored 😄
So without
And I was wrong about the default value. Its 64 kb as fs.createReadStream doc says |
1c6d7ad
to
c221d8e
Compare
c221d8e
to
6e53943
Compare
I changed the wording |
6e53943
to
042cf85
Compare
doc/api/stream.md
Outdated
@@ -1197,7 +1197,10 @@ print(fs.createReadStream('file')).catch(console.log); | |||
|
|||
If the loop terminates with a `break` or a `throw`, the stream will be | |||
destroyed. In other terms, iterating over a stream will consume the stream | |||
fully. | |||
fully. | |||
Note that by default, async reading of the contents of the file will be |
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.
Nit: it should be obvious that this is a async
operation, so I would not mention that again.
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.
I still find this a bit confusing. For example, "of the file"...there's no guarantee the stream is a file, or am I wrong about that?
How about this?
By default, the stream will be read in chunks of size equal to the
highWaterMark
option.
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.
(Maybe omit the mention of the default value from fs.createReadStream()
since the default value is 16kb for some other ways of creating streams.)
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 "by default" even necessary in the sentence? Is there an option to change it? If so, maybe it should be mentioned? "If fooOption
is not set, then by default, the stream will be..."
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.
For example, "of the file"...there's no guarantee the stream is a file, or am I wrong about that?
Its just that I tested with fs.createReadStream()
and the same example in docs but I guess this behaviour is the same in other cases
After thinking this though I think you are right in all of your suggestions. But note became too general so I would also add a test-case example:
The stream will be read in chunks of size equal to the
highWaterMark
option.
So in code example above it will only be one iteration if'file'
has less
then 64kb of data. Unless customhighWaterMark
value is specified in
[fs.createReadStream()
][] constructor.
Looks good?
If its too much hassle I can just left general part:
The stream will be read in chunks of size equal to the
highWaterMark
option.
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.
Maybe this?
The stream will be read in chunks of size equal to the `highWaterMark` option.
In the code example above, data will be in a single chunk if the file has less
then 64kb of data because no `highWaterMark` option is provided to
[`fs.createReadStream()`][].
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.
Seems good 👍
thank you, updated in 3aa49be
its hard to write good docs 😄
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.
Thanks for your patience. The PR-review process for docs can seem tedious and endless sometimes.
tests are green |
PR-URL: nodejs#19331 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 45c86e3 |
Yay! \o/ |
While I was working on #18904 I noticed that async iterator in readable streams iterates by the chunks of the size equal to stream
highWaterMark
value when reading a file. So I think it worth to mention in docs because at least for me it seemed confusing at first.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
stream, doc