Skip to content

Commit ffb1c85

Browse files
xtx1130juanarbol
authored andcommitted
stream: refactor use es2020 statement
PR-URL: #44533 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Erick Wendel <[email protected]>
1 parent eaf2ffc commit ffb1c85

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/internal/streams/destroy.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function destroy(err, cb) {
3535
// With duplex streams we use the writable side for state.
3636
const s = w || r;
3737

38-
if ((w && w.destroyed) || (r && r.destroyed)) {
38+
if (w?.destroyed || r?.destroyed) {
3939
if (typeof cb === 'function') {
4040
cb();
4141
}
@@ -134,7 +134,7 @@ function emitCloseNT(self) {
134134
r.closeEmitted = true;
135135
}
136136

137-
if ((w && w.emitClose) || (r && r.emitClose)) {
137+
if (w?.emitClose || r?.emitClose) {
138138
self.emit('close');
139139
}
140140
}
@@ -143,7 +143,7 @@ function emitErrorNT(self, err) {
143143
const r = self._readableState;
144144
const w = self._writableState;
145145

146-
if ((w && w.errorEmitted) || (r && r.errorEmitted)) {
146+
if (w?.errorEmitted || r?.errorEmitted) {
147147
return;
148148
}
149149

@@ -198,11 +198,11 @@ function errorOrDestroy(stream, err, sync) {
198198
const r = stream._readableState;
199199
const w = stream._writableState;
200200

201-
if ((w && w.destroyed) || (r && r.destroyed)) {
201+
if (w?.destroyed || r?.destroyed) {
202202
return this;
203203
}
204204

205-
if ((r && r.autoDestroy) || (w && w.autoDestroy))
205+
if (r?.autoDestroy || w?.autoDestroy)
206206
stream.destroy(err);
207207
else if (err) {
208208
// Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364
@@ -306,7 +306,7 @@ function emitConstructNT(stream) {
306306
}
307307

308308
function isRequest(stream) {
309-
return stream && stream.setHeader && typeof stream.abort === 'function';
309+
return stream?.setHeader && typeof stream.abort === 'function';
310310
}
311311

312312
// Normalize destroy for legacy.

0 commit comments

Comments
 (0)