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

Feature request: automatic string decoding for writable streams #7315

Closed
mscdex opened this issue Jun 16, 2016 · 4 comments
Closed

Feature request: automatic string decoding for writable streams #7315

mscdex opened this issue Jun 16, 2016 · 4 comments
Labels
feature request Issues that request new features to be added to Node.js. stream Issues and PRs related to the stream subsystem.

Comments

@mscdex
Copy link
Contributor

mscdex commented Jun 16, 2016

  • Version: all
  • Platform: n/a
  • Subsystem: stream

It would be nice if Writable streams had a configuration option to decode buffers to strings (using a StringDecoder instance). This is handy for example when writing a Transform stream that takes utf8 input.

Currently you have to set up your own StringDecoder instance and write the data through that first, which is kind of annoying. For non-multibyte encodings this isn't necessary though since you can just chunk.toString() inside your _write()/_transform() handler.

@mscdex mscdex added stream Issues and PRs related to the stream subsystem. feature request Issues that request new features to be added to Node.js. labels Jun 16, 2016
addaleax added a commit to addaleax/node that referenced this issue Jan 6, 2017
Support decoding the input of writable streams to a specific
decoding before passing it to `_write()`.

By default, all data written to a writable stream is encoded
into Buffers. This change enables the reverse situation, i.e.
when it is desired by the stream implementer to process all
input as strings, whether it was passed to `write()` as a string
or not.

This makes sense for multi-byte character encodings where
the buffers that are written using `write()` may contain
partial characters, so calling `chunk.toString()` is not universally
applicable.

Fixes: nodejs#7315
@Trott
Copy link
Member

Trott commented May 27, 2017

@nodejs/streams

@mcollina
Copy link
Member

This would be very nice to have, if someone would like to take it. Happy to coach, but it is tricky to implement.

#7425 has an original implementation which we need to be rechecked for performance regressions. If there are none, we are 👍 .

A very important thing to do would be to document how to do the boilerplate. See https://github.com/mcollina/split2/blob/master/index.js as an example.

@mcollina
Copy link
Member

See #15369.

@refack
Copy link
Contributor

refack commented Nov 11, 2018

Put into https://github.com/nodejs/node/projects/13 backlog

@refack refack closed this as completed Nov 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

No branches or pull requests

4 participants