diff --git a/doc/api/stream.md b/doc/api/stream.md index 5fd73cb2fb35d9..d26774dc5f1183 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1645,13 +1645,24 @@ parent class constructor: const { Writable } = require('stream'); class MyWritable extends Writable { - constructor(options) { - super(options); + constructor({ highWaterMark, ...options }) { + super({ + highWaterMark, + autoDestroy: false, + emitClose: true + }); // ... } } ``` +When extending streams it is important to keep in mind what options the user +can and should provide before forwarding these to the base constructor. For +example if the implementation makes assumptions in regard to e.g. the +`autoDestroy` and `emitClose` options, it becomes important to not allow the +user to override these. It is therefore recommend to be explicit about what +options are forwarded instead of implicitly forwarding all options. + The new stream class must then implement one or more specific methods, depending on the type of stream being created, as detailed in the chart below: