Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream,benchmark: refactor use es2020 statements #44533

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/internal/streams/destroy.js
Expand Up @@ -42,7 +42,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 @@ -128,7 +128,7 @@ function emitCloseNT(self) {
r.closeEmitted = true;
}

if ((w && w.emitClose) || (r && r.emitClose)) {
if (w?.emitClose || r?.emitClose) {
self.emit('close');
}
}
Expand All @@ -137,7 +137,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 @@ -192,11 +192,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 @@ -283,7 +283,7 @@ function emitConstructNT(stream) {
}

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

function emitCloseLegacy(stream) {
Expand Down