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

Error at code example of Duplex Stream in Docs #8085

Closed
blairzhao111 opened this issue Aug 12, 2016 · 0 comments
Closed

Error at code example of Duplex Stream in Docs #8085

blairzhao111 opened this issue Aug 12, 2016 · 0 comments
Labels
doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem.

Comments

@blairzhao111
Copy link

  • Version: v6.3.1
  • Platform: all
  • Subsystem: Duplex, Docs

This is the code snippet of code example of Duplex Stream in Docs.

  _write(chunk, encoding, callback) {
    // The underlying source only deals with strings
    if (Buffer.isBuffer(chunk))
      chunk = chunk.toString(encoding);
    this[kSource].writeSomeData(chunk, encoding);
    callback();
  }

If incoming chunk is an instance of Buffer, then encoding argument is supposed to be 'buffer' rather than String encoding types. So in this example, 'buffer' is passed as encoding into toString() and writeSomeData() methods instead of desired string encoding.

@mscdex mscdex added doc Issues and PRs related to the documentations. stream Issues and PRs related to the stream subsystem. labels Aug 12, 2016
lpinca added a commit to lpinca/node that referenced this issue Sep 2, 2016
Fix cases where `chunk` is a buffer.

PR-URL: nodejs#8378
Fixes: nodejs#8085
jasnell pushed a commit that referenced this issue Sep 29, 2016
Fix cases where `chunk` is a buffer.

PR-URL: #8378
Fixes: #8085
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
geek pushed a commit to geek/node that referenced this issue Sep 30, 2016
Fix cases where `chunk` is a buffer.

PR-URL: nodejs#8378
Fixes: nodejs#8085
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Fishrock123 pushed a commit that referenced this issue Oct 11, 2016
Fix cases where `chunk` is a buffer.

PR-URL: #8378
Fixes: #8085
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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 a pull request may close this issue.

2 participants