diff --git a/doc/api/stream.md b/doc/api/stream.md index 83fb13d71e..a7478bf3de 100644 --- a/doc/api/stream.md +++ b/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. diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index daef34b50c..76c4972d40 100644 --- a/lib/_stream_writable.js +++ b/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) {