Skip to content

Commit

Permalink
timers: refactor to use optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxxyx committed Jan 8, 2021
1 parent 15e47ed commit 738759a
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 738759a

Please sign in to comment.