Skip to content

Commit

Permalink
stream: refactor use es2020 statement
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xtx1130 authored and juanarbol committed Oct 3, 2022
1 parent 7ec03ac commit 6cdf9eb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/internal/streams/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function destroy(err, cb) {
// With duplex streams we use the writable side for state.
const s = w || r;

if ((w && w.destroyed) || (r && r.destroyed)) {
if (w?.destroyed || r?.destroyed) {
if (typeof cb === 'function') {
cb();
}
Expand Down Expand Up @@ -134,7 +134,7 @@ function emitCloseNT(self) {
r.closeEmitted = true;
}

if ((w && w.emitClose) || (r && r.emitClose)) {
if (w?.emitClose || r?.emitClose) {
self.emit('close');
}
}
Expand All @@ -143,7 +143,7 @@ function emitErrorNT(self, err) {
const r = self._readableState;
const w = self._writableState;

if ((w && w.errorEmitted) || (r && r.errorEmitted)) {
if (w?.errorEmitted || r?.errorEmitted) {
return;
}

Expand Down Expand Up @@ -198,11 +198,11 @@ function errorOrDestroy(stream, err, sync) {
const r = stream._readableState;
const w = stream._writableState;

if ((w && w.destroyed) || (r && r.destroyed)) {
if (w?.destroyed || r?.destroyed) {
return this;
}

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

function isRequest(stream) {
return stream && stream.setHeader && typeof stream.abort === 'function';
return stream?.setHeader && typeof stream.abort === 'function';
}

// Normalize destroy for legacy.
Expand Down

0 comments on commit 6cdf9eb

Please sign in to comment.