1 | declare module 'timers' {
|
2 | import { Abortable } from 'events';
|
3 | import { setTimeout as setTimeoutPromise, setImmediate as setImmediatePromise, setInterval as setIntervalPromise } from 'timers/promises';
|
4 |
|
5 | interface TimerOptions extends Abortable {
|
6 | |
7 |
|
8 |
|
9 |
|
10 |
|
11 | ref?: boolean | undefined;
|
12 | }
|
13 |
|
14 | let setTimeout: typeof global.setTimeout;
|
15 | let clearTimeout: typeof global.clearTimeout;
|
16 | let setInterval: typeof global.setInterval;
|
17 | let clearInterval: typeof global.clearInterval;
|
18 | let setImmediate: typeof global.setImmediate;
|
19 | let clearImmediate: typeof global.clearImmediate;
|
20 |
|
21 | global {
|
22 | namespace NodeJS {
|
23 |
|
24 | interface Timer extends RefCounted {
|
25 | hasRef(): boolean;
|
26 | refresh(): this;
|
27 | [Symbol.toPrimitive](): number;
|
28 | }
|
29 |
|
30 | interface Immediate extends RefCounted {
|
31 | hasRef(): boolean;
|
32 | _onImmediate: Function;
|
33 | }
|
34 |
|
35 | interface Timeout extends Timer {
|
36 | hasRef(): boolean;
|
37 | refresh(): this;
|
38 | [Symbol.toPrimitive](): number;
|
39 | }
|
40 | }
|
41 |
|
42 | function setTimeout<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
|
43 |
|
44 |
|
45 | function setTimeout(callback: (args: void) => void): NodeJS.Timeout;
|
46 | namespace setTimeout {
|
47 | const __promisify__: typeof setTimeoutPromise;
|
48 | }
|
49 | function clearTimeout(timeoutId: NodeJS.Timeout): void;
|
50 |
|
51 | function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
|
52 |
|
53 |
|
54 | function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
|
55 | namespace setInterval {
|
56 | const __promisify__: typeof setIntervalPromise;
|
57 | }
|
58 | function clearInterval(intervalId: NodeJS.Timeout): void;
|
59 |
|
60 | function setImmediate<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate;
|
61 |
|
62 |
|
63 | function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
|
64 | namespace setImmediate {
|
65 | const __promisify__: typeof setImmediatePromise;
|
66 | }
|
67 | function clearImmediate(immediateId: NodeJS.Immediate): void;
|
68 |
|
69 | function queueMicrotask(callback: () => void): void;
|
70 | }
|
71 | }
|
72 |
|
73 | declare module 'node:timers' {
|
74 | export * from 'timers';
|
75 | }
|
76 |
|
77 | declare module 'timers/promises' {
|
78 | import { TimerOptions } from 'timers';
|
79 |
|
80 | |
81 |
|
82 |
|
83 |
|
84 | function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
85 |
|
86 | |
87 |
|
88 |
|
89 | function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
90 |
|
91 | |
92 |
|
93 |
|
94 |
|
95 |
|
96 | function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
|
97 | }
|
98 |
|
99 | declare module 'node:timers/promises' {
|
100 | export * from 'timers/promises';
|
101 | }
|