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 <deb2001-github@yahoo.de>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • 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
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
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.