Skip to content
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

Closed
wants to merge 4 commits into from
Closed

doc: how to decode buffers extending from Writable #16403

wants to merge 4 commits into from

Conversation

dicearr
Copy link
Contributor

@dicearr dicearr commented Oct 23, 2017

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

Improved stream documentation with an example of how to decode buffers
to strings within a custom Writable.

Fixes: #15369
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem. labels Oct 23, 2017
@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Oct 23, 2017

Hi @dicearr! Thank you for a try to improve the docs.

We lint code fragments in docs (you can run node tools\eslint\bin\eslint.js --rulesdir tools/eslint-rules/ --ext=.md doc from the project root with your branch to check the conformity).

Currently, there are some issues with the linter:

  1. Lack of semicolons.
  2. Spaces between a function (method) name and parentheses.

You can fix them in a new commit or amend the existing one.

@jasnell jasnell requested a review from mcollina October 23, 2017 17:24
@tniessen
Copy link
Member

@tniessen
Copy link
Member

cc @nodejs/documentation

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mcollina mcollina left a 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.


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
Copy link
Member

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."

this._data += this._decoder.end();
callback();
}
}
Copy link
Member

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.

w.write(euro[0]);
w.end(euro[1]);

console.log(w._data); // currency: €
Copy link
Member

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.

@mcollina
Copy link
Member

@mcollina
Copy link
Member

CI failures are unrelated, landing.

Thanks for your first contribution @dicearr 🎉 !

@mcollina
Copy link
Member

Landed as e509db8!

@mcollina mcollina closed this Oct 31, 2017
mcollina pushed a commit that referenced this pull request Oct 31, 2017
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 <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
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>
Qard pushed a commit to ayojs/ayo that referenced this pull request Nov 2, 2017
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>
@dicearr dicearr deleted the docs-stream-decode-buf branch November 2, 2017 08:50
cjihrig pushed a commit to cjihrig/node that referenced this pull request Nov 6, 2017
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>
@cjihrig cjihrig mentioned this pull request Nov 6, 2017
gibfahn pushed a commit that referenced this pull request Nov 14, 2017
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 <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
MylesBorins pushed a commit that referenced this pull request Nov 14, 2017
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 <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Nov 21, 2017
@gibfahn gibfahn mentioned this pull request Nov 21, 2017
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how to use StringDecoder in combination with stream.Transform
9 participants