diff --git a/lib/internal/timers/promises.js b/lib/internal/timers/promises.js index 55d554bb838e95..c46b98f798ccaf 100644 --- a/lib/internal/timers/promises.js +++ b/lib/internal/timers/promises.js @@ -49,10 +49,7 @@ function setTimeout(after, value, options = {}) { 'boolean', ref)); } - // TODO(@jasnell): If a decision is made that this cannot be backported - // to 12.x, then this can be converted to use optional chaining to - // simplify the check. - if (signal && signal.aborted) { + if (signal?.aborted) { return PromiseReject(new AbortError()); } let oncancel; @@ -94,10 +91,7 @@ function setImmediate(value, options = {}) { 'boolean', ref)); } - // TODO(@jasnell): If a decision is made that this cannot be backported - // to 12.x, then this can be converted to use optional chaining to - // simplify the check. - if (signal && signal.aborted) { + if (signal?.aborted) { return PromiseReject(new AbortError()); } let oncancel; diff --git a/lib/timers.js b/lib/timers.js index fdeb92b1c1b5d3..dddbea495736be 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, { }); function clearTimeout(timer) { - if (timer && timer._onTimeout) { + if (timer?._onTimeout) { timer._onTimeout = null; unenroll(timer); return;