Skip to content

Commit 73ad9db

Browse files
xtx1130RafaelGSS
authored andcommitted
stream: refactor use es2020 statement
PR-URL: #44533 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
1 parent 81ea507 commit 73ad9db

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
@@ -42,7 +42,7 @@ function destroy(err, cb) {
4242
// With duplex streams we use the writable side for state.
4343
const s = w || r;
4444

45-
if ((w && w.destroyed) || (r && r.destroyed)) {
45+
if (w?.destroyed || r?.destroyed) {
4646
if (typeof cb === 'function') {
4747
cb();
4848
}
@@ -128,7 +128,7 @@ function emitCloseNT(self) {
128128
r.closeEmitted = true;
129129
}
130130

131-
if ((w && w.emitClose) || (r && r.emitClose)) {
131+
if (w?.emitClose || r?.emitClose) {
132132
self.emit('close');
133133
}
134134
}
@@ -137,7 +137,7 @@ function emitErrorNT(self, err) {
137137
const r = self._readableState;
138138
const w = self._writableState;
139139

140-
if ((w && w.errorEmitted) || (r && r.errorEmitted)) {
140+
if (w?.errorEmitted || r?.errorEmitted) {
141141
return;
142142
}
143143

@@ -192,11 +192,11 @@ function errorOrDestroy(stream, err, sync) {
192192
const r = stream._readableState;
193193
const w = stream._writableState;
194194

195-
if ((w && w.destroyed) || (r && r.destroyed)) {
195+
if (w?.destroyed || r?.destroyed) {
196196
return this;
197197
}
198198

199-
if ((r && r.autoDestroy) || (w && w.autoDestroy))
199+
if (r?.autoDestroy || w?.autoDestroy)
200200
stream.destroy(err);
201201
else if (err) {
202202
// Avoid V8 leak, https://github.com/nodejs/node/pull/34103#issuecomment-652002364
@@ -283,7 +283,7 @@ function emitConstructNT(stream) {
283283
}
284284

285285
function isRequest(stream) {
286-
return stream && stream.setHeader && typeof stream.abort === 'function';
286+
return stream?.setHeader && typeof stream.abort === 'function';
287287
}
288288

289289
function emitCloseLegacy(stream) {

0 commit comments

Comments
 (0)