Skip to content

Commit a0261d2

Browse files
mcollinaBethGriggs
authored andcommitted
Revert "timers: refactor to use optional chaining"
This reverts commit d8f535b. PR-URL: #38245 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 4afcd55 commit a0261d2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎lib/timers.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify,{
171171
});
172172

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

‎lib/timers/promises.js‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ function setTimeout(after, value, options ={}){
5353
'boolean',
5454
ref));
5555
}
56-
if(signal?.aborted){
56+
// TODO(@jasnell): If a decision is made that this cannot be backported
57+
// to 12.x, then this can be converted to use optional chaining to
58+
// simplify the check.
59+
if(signal&&signal.aborted){
5760
returnPromiseReject(newAbortError());
5861
}
5962
letoncancel;
@@ -95,7 +98,10 @@ function setImmediate(value, options ={}){
9598
'boolean',
9699
ref));
97100
}
98-
if(signal?.aborted){
101+
// TODO(@jasnell): If a decision is made that this cannot be backported
102+
// to 12.x, then this can be converted to use optional chaining to
103+
// simplify the check.
104+
if(signal&&signal.aborted){
99105
returnPromiseReject(newAbortError());
100106
}
101107
letoncancel;

0 commit comments

Comments
(0)