Skip to content

Commit 8e8b16f

Browse files
Lxxyxdanielleadams
authored andcommitted
timers: refactor to use optional chaining
PR-URL: #36767 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 24246a2 commit 8e8b16f

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

lib/timers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, {
171171
});
172172

173173
function clearTimeout(timer) {
174-
if (timer && timer._onTimeout) {
174+
if (timer?._onTimeout) {
175175
timer._onTimeout = null;
176176
unenroll(timer);
177177
return;

lib/timers/promises.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ function setTimeout(after, value, options = {}) {
4949
'boolean',
5050
ref));
5151
}
52-
// TODO(@jasnell): If a decision is made that this cannot be backported
53-
// to 12.x, then this can be converted to use optional chaining to
54-
// simplify the check.
55-
if (signal && signal.aborted) {
52+
if (signal?.aborted) {
5653
return PromiseReject(new AbortError());
5754
}
5855
let oncancel;
@@ -94,10 +91,7 @@ function setImmediate(value, options = {}) {
9491
'boolean',
9592
ref));
9693
}
97-
// TODO(@jasnell): If a decision is made that this cannot be backported
98-
// to 12.x, then this can be converted to use optional chaining to
99-
// simplify the check.
100-
if (signal && signal.aborted) {
94+
if (signal?.aborted) {
10195
return PromiseReject(new AbortError());
10296
}
10397
let oncancel;

0 commit comments

Comments
 (0)