* Sets the timer's start time to the current time, and reschedules the timer * to call its callback at the previously specified duration adjusted to the * current time. * Using this on a timer that has already called its callback will reactivate * the timer. * * @returns {void}
()
| 284 | * @returns {void} |
| 285 | */ |
| 286 | refresh () { |
| 287 | // In the special case that the timer is not in the list of active timers, |
| 288 | // add it back to the array to be processed in the next tick by the onTick |
| 289 | // function. |
| 290 | if (this._state === NOT_IN_LIST) { |
| 291 | fastTimers.push(this) |
| 292 | } |
| 293 | |
| 294 | // If the timer is the only active timer, refresh the fastNowTimeout for |
| 295 | // better resolution. |
| 296 | if (!fastNowTimeout || fastTimers.length === 1) { |
| 297 | refreshTimeout() |
| 298 | } |
| 299 | |
| 300 | // Setting the state to PENDING will cause the timer to be reset in the |
| 301 | // next tick by the onTick function. |
| 302 | this._state = PENDING |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * The `clear` method cancels the timer, preventing it from executing. |
no test coverage detected