Skip to content

Commit

Permalink
Revert "timers: refactor to use optional chaining"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mcollina authored and BethGriggs committed Apr 19, 2021
1 parent 4afcd55 commit a0261d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, {
});

function clearTimeout(timer) {
if (timer?._onTimeout) {
if (timer && timer._onTimeout) {
timer._onTimeout = null;
unenroll(timer);
return;
Expand Down
10 changes: 8 additions & 2 deletions lib/timers/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ function setTimeout(after, value, options = {}) {
'boolean',
ref));
}
if (signal?.aborted) {
// 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) {
return PromiseReject(new AbortError());
}
let oncancel;
Expand Down Expand Up @@ -95,7 +98,10 @@ function setImmediate(value, options = {}) {
'boolean',
ref));
}
if (signal?.aborted) {
// 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) {
return PromiseReject(new AbortError());
}
let oncancel;
Expand Down

0 comments on commit a0261d2

Please sign in to comment.