diff --git a/doc/api/stream.md b/doc/api/stream.md index 692861e71e7513..ef52f2d27a2570 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -45,8 +45,11 @@ There are four fundamental stream types within Node.js: is written and read (for example, [`zlib.createDeflate()`][]). Additionally, this module includes the utility functions -[`stream.pipeline()`][], [`stream.finished()`][], [`stream.Readable.from()`][] -and [`stream.addAbortSignal()`][]. +[`stream.duplexPair()`][], +[`stream.pipeline()`][], +[`stream.finished()`][] +[`stream.Readable.from()`][], and +[`stream.addAbortSignal()`][]. ### Streams Promises API @@ -2700,6 +2703,30 @@ unless `emitClose` is set in false. Once `destroy()` has been called, any further calls will be a no-op and no further errors except from `_destroy()` may be emitted as `'error'`. +#### `stream.duplexPair([options])` + + + +* `options` {Object} A value to pass to both [`Duplex`][] constructors, + to set options such as buffering. +* Returns: {Array} of two [`Duplex`][] instances. + +The utility function `duplexPair` returns an Array with two items, +each being a `Duplex` stream connected to the other side: + +```js +const [ sideA, sideB ] = duplexPair(); +``` + +Whatever is written to one stream is made readable on the other. It provides +behavior analogous to a network connection, where the data written by the client +becomes readable by the server, and vice-versa. + +The Duplex streams are symmetrical; one or the other may be used without any +difference in behavior. + ### `stream.finished(stream[, options], callback)`