@@ -3722,7 +3722,7 @@ changes:
37223722
37233723<!-- eslint-disable no-useless-constructor -->
37243724
3725- ``` js
3725+ ``` cjs
37263726const { Writable } = require (' node:stream' );
37273727
37283728class MyWritable extends Writable {
@@ -3734,18 +3734,18 @@ class MyWritable extends Writable {
37343734}
37353735```
37363736
3737- Or, when using pre-ES6 style constructors:
3737+ <!-- eslint-disable no-useless-constructor -->
37383738
3739- ``` js
3740- const { Writable } = require (' node:stream' );
3741- const util = require (' node:util' );
3739+ ``` mjs
3740+ import { Writable } from ' node:stream' ;
37423741
3743- function MyWritable (options ) {
3744- if (! (this instanceof MyWritable))
3745- return new MyWritable (options);
3746- Writable .call (this , options);
3742+ class MyWritable extends Writable {
3743+ constructor (options ) {
3744+ // Calls the stream.Writable() constructor.
3745+ super (options);
3746+ // ...
3747+ }
37473748}
3748- util .inherits (MyWritable, Writable);
37493749```
37503750
37513751Or, using the simplified constructor approach:
@@ -4095,20 +4095,6 @@ class MyReadable extends Readable {
40954095}
40964096` ` `
40974097
4098- Or, when using pre-ES6 style constructors:
4099-
4100- ` ` ` js
4101- const { Readable } = require (' node:stream' );
4102- const util = require (' node:util' );
4103-
4104- function MyReadable (options ) {
4105- if (! (this instanceof MyReadable))
4106- return new MyReadable (options);
4107- Readable .call (this , options);
4108- }
4109- util .inherits (MyReadable, Readable);
4110- ` ` `
4111-
41124098Or, using the simplified constructor approach:
41134099
41144100` ` ` js
@@ -4427,7 +4413,7 @@ changes:
44274413
44284414<!-- eslint-disable no-useless-constructor -->
44294415
4430- ` ` ` js
4416+ ` ` ` cjs
44314417const { Duplex } = require (' node:stream' );
44324418
44334419class MyDuplex extends Duplex {
@@ -4438,18 +4424,17 @@ class MyDuplex extends Duplex {
44384424}
44394425` ` `
44404426
4441- Or, when using pre-ES6 style constructors:
4427+ <!-- eslint-disable no-useless-constructor -->
44424428
4443- ` ` ` js
4444- const { Duplex } = require (' node:stream' );
4445- const util = require (' node:util' );
4429+ ` ` ` mjs
4430+ import { Duplex } from ' node:stream' ;
44464431
4447- function MyDuplex (options ) {
4448- if (! (this instanceof MyDuplex))
4449- return new MyDuplex (options);
4450- Duplex .call (this , options);
4432+ class MyDuplex extends Duplex {
4433+ constructor (options ) {
4434+ super (options);
4435+ // ...
4436+ }
44514437}
4452- util .inherits (MyDuplex, Duplex);
44534438` ` `
44544439
44554440Or, using the simplified constructor approach:
@@ -4624,7 +4609,7 @@ output on the `Readable` side is not consumed.
46244609
46254610<!-- eslint-disable no-useless-constructor -->
46264611
4627- ` ` ` js
4612+ ` ` ` cjs
46284613const { Transform } = require (' node:stream' );
46294614
46304615class MyTransform extends Transform {
@@ -4635,18 +4620,17 @@ class MyTransform extends Transform {
46354620}
46364621` ` `
46374622
4638- Or, when using pre-ES6 style constructors:
4623+ <!-- eslint-disable no-useless-constructor -->
46394624
4640- ` ` ` js
4641- const { Transform } = require (' node:stream' );
4642- const util = require (' node:util' );
4625+ ` ` ` mjs
4626+ import { Transform } from ' node:stream' ;
46434627
4644- function MyTransform (options ) {
4645- if (! (this instanceof MyTransform))
4646- return new MyTransform (options);
4647- Transform .call (this , options);
4628+ class MyTransform extends Transform {
4629+ constructor (options ) {
4630+ super (options);
4631+ // ...
4632+ }
46484633}
4649- util .inherits (MyTransform, Transform);
46504634` ` `
46514635
46524636Or, using the simplified constructor approach:
0 commit comments