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>
This commit is contained in:
Alexander Makarenko 2016-04-30 18:55:46 +02:00 committed by Calvin Metcalf
parent 62c31fe392
commit bcce05dba4
2 changed files with 2 additions and 0 deletions

View File

@ -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.

View File

@ -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) {