travis-ci
856 of 993 branches covered (86.2%)
4999 of 5114 relevant lines covered (97.75%)
7389.06 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;
|
23,900✔ |
6 |
this._timeout = null; |
23,900✔ |
7 |
} |
|
8 |
|
|
9 |
Timer.prototype.active = function active() { |
3,700✔ |
10 |
if (this._timeout) { |
|
11 |
if (this._timeout.refresh) { |
|
12 |
this._timeout.refresh();
|
357✔ |
13 |
} else {
|
|
14 |
Timers.active(this._timeout);
|
6,783✔ |
15 |
} |
|
16 |
} |
|
17 |
}; |
|
18 |
|
|
19 |
Timer.prototype.start = function start(msecs) { |
3,700✔ |
20 |
this.stop();
|
4,440✔ |
21 |
this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs); |
4,440✔ |
22 |
}; |
|
23 |
|
|
24 |
Timer.prototype.stop = function stop() { |
3,700✔ |
25 |
if (this._timeout) { |
|
26 |
Timers.clearTimeout(this._timeout);
|
4,440✔ |
27 |
this._timeout = null; |
4,440✔ |
28 |
} |
|
29 |
}; |
|
30 |
|
|
31 |
Timer.prototype._onTimeout = function _onTimeout() { |
3,700✔ |
32 |
return this._object._onTimeout(); |
140✔ |
33 |
}; |