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