Skip to content

Commit 776b73b

Browse files
committed
timers: cleanup interval handling
Uses `null` as the false-y value for `_repeat` as like other properties. Removes un-reachable statement in setInterval’s `wrapper()`. PR-URL: nodejs#1272 Reviewed-by: Trevor Norris <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent caf0b36 commit 776b73b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/timers.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ exports.setInterval = function(callback, repeat) {
272272

273273
function wrapper() {
274274
timer._repeat.call(this);
275-
// If callback called clearInterval().
276-
if (timer._repeat === null) return;
277275
// If timer is unref'd (or was - it's permanently removed from the list.)
278276
if (this._handle) {
279277
this._handle.start(repeat, 0);
@@ -287,7 +285,7 @@ exports.setInterval = function(callback, repeat) {
287285

288286
exports.clearInterval = function(timer) {
289287
if (timer && timer._repeat) {
290-
timer._repeat = false;
288+
timer._repeat = null;
291289
clearTimeout(timer);
292290
}
293291
};
@@ -300,7 +298,7 @@ const Timeout = function(after) {
300298
this._idleNext = this;
301299
this._idleStart = null;
302300
this._onTimeout = null;
303-
this._repeat = false;
301+
this._repeat = null;
304302
};
305303

306304
Timeout.prototype.unref = function() {

0 commit comments

Comments
 (0)