From d398b8f02be73f2846a62080ebfbd65ede0c7d50 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 21 Sep 2019 01:29:41 +0200 Subject: 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 Reviewed-By: Minwoo Jung Reviewed-By: Luigi Pinca --- doc/api/stream.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'doc') diff --git a/doc/api/stream.md b/doc/api/stream.md index b6093e8917..bf7ee7251a 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1687,8 +1687,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]) * `chunk` {Buffer|string|any} The `Buffer` to be written, converted from the `string` passed to [`stream.write()`][stream-write]. If the stream's @@ -1790,7 +1796,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 @@ -1833,8 +1840,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. -- cgit v1.2.3