Skip to content

Commit

Permalink
timers: simplify clearTimeout & clearInterval
Browse files Browse the repository at this point in the history
Remove unnecessary condition from timeout & interval clearing.

PR-URL: #18579
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
apapirovski committed Feb 8, 2018
1 parent c11cb03 commit 8204b0f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ function rearm(timer, start = TimerWrap.now()) {


const clearTimeout = exports.clearTimeout = function(timer) {
if (timer && (timer[kOnTimeout] || timer._onTimeout)) {
timer[kOnTimeout] = timer._onTimeout = null;
if (timer && timer._onTimeout) {
timer._onTimeout = null;
if (timer instanceof Timeout) {
timer.close(); // for after === 0
} else {
Expand Down

0 comments on commit 8204b0f

Please sign in to comment.