travis-ci
856 of 1007 branches covered (85.0%)
30 of 30 new or added lines in 5 files covered. (100.0%)
5007 of 5139 relevant lines covered (97.43%)
4449.94 hits per line
1 |
var Timers = require('timers'); |
3,700✔ |
2 |
|
|
3 |
module.exports = Timer; |
3,700✔ |
4 |
function Timer(object) { |
|
5 |
this._object = object;
|
11,894✔ |
6 |
this._timeout = null; |
11,894✔ |
7 |
} |
|
8 |
|
|
9 |
Timer.prototype.active = function active() { |
3,700✔ |
10 |
if (this._timeout) { |
|
11 |
if (this._timeout.refresh) { |
|
12 |
this._timeout.refresh();
|
356✔ |
13 |
} else {
|
|
14 |
Timers.active(this._timeout);
|
6,755✔ |
15 |
} |
|
16 |
} |
|
17 |
}; |
|
18 |
|
|
19 |
Timer.prototype.start = function start(msecs) { |
3,700✔ |
20 |
this.stop();
|
4,414✔ |
21 |
this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs); |
4,414✔ |
22 |
}; |
|
23 |
|
|
24 |
Timer.prototype.stop = function stop() { |
3,700✔ |
25 |
if (this._timeout) { |
|
26 |
Timers.clearTimeout(this._timeout);
|
4,394✔ |
27 |
this._timeout = null; |
4,394✔ |
28 |
} |
|
29 |
}; |
|
30 |
|
|
31 |
Timer.prototype._onTimeout = function _onTimeout() { |
3,700✔ |
32 |
return this._object._onTimeout(); |
140✔ |
33 |
}; |