push
travis-ci
858 of 997 branches covered (86.06%)
27 of 27 new or added lines in 1 file covered. (100.0%)
5009 of 5126 relevant lines covered (97.72%)
10857.3 hits per line
1 |
var Timers = require('timers'); |
5,394✔ |
2 |
|
|
3 |
module.exports = Timer; |
5,394✔ |
4 |
function Timer(object) { |
|
5 |
this._object = object;
|
34,684✔ |
6 |
this._timeout = null; |
34,684✔ |
7 |
} |
|
8 |
|
|
9 |
Timer.prototype.active = function active() { |
5,394✔ |
10 |
if (this._timeout) { |
|
11 |
if (this._timeout.refresh) { |
|
12 |
this._timeout.refresh();
|
× |
13 |
} else {
|
|
14 |
Timers.active(this._timeout);
|
10,353✔ |
15 |
} |
|
16 |
} |
|
17 |
}; |
|
18 |
|
|
19 |
Timer.prototype.start = function start(msecs) { |
5,394✔ |
20 |
this.stop();
|
6,438✔ |
21 |
this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs); |
6,438✔ |
22 |
}; |
|
23 |
|
|
24 |
Timer.prototype.stop = function stop() { |
5,394✔ |
25 |
if (this._timeout) { |
|
26 |
Timers.clearTimeout(this._timeout);
|
6,438✔ |
27 |
this._timeout = null; |
6,438✔ |
28 |
} |
|
29 |
}; |
|
30 |
|
|
31 |
Timer.prototype._onTimeout = function _onTimeout() { |
5,394✔ |
32 |
return this._object._onTimeout(); |
203✔ |
33 |
}; |