@types/node 17.0.42 → 18.0.0
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/README.md +1 -1
- node/assert.d.ts +7 -8
- node/async_hooks.d.ts +2 -2
- node/buffer.d.ts +11 -5
- node/child_process.d.ts +6 -3
- node/cluster.d.ts +14 -18
- node/console.d.ts +1 -1
- node/crypto.d.ts +109 -37
- node/dgram.d.ts +2 -2
- node/diagnostics_channel.d.ts +2 -1
- node/dns/promises.d.ts +2 -2
- node/dns.d.ts +2 -2
- node/domain.d.ts +3 -2
- node/events.d.ts +17 -27
- node/fs/promises.d.ts +14 -15
- node/fs.d.ts +21 -39
- node/http.d.ts +69 -23
- node/http2.d.ts +7 -2
- node/https.d.ts +1 -1
- node/index.d.ts +2 -1
- node/inspector.d.ts +10 -13
- node/net.d.ts +27 -7
- node/os.d.ts +5 -4
- node/package.json +2 -2
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +10 -2
- node/process.d.ts +2 -2
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline.d.ts +2 -2
- node/repl.d.ts +2 -2
- node/stream.d.ts +39 -15
- node/string_decoder.d.ts +1 -1
- node/test.d.ts +142 -0
- node/timers.d.ts +1 -1
- node/tls.d.ts +17 -9
- node/trace_events.d.ts +11 -1
- node/tty.d.ts +4 -2
- node/url.d.ts +25 -19
- node/util.d.ts +20 -9
- node/v8.d.ts +19 -1
- node/vm.d.ts +5 -3
- node/wasi.d.ts +1 -1
- node/worker_threads.d.ts +2 -5
- node/zlib.d.ts +1 -1
node/events.d.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* });
|
|
33
33
|
* myEmitter.emit('event');
|
|
34
34
|
* ```
|
|
35
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
35
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
|
|
36
36
|
*/
|
|
37
37
|
declare module 'events' {
|
|
38
38
|
interface EventEmitterOptions {
|
|
@@ -50,7 +50,7 @@ declare module 'events' {
|
|
|
50
50
|
listener: (...args: any[]) => void,
|
|
51
51
|
opts?: {
|
|
52
52
|
once: boolean;
|
|
53
|
-
}
|
|
53
|
+
}
|
|
54
54
|
): any;
|
|
55
55
|
}
|
|
56
56
|
interface StaticEventEmitterOptions {
|
|
@@ -154,11 +154,7 @@ declare module 'events' {
|
|
|
154
154
|
* ```
|
|
155
155
|
* @since v11.13.0, v10.16.0
|
|
156
156
|
*/
|
|
157
|
-
static once(
|
|
158
|
-
emitter: NodeEventTarget,
|
|
159
|
-
eventName: string | symbol,
|
|
160
|
-
options?: StaticEventEmitterOptions,
|
|
161
|
-
): Promise<any[]>;
|
|
157
|
+
static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
162
158
|
static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
|
163
159
|
/**
|
|
164
160
|
* ```js
|
|
@@ -218,11 +214,7 @@ declare module 'events' {
|
|
|
218
214
|
* @param eventName The name of the event being listened for
|
|
219
215
|
* @return that iterates `eventName` events emitted by the `emitter`
|
|
220
216
|
*/
|
|
221
|
-
static on(
|
|
222
|
-
emitter: NodeJS.EventEmitter,
|
|
223
|
-
eventName: string,
|
|
224
|
-
options?: StaticEventEmitterOptions,
|
|
225
|
-
): AsyncIterableIterator<any>;
|
|
217
|
+
static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
|
226
218
|
/**
|
|
227
219
|
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
|
228
220
|
*
|
|
@@ -269,23 +261,21 @@ declare module 'events' {
|
|
|
269
261
|
*/
|
|
270
262
|
static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
|
271
263
|
/**
|
|
272
|
-
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
273
|
-
* added for a particular event. This is a useful default that helps finding
|
|
274
|
-
* memory leaks. The `EventEmitter.setMaxListeners()` method allows the default limit to be
|
|
275
|
-
* modified (if eventTargets is empty) or modify the limit specified in every `EventTarget` | `EventEmitter` passed as arguments.
|
|
276
|
-
* The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
|
277
|
-
*
|
|
278
264
|
* ```js
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
265
|
+
* const {
|
|
266
|
+
* setMaxListeners,
|
|
267
|
+
* EventEmitter
|
|
268
|
+
* } = require('events');
|
|
269
|
+
*
|
|
270
|
+
* const target = new EventTarget();
|
|
271
|
+
* const emitter = new EventEmitter();
|
|
272
|
+
*
|
|
273
|
+
* setMaxListeners(5, target, emitter);
|
|
287
274
|
* ```
|
|
288
|
-
* @since v15.
|
|
275
|
+
* @since v15.4.0
|
|
276
|
+
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
|
277
|
+
* @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
|
278
|
+
* objects.
|
|
289
279
|
*/
|
|
290
280
|
static setMaxListeners(n?: number, ...eventTargets: Array<DOMEventTarget | NodeJS.EventEmitter>): void;
|
|
291
281
|
/**
|
node/fs/promises.d.ts
CHANGED
|
@@ -164,9 +164,9 @@ declare module 'fs/promises' {
|
|
|
164
164
|
/**
|
|
165
165
|
* `options` may also include a `start` option to allow writing data at some
|
|
166
166
|
* position past the beginning of the file, allowed values are in the
|
|
167
|
-
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
|
168
|
-
* it may require the `flags` `open` option to be set to `r+` rather than
|
|
169
|
-
* default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
|
167
|
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
|
168
|
+
* replacing it may require the `flags` `open` option to be set to `r+` rather than
|
|
169
|
+
* the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
|
170
170
|
*
|
|
171
171
|
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
|
172
172
|
* then the file descriptor won't be closed, even if there's an error.
|
|
@@ -333,9 +333,8 @@ declare module 'fs/promises' {
|
|
|
333
333
|
/**
|
|
334
334
|
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
|
335
335
|
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
|
336
|
-
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object
|
|
337
|
-
*
|
|
338
|
-
* property. The promise is resolved with no arguments upon success.
|
|
336
|
+
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
|
337
|
+
* The promise is resolved with no arguments upon success.
|
|
339
338
|
*
|
|
340
339
|
* If `options` is a string, then it specifies the `encoding`.
|
|
341
340
|
*
|
|
@@ -353,20 +352,18 @@ declare module 'fs/promises' {
|
|
|
353
352
|
/**
|
|
354
353
|
* Write `buffer` to the file.
|
|
355
354
|
*
|
|
356
|
-
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
357
|
-
*
|
|
358
355
|
* The promise is resolved with an object containing two properties:
|
|
359
356
|
*
|
|
360
357
|
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
|
361
358
|
* without waiting for the promise to be resolved (or rejected). For this
|
|
362
|
-
* scenario, use `
|
|
359
|
+
* scenario, use `filehandle.createWriteStream()`.
|
|
363
360
|
*
|
|
364
361
|
* On Linux, positional writes do not work when the file is opened in append mode.
|
|
365
362
|
* The kernel ignores the position argument and always appends the data to
|
|
366
363
|
* the end of the file.
|
|
367
364
|
* @since v10.0.0
|
|
368
365
|
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
|
369
|
-
* @param [length=buffer.byteLength] The number of bytes from `buffer` to write.
|
|
366
|
+
* @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
|
|
370
367
|
* @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
|
|
371
368
|
* See the POSIX pwrite(2) documentation for more detail.
|
|
372
369
|
*/
|
|
@@ -432,9 +429,9 @@ declare module 'fs/promises' {
|
|
|
432
429
|
/**
|
|
433
430
|
* Tests a user's permissions for the file or directory specified by `path`.
|
|
434
431
|
* The `mode` argument is an optional integer that specifies the accessibility
|
|
435
|
-
* checks to be performed.
|
|
436
|
-
*
|
|
437
|
-
*
|
|
432
|
+
* checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
|
433
|
+
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
|
434
|
+
* possible values of `mode`.
|
|
438
435
|
*
|
|
439
436
|
* If the accessibility check is successful, the promise is resolved with no
|
|
440
437
|
* value. If any of the accessibility checks fail, the promise is rejected
|
|
@@ -854,7 +851,9 @@ declare module 'fs/promises' {
|
|
|
854
851
|
*/
|
|
855
852
|
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
856
853
|
/**
|
|
857
|
-
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a
|
|
854
|
+
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
|
855
|
+
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
|
856
|
+
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
|
858
857
|
*
|
|
859
858
|
* The `encoding` option is ignored if `data` is a buffer.
|
|
860
859
|
*
|
|
@@ -869,7 +868,7 @@ declare module 'fs/promises' {
|
|
|
869
868
|
*
|
|
870
869
|
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
|
871
870
|
* method that performs multiple `write` calls internally to write the buffer
|
|
872
|
-
* passed to it. For performance sensitive code consider using `fs.createWriteStream()`.
|
|
871
|
+
* passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
|
|
873
872
|
*
|
|
874
873
|
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
|
875
874
|
* Cancelation is "best effort", and some amount of data is likely still
|
node/fs.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* All file system operations have synchronous, callback, and promise-based
|
|
18
18
|
* forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
|
|
19
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
19
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/fs.js)
|
|
20
20
|
*/
|
|
21
21
|
declare module 'fs' {
|
|
22
22
|
import * as stream from 'node:stream';
|
|
@@ -1123,15 +1123,15 @@ declare module 'fs' {
|
|
|
1123
1123
|
* ```js
|
|
1124
1124
|
* import { symlink } from 'fs';
|
|
1125
1125
|
*
|
|
1126
|
-
* symlink('./mew', './
|
|
1126
|
+
* symlink('./mew', './mewtwo', callback);
|
|
1127
1127
|
* ```
|
|
1128
1128
|
*
|
|
1129
|
-
* The above example creates a symbolic link `mewtwo`
|
|
1130
|
-
*
|
|
1129
|
+
* The above example creates a symbolic link `mewtwo` which points to `mew` in the
|
|
1130
|
+
* same directory:
|
|
1131
1131
|
*
|
|
1132
1132
|
* ```bash
|
|
1133
|
-
* $ tree
|
|
1134
|
-
*
|
|
1133
|
+
* $ tree .
|
|
1134
|
+
* .
|
|
1135
1135
|
* ├── mew
|
|
1136
1136
|
* └── mewtwo -> ./mew
|
|
1137
1137
|
* ```
|
|
@@ -2099,8 +2099,7 @@ declare module 'fs' {
|
|
|
2099
2099
|
*/
|
|
2100
2100
|
export function fsyncSync(fd: number): void;
|
|
2101
2101
|
/**
|
|
2102
|
-
* Write `buffer` to the file specified by `fd`.
|
|
2103
|
-
* must have an own `toString` function property.
|
|
2102
|
+
* Write `buffer` to the file specified by `fd`.
|
|
2104
2103
|
*
|
|
2105
2104
|
* `offset` determines the part of the buffer to be written, and `length` is
|
|
2106
2105
|
* an integer specifying the number of bytes to write.
|
|
@@ -2223,8 +2222,6 @@ declare module 'fs' {
|
|
|
2223
2222
|
}>;
|
|
2224
2223
|
}
|
|
2225
2224
|
/**
|
|
2226
|
-
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2227
|
-
*
|
|
2228
2225
|
* For detailed information, see the documentation of the asynchronous version of
|
|
2229
2226
|
* this API: {@link write}.
|
|
2230
2227
|
* @since v0.1.21
|
|
@@ -2296,10 +2293,7 @@ declare module 'fs' {
|
|
|
2296
2293
|
options: ReadAsyncOptions<TBuffer>,
|
|
2297
2294
|
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
|
2298
2295
|
): void;
|
|
2299
|
-
export function read(
|
|
2300
|
-
fd: number,
|
|
2301
|
-
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void
|
|
2302
|
-
): void;
|
|
2296
|
+
export function read(fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
|
|
2303
2297
|
export namespace read {
|
|
2304
2298
|
/**
|
|
2305
2299
|
* @param fd A file descriptor.
|
|
@@ -2325,9 +2319,7 @@ declare module 'fs' {
|
|
|
2325
2319
|
bytesRead: number;
|
|
2326
2320
|
buffer: TBuffer;
|
|
2327
2321
|
}>;
|
|
2328
|
-
function __promisify__(
|
|
2329
|
-
fd: number
|
|
2330
|
-
): Promise<{
|
|
2322
|
+
function __promisify__(fd: number): Promise<{
|
|
2331
2323
|
bytesRead: number;
|
|
2332
2324
|
buffer: NodeJS.ArrayBufferView;
|
|
2333
2325
|
}>;
|
|
@@ -2595,8 +2587,6 @@ declare module 'fs' {
|
|
|
2595
2587
|
*
|
|
2596
2588
|
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2597
2589
|
*
|
|
2598
|
-
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2599
|
-
*
|
|
2600
2590
|
* ```js
|
|
2601
2591
|
* import { writeFile } from 'fs';
|
|
2602
2592
|
* import { Buffer } from 'buffer';
|
|
@@ -2673,8 +2663,6 @@ declare module 'fs' {
|
|
|
2673
2663
|
/**
|
|
2674
2664
|
* Returns `undefined`.
|
|
2675
2665
|
*
|
|
2676
|
-
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2677
|
-
*
|
|
2678
2666
|
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2679
2667
|
*
|
|
2680
2668
|
* For detailed information, see the documentation of the asynchronous version of
|
|
@@ -3272,9 +3260,9 @@ declare module 'fs' {
|
|
|
3272
3260
|
/**
|
|
3273
3261
|
* Tests a user's permissions for the file or directory specified by `path`.
|
|
3274
3262
|
* The `mode` argument is an optional integer that specifies the accessibility
|
|
3275
|
-
* checks to be performed.
|
|
3276
|
-
*
|
|
3277
|
-
*
|
|
3263
|
+
* checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
|
3264
|
+
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
|
3265
|
+
* possible values of `mode`.
|
|
3278
3266
|
*
|
|
3279
3267
|
* The final argument, `callback`, is a callback function that is invoked with
|
|
3280
3268
|
* a possible error argument. If any of the accessibility checks fail, the error
|
|
@@ -3300,14 +3288,9 @@ declare module 'fs' {
|
|
|
3300
3288
|
* console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
|
|
3301
3289
|
* });
|
|
3302
3290
|
*
|
|
3303
|
-
* // Check if the file
|
|
3304
|
-
* access(file, constants.
|
|
3305
|
-
*
|
|
3306
|
-
* console.error(
|
|
3307
|
-
* `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
|
|
3308
|
-
* } else {
|
|
3309
|
-
* console.log(`${file} exists, and it is writable`);
|
|
3310
|
-
* }
|
|
3291
|
+
* // Check if the file is readable and writable.
|
|
3292
|
+
* access(file, constants.R_OK | constants.W_OK, (err) => {
|
|
3293
|
+
* console.log(`${file} ${err ? 'is not' : 'is'} readable and writable`);
|
|
3311
3294
|
* });
|
|
3312
3295
|
* ```
|
|
3313
3296
|
*
|
|
@@ -3451,10 +3434,9 @@ declare module 'fs' {
|
|
|
3451
3434
|
/**
|
|
3452
3435
|
* Synchronously tests a user's permissions for the file or directory specified
|
|
3453
3436
|
* by `path`. The `mode` argument is an optional integer that specifies the
|
|
3454
|
-
* accessibility checks to be performed.
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
* (e.g. `fs.constants.W_OK | fs.constants.R_OK`).
|
|
3437
|
+
* accessibility checks to be performed. `mode` should be either the value`fs.constants.F_OK` or a mask consisting of the bitwise OR of any of`fs.constants.R_OK`, `fs.constants.W_OK`, and
|
|
3438
|
+
* `fs.constants.X_OK` (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
|
3439
|
+
* possible values of `mode`.
|
|
3458
3440
|
*
|
|
3459
3441
|
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
|
3460
3442
|
* the method will return `undefined`.
|
|
@@ -3557,9 +3539,9 @@ declare module 'fs' {
|
|
|
3557
3539
|
/**
|
|
3558
3540
|
* `options` may also include a `start` option to allow writing data at some
|
|
3559
3541
|
* position past the beginning of the file, allowed values are in the
|
|
3560
|
-
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
|
3561
|
-
* it may require the `flags` option to be set to `r+` rather than the
|
|
3562
|
-
* The `encoding` can be any one of those accepted by `Buffer`.
|
|
3542
|
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
|
3543
|
+
* replacing it may require the `flags` option to be set to `r+` rather than the
|
|
3544
|
+
* default `w`. The `encoding` can be any one of those accepted by `Buffer`.
|
|
3563
3545
|
*
|
|
3564
3546
|
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
|
3565
3547
|
* then the file descriptor won't be closed, even if there's an error.
|
node/http.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* { 'content-length': '123',
|
|
14
14
|
* 'content-type': 'text/plain',
|
|
15
15
|
* 'connection': 'keep-alive',
|
|
16
|
-
* 'host': '
|
|
16
|
+
* 'host': 'example.com',
|
|
17
17
|
* 'accept': '*' }
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
* 'content-LENGTH', '123',
|
|
35
35
|
* 'content-type', 'text/plain',
|
|
36
36
|
* 'CONNECTION', 'keep-alive',
|
|
37
|
-
* 'Host', '
|
|
37
|
+
* 'Host', 'example.com',
|
|
38
38
|
* 'accepT', '*' ]
|
|
39
39
|
* ```
|
|
40
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
40
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js)
|
|
41
41
|
*/
|
|
42
42
|
declare module 'http' {
|
|
43
43
|
import * as stream from 'node:stream';
|
|
@@ -211,14 +211,12 @@ declare module 'http' {
|
|
|
211
211
|
* Limit the amount of time the parser will wait to receive the complete HTTP
|
|
212
212
|
* headers.
|
|
213
213
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* See `server.timeout` for more information on how timeout behavior can be
|
|
221
|
-
* customized.
|
|
214
|
+
* If the timeout expires, the server responds with status 408 without
|
|
215
|
+
* forwarding the request to the request listener and then closes the connection.
|
|
216
|
+
*
|
|
217
|
+
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
|
218
|
+
* potential Denial-of-Service attacks in case the server is deployed without a
|
|
219
|
+
* reverse proxy in front.
|
|
222
220
|
* @since v11.3.0, v10.14.0
|
|
223
221
|
*/
|
|
224
222
|
headersTimeout: number;
|
|
@@ -392,13 +390,13 @@ declare module 'http' {
|
|
|
392
390
|
* const headers = outgoingMessage.getHeaders();
|
|
393
391
|
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
|
394
392
|
* ```
|
|
395
|
-
* @since
|
|
393
|
+
* @since v7.7.0
|
|
396
394
|
*/
|
|
397
395
|
getHeaders(): OutgoingHttpHeaders;
|
|
398
396
|
/**
|
|
399
397
|
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
|
400
398
|
* names are lowercase.
|
|
401
|
-
* @since
|
|
399
|
+
* @since v7.7.0
|
|
402
400
|
*/
|
|
403
401
|
getHeaderNames(): string[];
|
|
404
402
|
/**
|
|
@@ -408,7 +406,7 @@ declare module 'http' {
|
|
|
408
406
|
* ```js
|
|
409
407
|
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
|
410
408
|
* ```
|
|
411
|
-
* @since
|
|
409
|
+
* @since v7.7.0
|
|
412
410
|
*/
|
|
413
411
|
hasHeader(name: string): boolean;
|
|
414
412
|
/**
|
|
@@ -418,6 +416,7 @@ declare module 'http' {
|
|
|
418
416
|
* outgoingMessage.removeHeader('Content-Encoding');
|
|
419
417
|
* ```
|
|
420
418
|
* @since v0.4.0
|
|
419
|
+
* @param name Header name
|
|
421
420
|
*/
|
|
422
421
|
removeHeader(name: string): void;
|
|
423
422
|
/**
|
|
@@ -608,7 +607,7 @@ declare module 'http' {
|
|
|
608
607
|
* The `request.aborted` property will be `true` if the request has
|
|
609
608
|
* been aborted.
|
|
610
609
|
* @since v0.11.14
|
|
611
|
-
* @deprecated Since v17.0.0 - Check `destroyed` instead.
|
|
610
|
+
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
|
612
611
|
*/
|
|
613
612
|
aborted: boolean;
|
|
614
613
|
/**
|
|
@@ -622,13 +621,58 @@ declare module 'http' {
|
|
|
622
621
|
*/
|
|
623
622
|
protocol: string;
|
|
624
623
|
/**
|
|
625
|
-
*
|
|
624
|
+
* When sending request through a keep-alive enabled agent, the underlying socket
|
|
625
|
+
* might be reused. But if server closes connection at unfortunate time, client
|
|
626
|
+
* may run into a 'ECONNRESET' error.
|
|
627
|
+
*
|
|
628
|
+
* ```js
|
|
629
|
+
* const http = require('http');
|
|
630
|
+
*
|
|
631
|
+
* // Server has a 5 seconds keep-alive timeout by default
|
|
632
|
+
* http
|
|
633
|
+
* .createServer((req, res) => {
|
|
634
|
+
* res.write('hello\n');
|
|
635
|
+
* res.end();
|
|
636
|
+
* })
|
|
637
|
+
* .listen(3000);
|
|
638
|
+
*
|
|
639
|
+
* setInterval(() => {
|
|
640
|
+
* // Adapting a keep-alive agent
|
|
641
|
+
* http.get('http://localhost:3000', { agent }, (res) => {
|
|
642
|
+
* res.on('data', (data) => {
|
|
643
|
+
* // Do nothing
|
|
644
|
+
* });
|
|
645
|
+
* });
|
|
646
|
+
* }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
|
|
647
|
+
* ```
|
|
648
|
+
*
|
|
649
|
+
* By marking a request whether it reused socket or not, we can do
|
|
650
|
+
* automatic error retry base on it.
|
|
651
|
+
*
|
|
652
|
+
* ```js
|
|
653
|
+
* const http = require('http');
|
|
654
|
+
* const agent = new http.Agent({ keepAlive: true });
|
|
655
|
+
*
|
|
656
|
+
* function retriableRequest() {
|
|
657
|
+
* const req = http
|
|
658
|
+
* .get('http://localhost:3000', { agent }, (res) => {
|
|
659
|
+
* // ...
|
|
660
|
+
* })
|
|
661
|
+
* .on('error', (err) => {
|
|
662
|
+
* // Check if retry is needed
|
|
663
|
+
* if (req.reusedSocket && err.code === 'ECONNRESET') {
|
|
664
|
+
* retriableRequest();
|
|
665
|
+
* }
|
|
666
|
+
* });
|
|
667
|
+
* }
|
|
668
|
+
*
|
|
669
|
+
* retriableRequest();
|
|
670
|
+
* ```
|
|
626
671
|
* @since v13.0.0, v12.16.0
|
|
627
672
|
*/
|
|
628
673
|
reusedSocket: boolean;
|
|
629
674
|
/**
|
|
630
675
|
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
|
631
|
-
* @default 2000
|
|
632
676
|
*/
|
|
633
677
|
maxHeadersCount: number;
|
|
634
678
|
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
|
@@ -788,7 +832,7 @@ declare module 'http' {
|
|
|
788
832
|
* The `message.aborted` property will be `true` if the request has
|
|
789
833
|
* been aborted.
|
|
790
834
|
* @since v10.1.0
|
|
791
|
-
* @deprecated Since v17.0.0 - Check `message.destroyed` from
|
|
835
|
+
* @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
|
|
792
836
|
*/
|
|
793
837
|
aborted: boolean;
|
|
794
838
|
/**
|
|
@@ -840,7 +884,7 @@ declare module 'http' {
|
|
|
840
884
|
*
|
|
841
885
|
* This property is guaranteed to be an instance of the `net.Socket` class,
|
|
842
886
|
* a subclass of `stream.Duplex`, unless the user specified a socket
|
|
843
|
-
* type other than `net.Socket
|
|
887
|
+
* type other than `net.Socket` or internally nulled.
|
|
844
888
|
* @since v0.3.0
|
|
845
889
|
*/
|
|
846
890
|
socket: Socket;
|
|
@@ -855,7 +899,7 @@ declare module 'http' {
|
|
|
855
899
|
* // { 'user-agent': 'curl/7.22.0',
|
|
856
900
|
* // host: '127.0.0.1:8000',
|
|
857
901
|
* // accept: '*' }
|
|
858
|
-
* console.log(request.
|
|
902
|
+
* console.log(request.getHeaders());
|
|
859
903
|
* ```
|
|
860
904
|
*
|
|
861
905
|
* Duplicates in raw headers are handled in the following ways, depending on the
|
|
@@ -931,14 +975,14 @@ declare module 'http' {
|
|
|
931
975
|
* To parse the URL into its parts:
|
|
932
976
|
*
|
|
933
977
|
* ```js
|
|
934
|
-
* new URL(request.url, `http://${request.
|
|
978
|
+
* new URL(request.url, `http://${request.getHeaders().host}`);
|
|
935
979
|
* ```
|
|
936
980
|
*
|
|
937
|
-
* When `request.url` is `'/status?name=ryan'` and`request.
|
|
981
|
+
* When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
|
|
938
982
|
*
|
|
939
983
|
* ```console
|
|
940
984
|
* $ node
|
|
941
|
-
* > new URL(request.url, `http://${request.
|
|
985
|
+
* > new URL(request.url, `http://${request.getHeaders().host}`)
|
|
942
986
|
* URL {
|
|
943
987
|
* href: 'http://localhost:3000/status?name=ryan',
|
|
944
988
|
* origin: 'http://localhost:3000',
|
|
@@ -1137,6 +1181,8 @@ declare module 'http' {
|
|
|
1137
1181
|
// create interface RequestOptions would make the naming more clear to developers
|
|
1138
1182
|
interface RequestOptions extends ClientRequestArgs {}
|
|
1139
1183
|
/**
|
|
1184
|
+
* `options` in `socket.connect()` are also supported.
|
|
1185
|
+
*
|
|
1140
1186
|
* Node.js maintains several connections per server to make HTTP requests.
|
|
1141
1187
|
* This function allows one to transparently issue requests.
|
|
1142
1188
|
*
|
node/http2.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* const http2 = require('http2');
|
|
7
7
|
* ```
|
|
8
8
|
* @since v8.4.0
|
|
9
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
9
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http2.js)
|
|
10
10
|
*/
|
|
11
11
|
declare module 'http2' {
|
|
12
12
|
import EventEmitter = require('node:events');
|
|
@@ -83,7 +83,7 @@ declare module 'http2' {
|
|
|
83
83
|
*/
|
|
84
84
|
readonly destroyed: boolean;
|
|
85
85
|
/**
|
|
86
|
-
* Set
|
|
86
|
+
* Set to `true` if the `END_STREAM` flag was set in the request or response
|
|
87
87
|
* HEADERS frame received, indicating that no additional data should be received
|
|
88
88
|
* and the readable side of the `Http2Stream` will be closed.
|
|
89
89
|
* @since v10.11.0
|
|
@@ -846,6 +846,11 @@ declare module 'http2' {
|
|
|
846
846
|
* For HTTP/2 Client `Http2Session` instances only, the `http2session.request()`creates and returns an `Http2Stream` instance that can be used to send an
|
|
847
847
|
* HTTP/2 request to the connected server.
|
|
848
848
|
*
|
|
849
|
+
* When a `ClientHttp2Session` is first created, the socket may not yet be
|
|
850
|
+
* connected. if `clienthttp2session.request()` is called during this time, the
|
|
851
|
+
* actual request will be deferred until the socket is ready to go.
|
|
852
|
+
* If the `session` is closed before the actual request be executed, an`ERR_HTTP2_GOAWAY_SESSION` is thrown.
|
|
853
|
+
*
|
|
849
854
|
* This method is only available if `http2session.type` is equal to`http2.constants.NGHTTP2_SESSION_CLIENT`.
|
|
850
855
|
*
|
|
851
856
|
* ```js
|
node/https.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
|
3
3
|
* separate module.
|
|
4
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
4
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js)
|
|
5
5
|
*/
|
|
6
6
|
declare module 'https' {
|
|
7
7
|
import { Duplex } from 'node:stream';
|
node/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for non-npm package Node.js
|
|
1
|
+
// Type definitions for non-npm package Node.js 18.0
|
|
2
2
|
// Project: https://nodejs.org/
|
|
3
3
|
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
|
4
4
|
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
/// <reference path="stream/consumers.d.ts" />
|
|
115
115
|
/// <reference path="stream/web.d.ts" />
|
|
116
116
|
/// <reference path="string_decoder.d.ts" />
|
|
117
|
+
/// <reference path="test.d.ts" />
|
|
117
118
|
/// <reference path="timers.d.ts" />
|
|
118
119
|
/// <reference path="timers/promises.d.ts" />
|
|
119
120
|
/// <reference path="tls.d.ts" />
|
node/inspector.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```js
|
|
16
16
|
* const inspector = require('inspector');
|
|
17
17
|
* ```
|
|
18
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
18
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/inspector.js)
|
|
19
19
|
*/
|
|
20
20
|
declare module 'inspector' {
|
|
21
21
|
import EventEmitter = require('node:events');
|
|
@@ -1688,7 +1688,7 @@ declare module 'inspector' {
|
|
|
1688
1688
|
/**
|
|
1689
1689
|
* Controls how the trace buffer stores data.
|
|
1690
1690
|
*/
|
|
1691
|
-
recordMode?: string;
|
|
1691
|
+
recordMode?: string | undefined;
|
|
1692
1692
|
/**
|
|
1693
1693
|
* Included category filters.
|
|
1694
1694
|
*/
|
|
@@ -1778,12 +1778,6 @@ declare module 'inspector' {
|
|
|
1778
1778
|
* @since v8.0.0
|
|
1779
1779
|
*/
|
|
1780
1780
|
connect(): void;
|
|
1781
|
-
/**
|
|
1782
|
-
* Connects a session to the main thread inspector back-end. An exception will
|
|
1783
|
-
* be thrown if this API was not called on a Worker thread.
|
|
1784
|
-
* @since v12.11.0
|
|
1785
|
-
*/
|
|
1786
|
-
connectToMainThread(): void;
|
|
1787
1781
|
/**
|
|
1788
1782
|
* Immediately close the session. All pending message callbacks will be called
|
|
1789
1783
|
* with an error. `session.connect()` will need to be called to be able to send
|
|
@@ -2695,7 +2689,7 @@ declare module 'inspector' {
|
|
|
2695
2689
|
prependOnceListener(event: 'NodeRuntime.waitingForDisconnect', listener: () => void): this;
|
|
2696
2690
|
}
|
|
2697
2691
|
/**
|
|
2698
|
-
* Activate inspector on host and port. Equivalent to
|
|
2692
|
+
* Activate inspector on host and port. Equivalent to`node --inspect=[[host:]port]`, but can be done programmatically after node has
|
|
2699
2693
|
* started.
|
|
2700
2694
|
*
|
|
2701
2695
|
* If wait is `true`, will block until a client has connected to the inspect port
|
|
@@ -2717,12 +2711,12 @@ declare module 'inspector' {
|
|
|
2717
2711
|
* ```console
|
|
2718
2712
|
* $ node --inspect -p 'inspector.url()'
|
|
2719
2713
|
* Debugger listening on ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34
|
|
2720
|
-
* For help see https://nodejs.org/en/docs/inspector
|
|
2714
|
+
* For help, see: https://nodejs.org/en/docs/inspector
|
|
2721
2715
|
* ws://127.0.0.1:9229/166e272e-7a30-4d09-97ce-f1c012b43c34
|
|
2722
2716
|
*
|
|
2723
2717
|
* $ node --inspect=localhost:3000 -p 'inspector.url()'
|
|
2724
2718
|
* Debugger listening on ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a
|
|
2725
|
-
* For help see https://nodejs.org/en/docs/inspector
|
|
2719
|
+
* For help, see: https://nodejs.org/en/docs/inspector
|
|
2726
2720
|
* ws://localhost:3000/51cf8d0e-3c36-4c59-8efd-54519839e56a
|
|
2727
2721
|
*
|
|
2728
2722
|
* $ node -p 'inspector.url()'
|
|
@@ -2738,7 +2732,10 @@ declare module 'inspector' {
|
|
|
2738
2732
|
*/
|
|
2739
2733
|
function waitForDebugger(): void;
|
|
2740
2734
|
}
|
|
2735
|
+
/**
|
|
2736
|
+
* The inspector module provides an API for interacting with the V8 inspector.
|
|
2737
|
+
*/
|
|
2741
2738
|
declare module 'node:inspector' {
|
|
2742
|
-
import
|
|
2743
|
-
export =
|
|
2739
|
+
import inspector = require('inspector');
|
|
2740
|
+
export = inspector;
|
|
2744
2741
|
}
|