diff --git a/doc/api/stream.md b/doc/api/stream.md index c8ccd06bec79bb..936a81cc6e4219 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1938,6 +1938,9 @@ method. #### `new stream.Writable([options])` ```js @@ -2028,6 +2032,27 @@ const myWritable = new Writable({ }); ``` +Calling `abort` on the `AbortController` corresponding to the passed +`AbortSignal` will behave the same way as calling `.destroy(new AbortError())` +on the writeable stream. + +```js +const { Writable } = require('stream'); + +const controller = new AbortController(); +const myWritable = new Writable({ + write(chunk, encoding, callback) { + // ... + }, + writev(chunks, callback) { + // ... + }, + signal: controller.signal +}); +// Later, abort the operation closing the stream +controller.abort(); + +``` #### `writable._construct(callback)` ```js @@ -2346,6 +2375,23 @@ const myReadable = new Readable({ }); ``` +Calling `abort` on the `AbortController` corresponding to the passed +`AbortSignal` will behave the same way as calling `.destroy(new AbortError())` +on the readable created. + +```js +const fs = require('fs'); +const controller = new AbortController(); +const read = new Readable({ + read(size) { + // ... + }, + signal: controller.signal +}); +// Later, abort the operation closing the stream +controller.abort(); +``` + #### `readable._construct(callback)`