()
| 69 | } |
| 70 | |
| 71 | _trigger() { |
| 72 | const now = Date.now(), |
| 73 | remaining = this._nextTime - now; |
| 74 | /* istanbul ignore if */ |
| 75 | if (remaining > 0) { |
| 76 | // It's possible (it caused tests to fail) to have the timeout trigger |
| 77 | // before the scheduled time. |
| 78 | this._timer = setTimeout(this._boundTrigger, remaining); |
| 79 | return; |
| 80 | } |
| 81 | this._schedule(now + this._maxDelay); |
| 82 | this.emit('trigger'); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | module.exports = EagerTimer; |