From 990a11ff57a3d09e24dd847ea32d8dd62eadc8df Mon Sep 17 00:00:00 2001 From: Aaron Caswell Date: Fri, 6 Dec 2013 14:22:18 -0800 Subject: [PATCH 1/3] Update index.js The index.js bootstrap export pointed to an invalid path :P --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index b21fdb7..b47652d 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/stopwatcher'); +module.exports = require('./lib/stopwatch'); From b80d4c0f67e63408423b9cf2fca848019caba873 Mon Sep 17 00:00:00 2001 From: porkchop Date: Fri, 6 Dec 2013 20:39:35 -0800 Subject: [PATCH 2/3] Made the seconds field represent thge actual current clock tick. Also, I could not get the tests to run without upgrading the should and mocha libs --- lib/stopwatch.js | 5 ++--- package.json | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/stopwatch.js b/lib/stopwatch.js index 27683ee..0c8aa9e 100644 --- a/lib/stopwatch.js +++ b/lib/stopwatch.js @@ -22,12 +22,11 @@ Stopwatch.prototype.start = function() { if (this.started()) { return false; } var self = this; - var currentSeconds = self.seconds; self.timer = setInterval(function () { - self.emit('tick', currentSeconds); + self.emit('tick', self.seconds); - if (--currentSeconds < 0) { + if (--self.seconds < 0) { self.stop(); self.emit('end'); } diff --git a/package.json b/package.json index c7ea505..04dffd5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "dependencies": {}, "devDependencies": { - "mocha" : "0.3.6", - "should" : "0.3.2" + "mocha" : "1.15.1", + "should" : "2.1.1" } } From ae99211b3660079429b8598f874408c519c60a4b Mon Sep 17 00:00:00 2001 From: porkchop Date: Sat, 7 Dec 2013 16:17:40 -0800 Subject: [PATCH 3/3] Made the event emitter inheritance setup lighter so as not to bring in the extra weigtht of the util module. This will make browserified versions of this carry less code to the client --- lib/stopwatch.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/stopwatch.js b/lib/stopwatch.js index 0c8aa9e..dd84d11 100644 --- a/lib/stopwatch.js +++ b/lib/stopwatch.js @@ -1,4 +1,3 @@ -var util = require('util'); var EventEmitter = require('events').EventEmitter; var stopwatches = {}; @@ -11,7 +10,7 @@ function Stopwatch(id, options) { this.timer = null; } -util.inherits(Stopwatch, EventEmitter); +Stopwatch.prototype.__proto__ = EventEmitter.prototype; Stopwatch.prototype.stop = function() { clearInterval(this.timer);