diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-09-21 02:29:41 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-09-25 19:21:05 +0300 |
commit | e71bdadf526477c05d676034cfab0aa42cda257d (patch) | |
tree | 1fa3ab8accc51cce35dcce65aeb11afe22ec1690 /doc/api | |
parent | 2707beb8b8aaa4619a28f79eeacd980d630ed85d (diff) |
stream: make _write() optional when _writev() is implemented
When implementing _writev, _write should be optional.
PR-URL: https://github.com/nodejs/node/pull/29639
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r-- | doc/api/stream.md | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/api/stream.md b/doc/api/stream.md index 8d21abb6bde..557e37ed7c0 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1684,8 +1684,8 @@ const myWritable = new Writable({ The `stream.Writable` class is extended to implement a [`Writable`][] stream. Custom `Writable` streams *must* call the `new stream.Writable([options])` -constructor and implement the `writable._write()` method. The -`writable._writev()` method *may* also be implemented. +constructor and implement the `writable._write()` and/or `writable._writev()` +method. #### Constructor: new stream.Writable([options]) <!-- YAML @@ -1774,6 +1774,12 @@ const myWritable = new Writable({ ``` #### writable.\_write(chunk, encoding, callback) +<!-- YAML +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/29639 + description: _write() is optional when providing _writev(). +--> * `chunk` {Buffer|string|any} The `Buffer` to be written, converted from the `string` passed to [`stream.write()`][stream-write]. If the stream's @@ -1787,7 +1793,8 @@ const myWritable = new Writable({ argument) when processing is complete for the supplied chunk. All `Writable` stream implementations must provide a -[`writable._write()`][stream-_write] method to send data to the underlying +[`writable._write()`][stream-_write] and/or +[`writable._writev()`][stream-_writev] method to send data to the underlying resource. [`Transform`][] streams provide their own implementation of the @@ -1830,8 +1837,8 @@ This function MUST NOT be called by application code directly. It should be implemented by child classes, and called by the internal `Writable` class methods only. -The `writable._writev()` method may be implemented in addition to -`writable._write()` in stream implementations that are capable of processing +The `writable._writev()` method may be implemented in addition or alternatively +to `writable._write()` in stream implementations that are capable of processing multiple chunks of data at once. If implemented, the method will be called with all chunks of data currently buffered in the write queue. |