Skip to content

Commit

Permalink
timers: refactor to use optional chaining
Browse files Browse the repository at this point in the history
PR-URL: #36767
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Lxxyx authored and danielleadams committed Jan 12, 2021
1 parent 24246a2 commit 8e8b16f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 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 && timer._onTimeout) {
if (timer?._onTimeout) {
timer._onTimeout = null;
unenroll(timer);
return;
Expand Down
10 changes: 2 additions & 8 deletions lib/timers/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8e8b16f

Please sign in to comment.