From 776b73b24306bac0ce299df4f90b7645d5efca31 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Thu, 26 Mar 2015 11:52:36 -0400 Subject: [PATCH] timers: cleanup interval handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uses `null` as the false-y value for `_repeat` as like other properties. Removes un-reachable statement in setInterval’s `wrapper()`. PR-URL: https://github.com/iojs/io.js/pull/1272 Reviewed-by: Trevor Norris Reviewed-By: Ben Noordhuis --- lib/timers.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index dd39e7b3d9edaf..668d5536c8186c 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -272,8 +272,6 @@ exports.setInterval = function(callback, repeat) { function wrapper() { timer._repeat.call(this); - // If callback called clearInterval(). - if (timer._repeat === null) return; // If timer is unref'd (or was - it's permanently removed from the list.) if (this._handle) { this._handle.start(repeat, 0); @@ -287,7 +285,7 @@ exports.setInterval = function(callback, repeat) { exports.clearInterval = function(timer) { if (timer && timer._repeat) { - timer._repeat = false; + timer._repeat = null; clearTimeout(timer); } }; @@ -300,7 +298,7 @@ const Timeout = function(after) { this._idleNext = this; this._idleStart = null; this._onTimeout = null; - this._repeat = false; + this._repeat = null; }; Timeout.prototype.unref = function() {