This object is created internally and is returned from setTimeout()
and setInterval()
.
It can be passed to either clearTimeout()
or clearInterval()
in order to cancel the scheduled actions.
Methods
ref():Timeout
When called, the active Timeout
object will not require the Node.js event loop to remain active.
If there is no other activity keeping the event loop running, the process may exit before the Timeout
object's
callback is invoked. Calling timeout.unref()
multiple times will have no effect.
Calling timeout.unref()
creates an internal timer that will wake the Node.js event loop.
Creating too many of these can adversely impact performance of the Node.js application.
refresh():Timeout
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. This is useful for refreshing a timer without allocating a new JavaScript object.
Using this on a timer that has already called its callback will reactivate the timer.
unref():Timeout
When called, the active Timeout
object will not require the Node.js event loop to remain active.
If there is no other activity keeping the event loop running, the process may exit before the Timeout
object's
callback is invoked. Calling timeout.unref()
multiple times will have no effect.
Calling timeout.unref()
creates an internal timer that will wake the Node.js event loop.
Creating too many of these can adversely impact performance of the Node.js application.