Uh oh!
There was an error while loading. Please reload this page.
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. |
tniessen
commented
Oct 28, 2017
tniessen
commented
Oct 28, 2017
cc @nodejs/documentation |
| 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.
| 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.
mcollina
commented
Oct 31, 2017
mcollina
commented
Oct 31, 2017
CI failures are unrelated, landing. Thanks for your first contribution @dicearr 🎉 ! |
mcollina
commented
Oct 31, 2017
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