UNPKG

936 BTypeScriptView Raw
1/**
2 * Schedules a macrotask to run after the current events have been processed.
3 *
4 * Unlike microtasks (scheduled using the Node 0.10+ `process.nextTick` API),
5 * where scheduling additional microtasks inside a microtask will cause them
6 * to be run inside the same microtask checkpoint, any macrotasks scheduled
7 * inside a macrotask will not be executed until the next iteration
8 * of the event loop.
9 *
10 * @param callback The macrotask to schedule.
11 * @param args The arguments to pass to the macrotask callback.
12 *
13 * @return The ID of the macrotask, which can be used to abort
14 * the macrotask with `clearImmediate`.
15 */
16declare function setImmediate<T extends unknown[]>(callback: (...args: T) => void, ...args: T): number;
17
18/**
19 * Aborts the specified macrotask before it's run.
20 *
21 * @param handle The ID of the macrotask to remove from the macrotask queue.
22 */
23declare function clearImmediate(handle: number): void;