@@ -3789,7 +3789,7 @@ changes:
37893789
37903790<!-- eslint-disable no-useless-constructor -->
37913791
3792- ``` js
3792+ ``` cjs
37933793const { Writable } = require (' node:stream' );
37943794
37953795class MyWritable extends Writable {
@@ -3801,18 +3801,18 @@ class MyWritable extends Writable {
38013801}
38023802```
38033803
3804- Or, when using pre-ES6 style constructors:
3804+ <!-- eslint-disable no-useless-constructor -->
38053805
3806- ``` js
3807- const { Writable } = require (' node:stream' );
3808- const util = require (' node:util' );
3806+ ``` mjs
3807+ import { Writable } from ' node:stream' ;
38093808
3810- function MyWritable (options ) {
3811- if (! (this instanceof MyWritable))
3812- return new MyWritable (options);
3813- Writable .call (this , options);
3809+ class MyWritable extends Writable {
3810+ constructor (options ) {
3811+ // Calls the stream.Writable() constructor.
3812+ super (options);
3813+ // ...
3814+ }
38143815}
3815- util .inherits (MyWritable, Writable);
38163816```
38173817
38183818Or, using the simplified constructor approach:
@@ -4162,20 +4162,6 @@ class MyReadable extends Readable {
41624162}
41634163` ` `
41644164
4165- Or, when using pre-ES6 style constructors:
4166-
4167- ` ` ` js
4168- const { Readable } = require (' node:stream' );
4169- const util = require (' node:util' );
4170-
4171- function MyReadable (options ) {
4172- if (! (this instanceof MyReadable))
4173- return new MyReadable (options);
4174- Readable .call (this , options);
4175- }
4176- util .inherits (MyReadable, Readable);
4177- ` ` `
4178-
41794165Or, using the simplified constructor approach:
41804166
41814167` ` ` js
@@ -4494,7 +4480,7 @@ changes:
44944480
44954481<!-- eslint-disable no-useless-constructor -->
44964482
4497- ` ` ` js
4483+ ` ` ` cjs
44984484const { Duplex } = require (' node:stream' );
44994485
45004486class MyDuplex extends Duplex {
@@ -4505,18 +4491,17 @@ class MyDuplex extends Duplex {
45054491}
45064492` ` `
45074493
4508- Or, when using pre-ES6 style constructors:
4494+ <!-- eslint-disable no-useless-constructor -->
45094495
4510- ` ` ` js
4511- const { Duplex } = require (' node:stream' );
4512- const util = require (' node:util' );
4496+ ` ` ` mjs
4497+ import { Duplex } from ' node:stream' ;
45134498
4514- function MyDuplex (options ) {
4515- if (! (this instanceof MyDuplex))
4516- return new MyDuplex (options);
4517- Duplex .call (this , options);
4499+ class MyDuplex extends Duplex {
4500+ constructor (options ) {
4501+ super (options);
4502+ // ...
4503+ }
45184504}
4519- util .inherits (MyDuplex, Duplex);
45204505` ` `
45214506
45224507Or, using the simplified constructor approach:
@@ -4691,7 +4676,7 @@ output on the `Readable` side is not consumed.
46914676
46924677<!-- eslint-disable no-useless-constructor -->
46934678
4694- ` ` ` js
4679+ ` ` ` cjs
46954680const { Transform } = require (' node:stream' );
46964681
46974682class MyTransform extends Transform {
@@ -4702,18 +4687,17 @@ class MyTransform extends Transform {
47024687}
47034688` ` `
47044689
4705- Or, when using pre-ES6 style constructors:
4690+ <!-- eslint-disable no-useless-constructor -->
47064691
4707- ` ` ` js
4708- const { Transform } = require (' node:stream' );
4709- const util = require (' node:util' );
4692+ ` ` ` mjs
4693+ import { Transform } from ' node:stream' ;
47104694
4711- function MyTransform (options ) {
4712- if (! (this instanceof MyTransform))
4713- return new MyTransform (options);
4714- Transform .call (this , options);
4695+ class MyTransform extends Transform {
4696+ constructor (options ) {
4697+ super (options);
4698+ // ...
4699+ }
47154700}
4716- util .inherits (MyTransform, Transform);
47174701` ` `
47184702
47194703Or, using the simplified constructor approach:
0 commit comments