GeezerVison is showing github.com — timers: refactor to use optional chaining · nodejs/node@d8f535b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/timers.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -171,7 +171,7 @@ ObjectDefineProperty(setTimeout, customPromisify, { |
171 | 171 | }); |
172 | 172 |
|
173 | 173 | function clearTimeout(timer) { |
174 | | - if (timer && timer._onTimeout) { |
| 174 | + if (timer?._onTimeout) { |
175 | 175 | timer._onTimeout = null; |
176 | 176 | unenroll(timer); |
177 | 177 | return; |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/timers/promises.js +2-8Lines changed: 2 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,10 +49,7 @@ function setTimeout(after, value, options = {}) { |
49 | 49 | 'boolean', |
50 | 50 | ref)); |
51 | 51 | } |
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) { |
56 | 53 | return PromiseReject(new AbortError()); |
57 | 54 | } |
58 | 55 | let oncancel; |
@@ -94,10 +91,7 @@ function setImmediate(value, options = {}) { |
94 | 91 | 'boolean', |
95 | 92 | ref)); |
96 | 93 | } |
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) { |
101 | 95 | return PromiseReject(new AbortError()); |
102 | 96 | } |
103 | 97 | let oncancel; |
|