-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: how to decode buffers extending from Writable #16403
Conversation
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: #15369
Hi @dicearr! Thank you for a try to improve the docs. We lint code fragments in docs (you can run Currently, there are some issues with the linter:
You can fix them in a new commit or amend the existing one. |
cc @nodejs/documentation |
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
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 with some nits.
doc/api/stream.md
Outdated
|
||
Decoding buffers is a common task, for instance, when using transformers whose | ||
input is a string. This is not a trivial process when using multi-byte | ||
characters encoding. Implement it within [Writable][] implies some performance |
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 would add: "...multi-byte characters encoding, such as UTF-8."
I would remove the sentence "Implement it within Writable implies some performance regressions".
Then:
"The following example shows how to decode multi-byte strings using StringDecoder
and Writable
."
doc/api/stream.md
Outdated
this._data += this._decoder.end(); | ||
callback(); | ||
} | ||
} |
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.
it would be good to add a quick example on how to use this.
doc/api/stream.md
Outdated
w.write(euro[0]); | ||
w.end(euro[1]); | ||
|
||
console.log(w._data); // currency: € |
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.
can you please rename _data
into data
? accessing a prefixed property from outside is encouraging to tinker with the stream private properties, which is something we would like to avoid.
CI failures are unrelated, landing. Thanks for your first contribution @dicearr 🎉 ! |
Landed as e509db8! |
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: #15369 PR-URL: #16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: nodejs/node#15369 PR-URL: nodejs/node#16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: nodejs/node#15369 PR-URL: nodejs/node#16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: nodejs#15369 PR-URL: nodejs#16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: #15369 PR-URL: #16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: #15369 PR-URL: #16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers to strings within a custom Writable. Fixes: nodejs/node#15369 PR-URL: nodejs/node#16403 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Improved stream documentation with an example of how to decode buffers
to strings within a custom Writable.
Fixes: #15369
Checklist
Affected core subsystem(s)
doc