Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8e8b16f

Browse filesBrowse files
Lxxyxdanielleadams
authored andcommitted
timers: refactor to use optional chaining
PR-URL: #36767 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 24246a2 commit 8e8b16f
Copy full SHA for 8e8b16f

File tree

Expand file treeCollapse file tree

2 files changed

+3
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+3
-9
lines changed
Open diff view settings
Collapse file

‎lib/timers.js‎

Copy file name to clipboardExpand all lines: lib/timers.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, {
171171
});
172172

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

‎lib/timers/promises.js‎

Copy file name to clipboardExpand all lines: lib/timers/promises.js
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ function setTimeout(after, value, options = {}) {
4949
'boolean',
5050
ref));
5151
}
52-
// TODO(@jasnell): If a decision is made that this cannot be backported
53-
// to 12.x, then this can be converted to use optional chaining to
54-
// simplify the check.
55-
if (signal && signal.aborted) {
52+
if (signal?.aborted) {
5653
return PromiseReject(new AbortError());
5754
}
5855
let oncancel;
@@ -94,10 +91,7 @@ function setImmediate(value, options = {}) {
9491
'boolean',
9592
ref));
9693
}
97-
// TODO(@jasnell): If a decision is made that this cannot be backported
98-
// to 12.x, then this can be converted to use optional chaining to
99-
// simplify the check.
100-
if (signal && signal.aborted) {
94+
if (signal?.aborted) {
10195
return PromiseReject(new AbortError());
10296
}
10397
let oncancel;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.