Skip to content

Commit 8d8fef0

Browse files
Anton Andesensilverwind
authored andcommitted
doc: add note for binary safe string reading
`readable.setEncoding(null)` - may be the most preferable way to proxy a binary data without any encoding/decoding overhead PR-URL: #5155 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
1 parent 40d57b7 commit 8d8fef0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/stream.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ potentially mangled if you simply pulled the Buffers directly and
416416
called [`buf.toString(encoding)`][] on them. If you want to read the data
417417
as strings, always use this method.
418418

419+
Also you can disable any encoding at all with `readable.setEncoding(null)`.
420+
This approach is very useful if you deal with binary data or with large
421+
multi-byte strings spread out over multiple chunks.
422+
419423
```js
420424
var readable = getReadableStreamSomehow();
421425
readable.setEncoding('utf8');

0 commit comments

Comments
 (0)