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>
process-exit-stdio-flushing
Alexander Makarenko 9 years ago
committed by Calvin Metcalf
parent
commit
bcce05dba4
  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) #### writable.setDefaultEncoding(encoding)
* `encoding` {String} The new default encoding * `encoding` {String} The new default encoding
* Return: `this`
Sets the default encoding for a writable stream. 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)) if (!Buffer.isEncoding(encoding))
throw new TypeError('Unknown encoding: ' + encoding); throw new TypeError('Unknown encoding: ' + encoding);
this._writableState.defaultEncoding = encoding; this._writableState.defaultEncoding = encoding;
return this;
}; };
function decodeChunk(state, chunk, encoding) { function decodeChunk(state, chunk, encoding) {

Loading…
Cancel
Save