blob: 0d2f3e745edf4819b4ce1c7aaea10daa3371f43a (
plain) (
blame)
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
|
/**
* The `timer` module exposes a global API for scheduling functions to
* be called at some future period of time. Because the timer functions are
* globals, there is no need to call `require('timers')` to use the API.
*
* The timer functions within Node.js implement a similar API as the timers API
* provided by Web Browsers but use a different internal implementation that is
* built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js)
*/
declare module "timers" {
class Timer {
ref(): Timer;
unref(): Timer;
hasRef(): boolean;
}
const _exported: {
clearTimeout: (timer: Timer | number) => void;
clearInterval: (timer: Timer | number) => void;
setInterval: (
cb: CallableFunction,
msDelay: number,
...args: any[]
) => Timer;
setTimeout: (
cb: CallableFunction,
msDelay: number,
...args: any[]
) => Timer;
setImmediate: (cb: CallableFunction, ...args: any[]) => Timer;
};
export = _exported;
}
declare module "node:timers" {
import timers = require("timers");
export = timers;
}
|