{ } qjs-modules

timers

Source: lib/timers.js (pure JS)

Node-style interval timers, layered on os.setTimeout. Importing the module also installs setTimeout, clearTimeout, setInterval and clearInterval on globalThis, without replacing any that already exist.

Exports

ExportArgsKindDescription
setTimeout—re-exportRe-exported from os.
clearTimeout—re-exportRe-exported from os.
setInterval(fn, t)2functionRepeatedly invokes fn every t ms; returns an id.
clearInterval(id)1functionCancels an interval started by setInterval.
setImmediate(fn, ...args)1+functionRuns fn after the current tick (a zero-delay timer); returns a handle.
clearImmediate(handle)1functionCancels a pending setImmediate.

setImmediate and clearImmediate are installed on globalThis as well. The promise forms are in timersPromises (timers/promises).

Export list

Generated by utilities/doc-api.js from the timers dump of utilities/api-surface.sh: 30 members. Edit the text above this block, not the block.

Functions: clearImmediate(), clearInterval(), clearTimeout(), setImmediate(), setInterval(), setTimeout()

Immediate

class, constructible

  • methods: hasRef(), ref(), undefined(), unref()

Timeout

class, constructible

  • methods: close(), hasRef(), ref(), refresh(), undefined(), unref(), [Symbol.toPrimitive]()

default

object

  • static methods: Immediate(), Timeout(), clearImmediate(), clearInterval(), clearTimeout(), setImmediate(), setInterval(), setTimeout()