@types/node 18.19.84 → 18.19.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node v18.19/README.md +1 -1
- node v18.19/fs.d.ts +6 -6
- node v18.19/package.json +3 -3
- node v18.19/timers/promises.d.ts +32 -17
- node v18.19/timers.d.ts +209 -49
node v18.19/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v18.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Tue, 01 Apr 2025 16:38:24 GMT
|
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
|
13
13
|
|
|
14
14
|
# Credits
|
node v18.19/fs.d.ts
CHANGED
|
@@ -609,7 +609,7 @@ declare module "fs" {
|
|
|
609
609
|
* @since v0.8.6
|
|
610
610
|
* @param [len=0]
|
|
611
611
|
*/
|
|
612
|
-
export function truncate(path: PathLike, len: number | undefined
|
|
612
|
+
export function truncate(path: PathLike, len: number | undefined, callback: NoParamCallback): void;
|
|
613
613
|
/**
|
|
614
614
|
* Asynchronous truncate(2) - Truncate a file to a specified length.
|
|
615
615
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
@@ -621,7 +621,7 @@ declare module "fs" {
|
|
|
621
621
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
622
622
|
* @param len If not specified, defaults to `0`.
|
|
623
623
|
*/
|
|
624
|
-
function __promisify__(path: PathLike, len?: number
|
|
624
|
+
function __promisify__(path: PathLike, len?: number): Promise<void>;
|
|
625
625
|
}
|
|
626
626
|
/**
|
|
627
627
|
* Truncates the file. Returns `undefined`. A file descriptor can also be
|
|
@@ -632,7 +632,7 @@ declare module "fs" {
|
|
|
632
632
|
* @since v0.8.6
|
|
633
633
|
* @param [len=0]
|
|
634
634
|
*/
|
|
635
|
-
export function truncateSync(path: PathLike, len?: number
|
|
635
|
+
export function truncateSync(path: PathLike, len?: number): void;
|
|
636
636
|
/**
|
|
637
637
|
* Truncates the file descriptor. No arguments other than a possible exception are
|
|
638
638
|
* given to the completion callback.
|
|
@@ -676,7 +676,7 @@ declare module "fs" {
|
|
|
676
676
|
* @since v0.8.6
|
|
677
677
|
* @param [len=0]
|
|
678
678
|
*/
|
|
679
|
-
export function ftruncate(fd: number, len: number | undefined
|
|
679
|
+
export function ftruncate(fd: number, len: number | undefined, callback: NoParamCallback): void;
|
|
680
680
|
/**
|
|
681
681
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
|
682
682
|
* @param fd A file descriptor.
|
|
@@ -688,7 +688,7 @@ declare module "fs" {
|
|
|
688
688
|
* @param fd A file descriptor.
|
|
689
689
|
* @param len If not specified, defaults to `0`.
|
|
690
690
|
*/
|
|
691
|
-
function __promisify__(fd: number, len?: number
|
|
691
|
+
function __promisify__(fd: number, len?: number): Promise<void>;
|
|
692
692
|
}
|
|
693
693
|
/**
|
|
694
694
|
* Truncates the file descriptor. Returns `undefined`.
|
|
@@ -698,7 +698,7 @@ declare module "fs" {
|
|
|
698
698
|
* @since v0.8.6
|
|
699
699
|
* @param [len=0]
|
|
700
700
|
*/
|
|
701
|
-
export function ftruncateSync(fd: number, len?: number
|
|
701
|
+
export function ftruncateSync(fd: number, len?: number): void;
|
|
702
702
|
/**
|
|
703
703
|
* Asynchronously changes owner and group of a file. No arguments other than a
|
|
704
704
|
* possible exception are given to the completion callback.
|
node v18.19/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "18.19.
|
|
3
|
+
"version": "18.19.86",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -220,6 +220,6 @@
|
|
|
220
220
|
"undici-types": "~5.26.4"
|
|
221
221
|
},
|
|
222
222
|
"peerDependencies": {},
|
|
223
|
-
"typesPublisherContentHash": "
|
|
224
|
-
"typeScriptVersion": "5.
|
|
223
|
+
"typesPublisherContentHash": "56c3936f9acbd8dc952c85df42d6f977d4062ccb735b5afd2bb6be788948c7ab",
|
|
224
|
+
"typeScriptVersion": "5.1"
|
|
225
225
|
}
|
node v18.19/timers/promises.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `timers/promises` API provides an alternative set of timer functions
|
|
3
|
-
* that return `Promise` objects. The API is accessible via
|
|
3
|
+
* that return `Promise` objects. The API is accessible via
|
|
4
|
+
* `require('node:timers/promises')`.
|
|
4
5
|
*
|
|
5
6
|
* ```js
|
|
6
7
|
* import {
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
* } from 'timers/promises';
|
|
11
12
|
* ```
|
|
12
13
|
* @since v15.0.0
|
|
14
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.x/lib/timers/promises.js)
|
|
13
15
|
*/
|
|
14
16
|
declare module "timers/promises" {
|
|
15
17
|
import { TimerOptions } from "node:timers";
|
|
@@ -17,14 +19,15 @@ declare module "timers/promises" {
|
|
|
17
19
|
* ```js
|
|
18
20
|
* import {
|
|
19
21
|
* setTimeout,
|
|
20
|
-
* } from 'timers/promises';
|
|
22
|
+
* } from 'node:timers/promises';
|
|
21
23
|
*
|
|
22
24
|
* const res = await setTimeout(100, 'result');
|
|
23
25
|
*
|
|
24
26
|
* console.log(res); // Prints 'result'
|
|
25
27
|
* ```
|
|
26
28
|
* @since v15.0.0
|
|
27
|
-
* @param
|
|
29
|
+
* @param delay The number of milliseconds to wait before fulfilling the
|
|
30
|
+
* promise. **Default:** `1`.
|
|
28
31
|
* @param value A value with which the promise is fulfilled.
|
|
29
32
|
*/
|
|
30
33
|
function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
|
|
@@ -32,7 +35,7 @@ declare module "timers/promises" {
|
|
|
32
35
|
* ```js
|
|
33
36
|
* import {
|
|
34
37
|
* setImmediate,
|
|
35
|
-
* } from 'timers/promises';
|
|
38
|
+
* } from 'node:timers/promises';
|
|
36
39
|
*
|
|
37
40
|
* const res = await setImmediate('result');
|
|
38
41
|
*
|
|
@@ -44,11 +47,13 @@ declare module "timers/promises" {
|
|
|
44
47
|
function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
|
|
45
48
|
/**
|
|
46
49
|
* Returns an async iterator that generates values in an interval of `delay` ms.
|
|
50
|
+
* If `ref` is `true`, you need to call `next()` of async iterator explicitly
|
|
51
|
+
* or implicitly to keep the event loop alive.
|
|
47
52
|
*
|
|
48
53
|
* ```js
|
|
49
54
|
* import {
|
|
50
55
|
* setInterval,
|
|
51
|
-
* } from 'timers/promises';
|
|
56
|
+
* } from 'node:timers/promises';
|
|
52
57
|
*
|
|
53
58
|
* const interval = 100;
|
|
54
59
|
* for await (const startTime of setInterval(interval, Date.now())) {
|
|
@@ -60,32 +65,42 @@ declare module "timers/promises" {
|
|
|
60
65
|
* console.log(Date.now());
|
|
61
66
|
* ```
|
|
62
67
|
* @since v15.9.0
|
|
68
|
+
* @param delay The number of milliseconds to wait between iterations.
|
|
69
|
+
* **Default:** `1`.
|
|
70
|
+
* @param value A value with which the iterator returns.
|
|
63
71
|
*/
|
|
64
|
-
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions):
|
|
65
|
-
|
|
72
|
+
function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): NodeJS.AsyncIterator<T>;
|
|
66
73
|
interface Scheduler {
|
|
67
74
|
/**
|
|
75
|
+
* An experimental API defined by the [Scheduling APIs](https://github.com/WICG/scheduling-apis) draft specification
|
|
76
|
+
* being developed as a standard Web Platform API.
|
|
77
|
+
*
|
|
78
|
+
* Calling `timersPromises.scheduler.wait(delay, options)` is roughly equivalent
|
|
79
|
+
* to calling `timersPromises.setTimeout(delay, undefined, options)` except that
|
|
80
|
+
* the `ref` option is not supported.
|
|
81
|
+
*
|
|
68
82
|
* ```js
|
|
69
83
|
* import { scheduler } from 'node:timers/promises';
|
|
70
84
|
*
|
|
71
85
|
* await scheduler.wait(1000); // Wait one second before continuing
|
|
72
86
|
* ```
|
|
73
|
-
*
|
|
74
|
-
* Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported.
|
|
75
|
-
* @since v16.14.0
|
|
87
|
+
* @since v17.3.0, v16.14.0
|
|
76
88
|
* @experimental
|
|
77
|
-
* @param
|
|
89
|
+
* @param delay The number of milliseconds to wait before resolving the
|
|
90
|
+
* promise.
|
|
78
91
|
*/
|
|
79
|
-
wait
|
|
92
|
+
wait(delay: number, options?: { signal?: AbortSignal }): Promise<void>;
|
|
80
93
|
/**
|
|
81
|
-
* An experimental API defined by the Scheduling APIs draft specification
|
|
82
|
-
*
|
|
83
|
-
*
|
|
94
|
+
* An experimental API defined by the [Scheduling APIs](https://github.com/WICG/scheduling-apis) draft specification
|
|
95
|
+
* being developed as a standard Web Platform API.
|
|
96
|
+
*
|
|
97
|
+
* Calling `timersPromises.scheduler.yield()` is equivalent to calling
|
|
98
|
+
* `timersPromises.setImmediate()` with no arguments.
|
|
99
|
+
* @since v17.3.0, v16.14.0
|
|
84
100
|
* @experimental
|
|
85
101
|
*/
|
|
86
|
-
yield
|
|
102
|
+
yield(): Promise<void>;
|
|
87
103
|
}
|
|
88
|
-
|
|
89
104
|
const scheduler: Scheduler;
|
|
90
105
|
}
|
|
91
106
|
declare module "node:timers/promises" {
|
node v18.19/timers.d.ts
CHANGED
|
@@ -6,16 +6,12 @@
|
|
|
6
6
|
* The timer functions within Node.js implement a similar API as the timers API
|
|
7
7
|
* provided by Web Browsers but use a different internal implementation that is
|
|
8
8
|
* built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
|
|
9
|
-
* @see [source](https://github.com/nodejs/node/blob/v18.
|
|
9
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.x/lib/timers.js)
|
|
10
10
|
*/
|
|
11
11
|
declare module "timers" {
|
|
12
12
|
import { Abortable } from "node:events";
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
setInterval as setIntervalPromise,
|
|
16
|
-
setTimeout as setTimeoutPromise,
|
|
17
|
-
} from "node:timers/promises";
|
|
18
|
-
interface TimerOptions extends Abortable {
|
|
13
|
+
import * as promises from "node:timers/promises";
|
|
14
|
+
export interface TimerOptions extends Abortable {
|
|
19
15
|
/**
|
|
20
16
|
* Set to `false` to indicate that the scheduled `Timeout`
|
|
21
17
|
* should not require the Node.js event loop to remain active.
|
|
@@ -23,39 +19,93 @@ declare module "timers" {
|
|
|
23
19
|
*/
|
|
24
20
|
ref?: boolean | undefined;
|
|
25
21
|
}
|
|
26
|
-
let setTimeout: typeof global.setTimeout;
|
|
27
|
-
let clearTimeout: typeof global.clearTimeout;
|
|
28
|
-
let setInterval: typeof global.setInterval;
|
|
29
|
-
let clearInterval: typeof global.clearInterval;
|
|
30
|
-
let setImmediate: typeof global.setImmediate;
|
|
31
|
-
let clearImmediate: typeof global.clearImmediate;
|
|
32
22
|
global {
|
|
33
23
|
namespace NodeJS {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
/**
|
|
25
|
+
* This object is created internally and is returned from `setImmediate()`. It
|
|
26
|
+
* can be passed to `clearImmediate()` in order to cancel the scheduled
|
|
27
|
+
* actions.
|
|
28
|
+
*
|
|
29
|
+
* By default, when an immediate is scheduled, the Node.js event loop will continue
|
|
30
|
+
* running as long as the immediate is active. The `Immediate` object returned by
|
|
31
|
+
* `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`
|
|
32
|
+
* functions that can be used to control this default behavior.
|
|
33
|
+
*/
|
|
34
|
+
interface Immediate extends RefCounted, Disposable {
|
|
41
35
|
/**
|
|
42
36
|
* If true, the `Immediate` object will keep the Node.js event loop active.
|
|
43
37
|
* @since v11.0.0
|
|
44
38
|
*/
|
|
45
39
|
hasRef(): boolean;
|
|
46
|
-
|
|
40
|
+
/**
|
|
41
|
+
* When called, requests that the Node.js event loop _not_ exit so long as the
|
|
42
|
+
* `Immediate` is active. Calling `immediate.ref()` multiple times will have no
|
|
43
|
+
* effect.
|
|
44
|
+
*
|
|
45
|
+
* By default, all `Immediate` objects are "ref'ed", making it normally unnecessary
|
|
46
|
+
* to call `immediate.ref()` unless `immediate.unref()` had been called previously.
|
|
47
|
+
* @since v9.7.0
|
|
48
|
+
* @returns a reference to `immediate`
|
|
49
|
+
*/
|
|
50
|
+
ref(): this;
|
|
51
|
+
/**
|
|
52
|
+
* When called, the active `Immediate` object will not require the Node.js event
|
|
53
|
+
* loop to remain active. If there is no other activity keeping the event loop
|
|
54
|
+
* running, the process may exit before the `Immediate` object's callback is
|
|
55
|
+
* invoked. Calling `immediate.unref()` multiple times will have no effect.
|
|
56
|
+
* @since v9.7.0
|
|
57
|
+
* @returns a reference to `immediate`
|
|
58
|
+
*/
|
|
59
|
+
unref(): this;
|
|
47
60
|
/**
|
|
48
61
|
* Cancels the immediate. This is similar to calling `clearImmediate()`.
|
|
49
62
|
* @since v18.18.0
|
|
63
|
+
* @experimental
|
|
50
64
|
*/
|
|
51
65
|
[Symbol.dispose](): void;
|
|
66
|
+
_onImmediate(...args: any[]): void;
|
|
67
|
+
}
|
|
68
|
+
// Legacy interface used in Node.js v9 and prior
|
|
69
|
+
/** @deprecated Use `NodeJS.Timeout` instead. */
|
|
70
|
+
interface Timer extends RefCounted {
|
|
71
|
+
hasRef(): boolean;
|
|
72
|
+
refresh(): this;
|
|
73
|
+
[Symbol.toPrimitive](): number;
|
|
52
74
|
}
|
|
53
|
-
|
|
75
|
+
/**
|
|
76
|
+
* This object is created internally and is returned from `setTimeout()` and
|
|
77
|
+
* `setInterval()`. It can be passed to either `clearTimeout()` or
|
|
78
|
+
* `clearInterval()` in order to cancel the scheduled actions.
|
|
79
|
+
*
|
|
80
|
+
* By default, when a timer is scheduled using either `setTimeout()` or
|
|
81
|
+
* `setInterval()`, the Node.js event loop will continue running as long as the
|
|
82
|
+
* timer is active. Each of the `Timeout` objects returned by these functions
|
|
83
|
+
* export both `timeout.ref()` and `timeout.unref()` functions that can be used to
|
|
84
|
+
* control this default behavior.
|
|
85
|
+
*/
|
|
86
|
+
interface Timeout extends RefCounted, Disposable, Timer {
|
|
87
|
+
/**
|
|
88
|
+
* Cancels the timeout.
|
|
89
|
+
* @since v0.9.1
|
|
90
|
+
* @legacy Use `clearTimeout()` instead.
|
|
91
|
+
* @returns a reference to `timeout`
|
|
92
|
+
*/
|
|
93
|
+
close(): this;
|
|
54
94
|
/**
|
|
55
95
|
* If true, the `Timeout` object will keep the Node.js event loop active.
|
|
56
96
|
* @since v11.0.0
|
|
57
97
|
*/
|
|
58
98
|
hasRef(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* When called, requests that the Node.js event loop _not_ exit so long as the
|
|
101
|
+
* `Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
|
|
102
|
+
*
|
|
103
|
+
* By default, all `Timeout` objects are "ref'ed", making it normally unnecessary
|
|
104
|
+
* to call `timeout.ref()` unless `timeout.unref()` had been called previously.
|
|
105
|
+
* @since v0.9.1
|
|
106
|
+
* @returns a reference to `timeout`
|
|
107
|
+
*/
|
|
108
|
+
ref(): this;
|
|
59
109
|
/**
|
|
60
110
|
* Sets the timer's start time to the current time, and reschedules the timer to
|
|
61
111
|
* call its callback at the previously specified duration adjusted to the current
|
|
@@ -65,61 +115,171 @@ declare module "timers" {
|
|
|
65
115
|
* Using this on a timer that has already called its callback will reactivate the
|
|
66
116
|
* timer.
|
|
67
117
|
* @since v10.2.0
|
|
68
|
-
* @
|
|
118
|
+
* @returns a reference to `timeout`
|
|
69
119
|
*/
|
|
70
120
|
refresh(): this;
|
|
121
|
+
/**
|
|
122
|
+
* When called, the active `Timeout` object will not require the Node.js event loop
|
|
123
|
+
* to remain active. If there is no other activity keeping the event loop running,
|
|
124
|
+
* the process may exit before the `Timeout` object's callback is invoked. Calling
|
|
125
|
+
* `timeout.unref()` multiple times will have no effect.
|
|
126
|
+
* @since v0.9.1
|
|
127
|
+
* @returns a reference to `timeout`
|
|
128
|
+
*/
|
|
129
|
+
unref(): this;
|
|
130
|
+
/**
|
|
131
|
+
* Coerce a `Timeout` to a primitive. The primitive can be used to
|
|
132
|
+
* clear the `Timeout`. The primitive can only be used in the
|
|
133
|
+
* same thread where the timeout was created. Therefore, to use it
|
|
134
|
+
* across `worker_threads` it must first be passed to the correct
|
|
135
|
+
* thread. This allows enhanced compatibility with browser
|
|
136
|
+
* `setTimeout()` and `setInterval()` implementations.
|
|
137
|
+
* @since v14.9.0, v12.19.0
|
|
138
|
+
*/
|
|
71
139
|
[Symbol.toPrimitive](): number;
|
|
72
140
|
/**
|
|
73
141
|
* Cancels the timeout.
|
|
74
142
|
* @since v18.18.0
|
|
143
|
+
* @experimental
|
|
75
144
|
*/
|
|
76
145
|
[Symbol.dispose](): void;
|
|
146
|
+
_onTimeout(...args: any[]): void;
|
|
77
147
|
}
|
|
78
148
|
}
|
|
79
149
|
/**
|
|
80
|
-
* Schedules execution of
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
150
|
+
* Schedules the "immediate" execution of the `callback` after I/O events'
|
|
151
|
+
* callbacks.
|
|
152
|
+
*
|
|
153
|
+
* When multiple calls to `setImmediate()` are made, the `callback` functions are
|
|
154
|
+
* queued for execution in the order in which they are created. The entire callback
|
|
155
|
+
* queue is processed every event loop iteration. If an immediate timer is queued
|
|
156
|
+
* from inside an executing callback, that timer will not be triggered until the
|
|
157
|
+
* next event loop iteration.
|
|
158
|
+
*
|
|
159
|
+
* If `callback` is not a function, a `TypeError` will be thrown.
|
|
160
|
+
*
|
|
161
|
+
* This method has a custom variant for promises that is available using
|
|
162
|
+
* `timersPromises.setImmediate()`.
|
|
163
|
+
* @since v0.9.1
|
|
164
|
+
* @param callback The function to call at the end of this turn of
|
|
165
|
+
* the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout)
|
|
166
|
+
* @param args Optional arguments to pass when the `callback` is called.
|
|
167
|
+
* @returns for use with `clearImmediate()`
|
|
85
168
|
*/
|
|
86
|
-
function
|
|
169
|
+
function setImmediate<TArgs extends any[]>(
|
|
87
170
|
callback: (...args: TArgs) => void,
|
|
88
|
-
delay?: number,
|
|
89
171
|
...args: TArgs
|
|
90
|
-
): NodeJS.
|
|
91
|
-
//
|
|
172
|
+
): NodeJS.Immediate;
|
|
173
|
+
// Allow a single void-accepting argument to be optional in arguments lists.
|
|
174
|
+
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
|
92
175
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
93
|
-
function
|
|
94
|
-
namespace
|
|
95
|
-
|
|
176
|
+
function setImmediate(callback: (_: void) => void): NodeJS.Immediate;
|
|
177
|
+
namespace setImmediate {
|
|
178
|
+
import __promisify__ = promises.setImmediate;
|
|
179
|
+
export { __promisify__ };
|
|
96
180
|
}
|
|
97
|
-
|
|
181
|
+
/**
|
|
182
|
+
* Schedules repeated execution of `callback` every `delay` milliseconds.
|
|
183
|
+
*
|
|
184
|
+
* When `delay` is larger than `2147483647` or less than `1`, the `delay` will be
|
|
185
|
+
* set to `1`. Non-integer delays are truncated to an integer.
|
|
186
|
+
*
|
|
187
|
+
* If `callback` is not a function, a `TypeError` will be thrown.
|
|
188
|
+
*
|
|
189
|
+
* This method has a custom variant for promises that is available using
|
|
190
|
+
* `timersPromises.setInterval()`.
|
|
191
|
+
* @since v0.0.1
|
|
192
|
+
* @param callback The function to call when the timer elapses.
|
|
193
|
+
* @param delay The number of milliseconds to wait before calling the
|
|
194
|
+
* `callback`. **Default:** `1`.
|
|
195
|
+
* @param args Optional arguments to pass when the `callback` is called.
|
|
196
|
+
* @returns for use with `clearInterval()`
|
|
197
|
+
*/
|
|
98
198
|
function setInterval<TArgs extends any[]>(
|
|
99
199
|
callback: (...args: TArgs) => void,
|
|
100
200
|
delay?: number,
|
|
101
201
|
...args: TArgs
|
|
102
202
|
): NodeJS.Timeout;
|
|
103
|
-
//
|
|
203
|
+
// Allow a single void-accepting argument to be optional in arguments lists.
|
|
204
|
+
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
|
104
205
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
105
|
-
function setInterval(callback: (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
206
|
+
function setInterval(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
|
|
207
|
+
/**
|
|
208
|
+
* Schedules execution of a one-time `callback` after `delay` milliseconds.
|
|
209
|
+
*
|
|
210
|
+
* The `callback` will likely not be invoked in precisely `delay` milliseconds.
|
|
211
|
+
* Node.js makes no guarantees about the exact timing of when callbacks will fire,
|
|
212
|
+
* nor of their ordering. The callback will be called as close as possible to the
|
|
213
|
+
* time specified.
|
|
214
|
+
*
|
|
215
|
+
* When `delay` is larger than `2147483647` or less than `1` or `NaN`, the `delay`
|
|
216
|
+
* will be set to `1`. Non-integer delays are truncated to an integer.
|
|
217
|
+
*
|
|
218
|
+
* If `callback` is not a function, a `TypeError` will be thrown.
|
|
219
|
+
*
|
|
220
|
+
* This method has a custom variant for promises that is available using
|
|
221
|
+
* `timersPromises.setTimeout()`.
|
|
222
|
+
* @since v0.0.1
|
|
223
|
+
* @param callback The function to call when the timer elapses.
|
|
224
|
+
* @param delay The number of milliseconds to wait before calling the
|
|
225
|
+
* `callback`. **Default:** `1`.
|
|
226
|
+
* @param args Optional arguments to pass when the `callback` is called.
|
|
227
|
+
* @returns for use with `clearTimeout()`
|
|
228
|
+
*/
|
|
229
|
+
function setTimeout<TArgs extends any[]>(
|
|
111
230
|
callback: (...args: TArgs) => void,
|
|
231
|
+
delay?: number,
|
|
112
232
|
...args: TArgs
|
|
113
|
-
): NodeJS.
|
|
114
|
-
//
|
|
233
|
+
): NodeJS.Timeout;
|
|
234
|
+
// Allow a single void-accepting argument to be optional in arguments lists.
|
|
235
|
+
// Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
|
|
115
236
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
116
|
-
function
|
|
117
|
-
namespace
|
|
118
|
-
|
|
237
|
+
function setTimeout(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
|
|
238
|
+
namespace setTimeout {
|
|
239
|
+
import __promisify__ = promises.setTimeout;
|
|
240
|
+
export { __promisify__ };
|
|
119
241
|
}
|
|
120
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Cancels an `Immediate` object created by `setImmediate()`.
|
|
244
|
+
* @since v0.9.1
|
|
245
|
+
* @param immediate An `Immediate` object as returned by `setImmediate()`.
|
|
246
|
+
*/
|
|
247
|
+
function clearImmediate(immediate: NodeJS.Immediate | undefined): void;
|
|
248
|
+
/**
|
|
249
|
+
* Cancels a `Timeout` object created by `setInterval()`.
|
|
250
|
+
* @since v0.0.1
|
|
251
|
+
* @param timeout A `Timeout` object as returned by `setInterval()`
|
|
252
|
+
* or the primitive of the `Timeout` object as a string or a number.
|
|
253
|
+
*/
|
|
254
|
+
function clearInterval(timeout: NodeJS.Timeout | string | number | undefined): void;
|
|
255
|
+
/**
|
|
256
|
+
* Cancels a `Timeout` object created by `setTimeout()`.
|
|
257
|
+
* @since v0.0.1
|
|
258
|
+
* @param timeout A `Timeout` object as returned by `setTimeout()`
|
|
259
|
+
* or the primitive of the `Timeout` object as a string or a number.
|
|
260
|
+
*/
|
|
261
|
+
function clearTimeout(timeout: NodeJS.Timeout | string | number | undefined): void;
|
|
262
|
+
/**
|
|
263
|
+
* The `queueMicrotask()` method queues a microtask to invoke `callback`. If
|
|
264
|
+
* `callback` throws an exception, the `process` object `'uncaughtException'`
|
|
265
|
+
* event will be emitted.
|
|
266
|
+
*
|
|
267
|
+
* The microtask queue is managed by V8 and may be used in a similar manner to
|
|
268
|
+
* the `process.nextTick()` queue, which is managed by Node.js. The
|
|
269
|
+
* `process.nextTick()` queue is always processed before the microtask queue
|
|
270
|
+
* within each turn of the Node.js event loop.
|
|
271
|
+
* @since v11.0.0
|
|
272
|
+
* @param callback Function to be queued.
|
|
273
|
+
*/
|
|
121
274
|
function queueMicrotask(callback: () => void): void;
|
|
122
275
|
}
|
|
276
|
+
import clearImmediate = globalThis.clearImmediate;
|
|
277
|
+
import clearInterval = globalThis.clearInterval;
|
|
278
|
+
import clearTimeout = globalThis.clearTimeout;
|
|
279
|
+
import setImmediate = globalThis.setImmediate;
|
|
280
|
+
import setInterval = globalThis.setInterval;
|
|
281
|
+
import setTimeout = globalThis.setTimeout;
|
|
282
|
+
export { clearImmediate, clearInterval, clearTimeout, setImmediate, setInterval, setTimeout };
|
|
123
283
|
}
|
|
124
284
|
declare module "node:timers" {
|
|
125
285
|
export * from "timers";
|