Timers

The global functions setTimeout, setInterval, clearTimeout and clearInterval. Server scripts also have setImmediate and clearImmediate, which bundled Node packages expect. A timer belongs to the resource that set it, and all are cleared when it stops. A timer handler that throws makes the resource fail.

timers.setTimeout()

setTimeout(handler, delay, ...args)

Runs a handler once after a delay.

timers.setInterval()

setInterval(handler, delay, ...args)

Runs a handler repeatedly, every `delay` milliseconds.

timers.clearTimeout()

clearTimeout(timer)

Cancels a timeout.

timers.clearInterval()

clearInterval(timer)

Stops an interval.

timers.setImmediate()

setImmediate(handler, ...args)

Server scripts only. Runs a handler once, right after the current work and before any timer, like Node's setImmediate.

timers.clearImmediate()

clearImmediate(immediate)

Server scripts only. Cancels a setImmediate that has not run.