UNPKG

1.18 kBTypeScriptView Raw
1declare module 'timers' {
2 import { Abortable } from 'events';
3
4 interface TimerOptions extends Abortable {
5 /**
6 * Set to `false` to indicate that the scheduled `Timeout`
7 * should not require the Node.js event loop to remain active.
8 * @default true
9 */
10 ref?: boolean;
11 }
12
13 function setTimeout(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
14 namespace setTimeout {
15 function __promisify__(ms: number): Promise<void>;
16 function __promisify__<T>(ms: number, value: T, options?: TimerOptions): Promise<T>;
17 }
18 function clearTimeout(timeoutId: NodeJS.Timeout): void;
19 function setInterval(callback: (...args: any[]) => void, ms?: number, ...args: any[]): NodeJS.Timeout;
20 function clearInterval(intervalId: NodeJS.Timeout): void;
21 function setImmediate(callback: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate;
22 namespace setImmediate {
23 function __promisify__(): Promise<void>;
24 function __promisify__<T>(value: T, options?: TimerOptions): Promise<T>;
25 }
26 function clearImmediate(immediateId: NodeJS.Immediate): void;
27}