doc: how to decode buffers extending from Writable#16403
doc: how to decode buffers extending from Writable#16403dicearr wants to merge 4 commits intonodejs:masterfrom dicearr:docs-stream-decode-buf
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 |
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.
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."
| this._data += this._decoder.end(); | ||
| callback(); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
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: nodejs/node#15369 PR-URL: nodejs/node#16403 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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 <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
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