Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2913d47
commit 55265b8
Showing
6 changed files
with
44 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var Timers = require('timers'); | ||
|
||
module.exports = Timer; | ||
function Timer(object) { | ||
this._object = object; | ||
this._timeout = null; | ||
} | ||
|
||
Timer.prototype.active = function active() { | ||
if (this._timeout) { | ||
if (this._timeout.refresh) { | ||
this._timeout.refresh(); | ||
} else { | ||
Timers.active(this._timeout); | ||
} | ||
} | ||
}; | ||
|
||
Timer.prototype.start = function start(msecs) { | ||
this.stop(); | ||
this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs); | ||
}; | ||
|
||
Timer.prototype.stop = function stop() { | ||
if (this._timeout) { | ||
Timers.clearTimeout(this._timeout); | ||
this._timeout = null; | ||
} | ||
}; | ||
|
||
Timer.prototype._onTimeout = function _onTimeout() { | ||
return this._object._onTimeout(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters