forked from DefinitelyTyped/DefinitelyTyped
/
timers.d.ts
47 lines (41 loc) · 1.3 KB
/
timers.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* This module provides setInterval, setTimeout and co.
*/
/**
* Set a timer that executes a function once the timer expires.
*
* @param functionRef - The function to be executed.
* @param delay - The delay in milliseconds.
* @param args - The arguments to be passed to the function.
* @returns The timer id.
*/
export function setTimeout(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): TimeoutID;
/**
* Cancels a timer previously set with setTimeout().
*
* @param timeoutID - The timer id to be cancelled.
*/
export function clearTimeout(timeoutID: TimeoutID): void;
/**
* Repeatedly execute a function, with a fixed time delay between each call.
*
* @param functionRef - The function to be executed.
* @param delay - The delay in milliseconds.
* @param args - The arguments to be passed to the function.
* @returns The interval id.
*/
export function setInterval(functionRef: (...args: any[]) => void, delay: number, ...args: any[]): IntervalID;
/**
* Cancels an interval previously set with setInterval().
*
* @param intervalID - The interval id to be cancelled.
*/
export function clearInterval(intervalID: IntervalID): void;
/**
* Type alias for a timer id.
*/
export type TimeoutID = number;
/**
* Type alias for a interval id.
*/
export type IntervalID = number;