Browse Source

doc: make `writable.setDefaultEncoding()` return `this`

Let this function return `this` for parity with `readable.setEncoding()`.

PR-URL: https://github.com/nodejs/node/pull/5040
Fixes: https://github.com/nodejs/node/issues/5013

Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v6.x
Alexander Makarenko 9 years ago
committed by Jeremiah Senkpiel
parent
commit
e6c8da45b1
  1. 1
      doc/api/stream.md
  2. 1
      lib/_stream_writable.js

1
doc/api/stream.md

@ -695,6 +695,7 @@ file.end('world!');
#### writable.setDefaultEncoding(encoding)
* `encoding` {String} The new default encoding
* Return: `this`
Sets the default encoding for a writable stream.

1
lib/_stream_writable.js

@ -251,6 +251,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
if (!Buffer.isEncoding(encoding))
throw new TypeError('Unknown encoding: ' + encoding);
this._writableState.defaultEncoding = encoding;
return this;
};
function decodeChunk(state, chunk, encoding) {

Loading…
Cancel
Save