From 5bfe1adc4f8b40b9b96aed51c145de82f555330d Mon Sep 17 00:00:00 2001 From: Jorge Chamorro Bieling Date: Mon, 11 Apr 2011 13:56:50 +0200 Subject: [PATCH] the timer's ms arg ought to be an integer Timers do strange things when it isn't. --- lib/timers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/timers.js b/lib/timers.js index d6fede1fa04..86738047a72 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -148,6 +148,7 @@ exports.active = function(item) { exports.setTimeout = function(callback, after) { var timer; + after = Math.floor(after); if (after <= 0) { // Use the slow case for after == 0 timer = new Timer(); @@ -201,7 +202,7 @@ exports.clearTimeout = function(timer) { exports.setInterval = function(callback, repeat) { var timer = new Timer(); - + repeat = Math.floor(repeat); if (arguments.length > 2) { var args = Array.prototype.slice.call(arguments, 2); timer.callback = function() {