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'); diff --git a/lib/stopwatch.js b/lib/stopwatch.js index 27683ee..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); @@ -22,12 +21,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" } }