Skip to main content

Module timers

Module timers 

Source
Expand description

Node timers and timers/promises modules.

require('timers') re-exports the SAME timer primitives that already exist as globals (setTimeout/setInterval/setImmediate + their clear*), so this module owns NO queue of its own: every method delegates straight to builtins::call_builtin_function, which schedules onto the single shared JsHost.macrotasks queue. timers.foo(...) is therefore observably identical to the global foo(...).

require('timers/promises') returns the promise-based variants: setTimeout and setImmediate resolve a Promise after the delay instead of invoking a callback. They are built on the SAME two substrates — the global timer scheduler and the @@presolve:<id> native-continuation convention that builtins.rs uses for Promise resolve reactions — so no new mechanism is introduced: a timer is scheduled whose callback is the promise’s resolver.

Constants§

METHODS
Methods of the timers module. Each name is also a global; call forwards to the identical global implementation, so there is one timer queue, not two.
PROMISES_METHODS
Methods of the timers/promises module (its namespace name carries no ., so stdlib::is_method treats the whole "timers/promises" as the namespace).

Functions§

call
Dispatch a timers.<method> call by delegating to the matching global timer builtin. clearImmediate has no distinct global handler (the loop cancels by id regardless of kind), so it maps to clearTimeout.
promises_call
Dispatch a timers/promises.<method> call.