-
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
doc: fix trivial mistakes in stream document. #10411
Conversation
the `encoding` argument can be safely ignored, and `chunk` will always be a | ||
`Buffer`. | ||
the `encoding` argument can be safely ignored, and `chunk` will remain the same | ||
type from the source. |
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.
How can one tell what the type is? I thought these were always Buffers lol.
Do you mean it is different for Object Mode?
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.
When decodeStrings is true, string is converted into Buffer here.
https://github.com/nodejs/node/blob/v6.9.3-proposal/lib/_stream_writable.js#L285-L288
Of course Buffer is still Buffer. So the chunk always be a Buffer.
When decodeStrings is false, there is no conversion before _write()
received it.
So, string keeps string, not always be Buffer.
Please see upper sample codes.
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.
@fmy you are right. I would phrase that differently thought, because Writable
can be used also without pipe()
. How about:
will remain the same object that is passed to .write()
.
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 remain the same object that is passed to .write().
@mcollina thanks! i will change words.
@nodejs/streams |
the `encoding` argument can be safely ignored, and `chunk` will always be a | ||
`Buffer`. | ||
the `encoding` argument can be safely ignored, and `chunk` will remain the same | ||
type from the source. |
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.
@fmy you are right. I would phrase that differently thought, because Writable
can be used also without pipe()
. How about:
will remain the same object that is passed to .write()
.
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`.
In this context, 'expected' looks strange word.
0834cb8
to
404222a
Compare
I changed some words. |
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.
LGTM
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 37d6052 |
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When decodeStrings is false and given data is string, _write() function receives the string data not `Buffer`. PR-URL: #10411 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Affected core subsystem(s)
doc
Description of change
1st commit:
In stream.Writable, when decodeStrings option is false, the chunk
_write()
function received is not always beBuffer
, it depends types of the sources.2nd commit:
This is a trivial fix, 'unexpected' fits this context.