The callback to execute.
Optionaloptions: MicroTaskOptions
Optional per-call fallback options when queueMicrotask is unavailable.
A handler that can be used to cancel or refresh the scheduled callback.
Schedules a callback to run in the microtask queue, passing the provided args to the
callback when it executes.
It uses the native queueMicrotask when available, otherwise falls back to
Promise.resolve().then(...), and if Promise is unavailable it falls back to
scheduleTimeout(..., 0). With the scheduleTimeout fallback the pending callbacks are also run just before the
callback of any timeout or interval created by this library (eg. scheduleTimeout, createTimeout or
scheduleInterval), so like native microtasks they run before a timer which was started before them (and one
which cancels that timer stops its callback), but not before a native setTimeout() / setInterval() callback.
Unlike standard microtasks, this helper returns a cancellable ITimerHandler
so scheduled callbacks can be canceled before execution.
This provides consistent microtask scheduling behavior across all supported runtimes,
including Node.js, browsers, and web workers.
The callback to execute.
The callback arguments to pass when the callback executes.
Optionaloptions: MicroTaskOptions
Optional per-call fallback options when queueMicrotask is unavailable.
A handler that can be used to cancel or refresh the scheduled callback.
Schedules a callback to run in the microtask queue.
It uses the native
queueMicrotaskwhen available, otherwise falls back toPromise.resolve().then(...), and ifPromiseis unavailable it falls back toscheduleTimeout(..., 0). With thescheduleTimeoutfallback the pending callbacks are also run just before the callback of any timeout or interval created by this library (eg. scheduleTimeout, createTimeout or scheduleInterval), so like native microtasks they run before a timer which was started before them (and one which cancels that timer stops its callback), but not before a nativesetTimeout()/setInterval()callback. Unlike standard microtasks, this helper returns a cancellableITimerHandlerso scheduled callbacks can be canceled before execution. This provides consistent microtask scheduling behavior across all supported runtimes, including Node.js, browsers, and web workers.