node:timers

#Import

import timers from "nstdlib/node/timers";

Note

Behaves like Node.js. Scheduled on the host setTimeout. ref()/unref() reach the host timer handle, and process.nextTick is installed only into a realm that has none. A host that already has one keeps it.

#Support

node:timers. nstd: some support; Node test suite 84.8% passing. Browser: works; export coverage 100%; Node test suite 83.1% passing.

  • nstd: 50/59 of Node's own eligible tests pass under nstd.
  • Browser: Loads with a minimal process object. 7 of Node's 7 exports are available. 1 of 1 behavior checks match Node.js.

#Exports (7)

Every name Node.js exports from this module, and what you get when you read it, as a named import or as a property of the default import:

  • ✅ A value, both ways. An export that throws an error naming the missing feature also counts.
  • ⚠️ A value one way, undefined the other.
  • ❔ undefined both ways.
  • ❌ Not exported at all.
  • – Not measured.
ExportNode.jsBrowser
clearImmediate✅✅
clearInterval✅✅
clearTimeout✅✅
promises✅✅
setImmediate✅✅
setInterval✅✅
setTimeout✅✅

#Diagnostics

nstdlib running inside Node.js. This isn't an environment it's meant for, so it isn't shown above, but it tells a library problem from an environment one:

  • coverage: 7/7 of the host's export names answer inside host node. Behaviour verified against the host builtin. Scheduled on the host setTimeout. ref()/unref() reach the host timer handle, and process.nextTick is installed only into a realm that has none. A host that already has one keeps it.
  • smoke: Imports in a clean child process.
  • vitest: Test/runtime/timers.test.ts: 46/46 assertions pass.
  • node-suite: 52/59 of Node's own eligible tests pass with ./dist inside host node. A failure there and in the page is the library's, one only in the page is the engine's.