@types/node 17.0.45 → 18.0.2
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 v17.0 → node}/LICENSE +0 -0
- node v17.0/README.md → node/README.md +3 -3
- {node v17.0 → node}/assert/strict.d.ts +0 -0
- node v17.0/assert.d.ts → node/assert.d.ts +7 -8
- node v17.0/async_hooks.d.ts → node/async_hooks.d.ts +2 -2
- node v17.0/buffer.d.ts → node/buffer.d.ts +11 -5
- node v17.0/child_process.d.ts → node/child_process.d.ts +6 -3
- node v17.0/cluster.d.ts → node/cluster.d.ts +14 -18
- node v17.0/console.d.ts → node/console.d.ts +1 -1
- {node v17.0 → node}/constants.d.ts +0 -0
- node v17.0/crypto.d.ts → node/crypto.d.ts +109 -37
- node v17.0/dgram.d.ts → node/dgram.d.ts +2 -2
- node v17.0/diagnostics_channel.d.ts → node/diagnostics_channel.d.ts +2 -1
- node v17.0/dns/promises.d.ts → node/dns/promises.d.ts +2 -2
- node v17.0/dns.d.ts → node/dns.d.ts +2 -2
- node v17.0/domain.d.ts → node/domain.d.ts +3 -2
- node v17.0/events.d.ts → node/events.d.ts +17 -27
- node v17.0/fs/promises.d.ts → node/fs/promises.d.ts +40 -17
- node v17.0/fs.d.ts → node/fs.d.ts +33 -44
- {node v17.0 → node}/globals.d.ts +0 -0
- {node v17.0 → node}/globals.global.d.ts +0 -0
- node v17.0/http.d.ts → node/http.d.ts +79 -23
- node v17.0/http2.d.ts → node/http2.d.ts +7 -2
- node v17.0/https.d.ts → node/https.d.ts +11 -1
- node v17.0/index.d.ts → node/index.d.ts +3 -1
- node v17.0/inspector.d.ts → node/inspector.d.ts +10 -13
- {node v17.0 → node}/module.d.ts +0 -0
- node v17.0/net.d.ts → node/net.d.ts +32 -7
- node v17.0/os.d.ts → node/os.d.ts +5 -4
- node v17.0/package.json → node/package.json +7 -2
- node v17.0/path.d.ts → node/path.d.ts +1 -1
- node v17.0/perf_hooks.d.ts → node/perf_hooks.d.ts +10 -2
- node v17.0/process.d.ts → node/process.d.ts +14 -13
- node v17.0/punycode.d.ts → node/punycode.d.ts +1 -1
- node v17.0/querystring.d.ts → node/querystring.d.ts +1 -1
- node v17.0/readline.d.ts → node/readline.d.ts +2 -2
- node v17.0/repl.d.ts → node/repl.d.ts +2 -2
- {node v17.0 → node}/stream/consumers.d.ts +0 -0
- {node v17.0 → node}/stream/promises.d.ts +0 -0
- {node v17.0 → node}/stream/web.d.ts +0 -0
- node v17.0/stream.d.ts → node/stream.d.ts +65 -15
- node v17.0/string_decoder.d.ts → node/string_decoder.d.ts +1 -1
- node/test.d.ts +142 -0
- {node v17.0 → node}/timers/promises.d.ts +0 -0
- node v17.0/timers.d.ts → node/timers.d.ts +3 -3
- node v17.0/tls.d.ts → node/tls.d.ts +18 -10
- node v17.0/trace_events.d.ts → node/trace_events.d.ts +11 -1
- node v17.0/tty.d.ts → node/tty.d.ts +4 -2
- node v17.0/url.d.ts → node/url.d.ts +25 -19
- node v17.0/util.d.ts → node/util.d.ts +20 -9
- node v17.0/v8.d.ts → node/v8.d.ts +19 -1
- node v17.0/vm.d.ts → node/vm.d.ts +5 -3
- node v17.0/wasi.d.ts → node/wasi.d.ts +1 -1
- node v17.0/worker_threads.d.ts → node/worker_threads.d.ts +2 -5
- node v17.0/zlib.d.ts → node/zlib.d.ts +1 -1
|
@@ -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
|
/**
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
declare module 'fs/promises' {
|
|
12
12
|
import { Abortable } from 'node:events';
|
|
13
13
|
import { Stream } from 'node:stream';
|
|
14
|
+
import { ReadableStream } from 'node:stream/web';
|
|
14
15
|
import {
|
|
15
16
|
Stats,
|
|
16
17
|
BigIntStats,
|
|
@@ -163,9 +164,9 @@ declare module 'fs/promises' {
|
|
|
163
164
|
/**
|
|
164
165
|
* `options` may also include a `start` option to allow writing data at some
|
|
165
166
|
* position past the beginning of the file, allowed values are in the
|
|
166
|
-
* \[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
|
|
167
|
-
* it may require the `flags` `open` option to be set to `r+` rather than
|
|
168
|
-
* 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`.
|
|
169
170
|
*
|
|
170
171
|
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
|
171
172
|
* then the file descriptor won't be closed, even if there's an error.
|
|
@@ -209,6 +210,29 @@ declare module 'fs/promises' {
|
|
|
209
210
|
*/
|
|
210
211
|
read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
|
211
212
|
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
|
213
|
+
/**
|
|
214
|
+
* Returns a `ReadableStream` that may be used to read the files data.
|
|
215
|
+
*
|
|
216
|
+
* An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
|
|
217
|
+
* or closing.
|
|
218
|
+
*
|
|
219
|
+
* ```js
|
|
220
|
+
* import { open } from 'node:fs/promises';
|
|
221
|
+
*
|
|
222
|
+
* const file = await open('./some/file/to/read');
|
|
223
|
+
*
|
|
224
|
+
* for await (const chunk of file.readableWebStream())
|
|
225
|
+
* console.log(chunk);
|
|
226
|
+
*
|
|
227
|
+
* await file.close();
|
|
228
|
+
* ```
|
|
229
|
+
*
|
|
230
|
+
* While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method.
|
|
231
|
+
*
|
|
232
|
+
* @since v17.0.0
|
|
233
|
+
* @experimental
|
|
234
|
+
*/
|
|
235
|
+
readableWebStream(): ReadableStream;
|
|
212
236
|
/**
|
|
213
237
|
* Asynchronously reads the entire contents of a file.
|
|
214
238
|
*
|
|
@@ -309,9 +333,8 @@ declare module 'fs/promises' {
|
|
|
309
333
|
/**
|
|
310
334
|
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
|
311
335
|
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
|
312
|
-
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object
|
|
313
|
-
*
|
|
314
|
-
* 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.
|
|
315
338
|
*
|
|
316
339
|
* If `options` is a string, then it specifies the `encoding`.
|
|
317
340
|
*
|
|
@@ -329,20 +352,18 @@ declare module 'fs/promises' {
|
|
|
329
352
|
/**
|
|
330
353
|
* Write `buffer` to the file.
|
|
331
354
|
*
|
|
332
|
-
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
333
|
-
*
|
|
334
355
|
* The promise is resolved with an object containing two properties:
|
|
335
356
|
*
|
|
336
357
|
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
|
337
358
|
* without waiting for the promise to be resolved (or rejected). For this
|
|
338
|
-
* scenario, use `
|
|
359
|
+
* scenario, use `filehandle.createWriteStream()`.
|
|
339
360
|
*
|
|
340
361
|
* On Linux, positional writes do not work when the file is opened in append mode.
|
|
341
362
|
* The kernel ignores the position argument and always appends the data to
|
|
342
363
|
* the end of the file.
|
|
343
364
|
* @since v10.0.0
|
|
344
365
|
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
|
345
|
-
* @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.
|
|
346
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.
|
|
347
368
|
* See the POSIX pwrite(2) documentation for more detail.
|
|
348
369
|
*/
|
|
@@ -408,9 +429,9 @@ declare module 'fs/promises' {
|
|
|
408
429
|
/**
|
|
409
430
|
* Tests a user's permissions for the file or directory specified by `path`.
|
|
410
431
|
* The `mode` argument is an optional integer that specifies the accessibility
|
|
411
|
-
* checks to be performed.
|
|
412
|
-
*
|
|
413
|
-
*
|
|
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`.
|
|
414
435
|
*
|
|
415
436
|
* If the accessibility check is successful, the promise is resolved with no
|
|
416
437
|
* value. If any of the accessibility checks fail, the promise is rejected
|
|
@@ -487,7 +508,7 @@ declare module 'fs/promises' {
|
|
|
487
508
|
* @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
|
|
488
509
|
* @return Fulfills with a {FileHandle} object.
|
|
489
510
|
*/
|
|
490
|
-
function open(path: PathLike, flags
|
|
511
|
+
function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
|
|
491
512
|
/**
|
|
492
513
|
* Renames `oldPath` to `newPath`.
|
|
493
514
|
* @since v10.0.0
|
|
@@ -830,7 +851,9 @@ declare module 'fs/promises' {
|
|
|
830
851
|
*/
|
|
831
852
|
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
832
853
|
/**
|
|
833
|
-
* 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.
|
|
834
857
|
*
|
|
835
858
|
* The `encoding` option is ignored if `data` is a buffer.
|
|
836
859
|
*
|
|
@@ -845,7 +868,7 @@ declare module 'fs/promises' {
|
|
|
845
868
|
*
|
|
846
869
|
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
|
847
870
|
* method that performs multiple `write` calls internally to write the buffer
|
|
848
|
-
* 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()`.
|
|
849
872
|
*
|
|
850
873
|
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
|
851
874
|
* Cancelation is "best effort", and some amount of data is likely still
|
|
@@ -1084,7 +1107,7 @@ declare module 'fs/promises' {
|
|
|
1084
1107
|
* @param dest destination path to copy to.
|
|
1085
1108
|
* @return Fulfills with `undefined` upon success.
|
|
1086
1109
|
*/
|
|
1087
|
-
function cp(source: string, destination: string, opts?: CopyOptions): Promise<void>;
|
|
1110
|
+
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
|
|
1088
1111
|
}
|
|
1089
1112
|
declare module 'node:fs/promises' {
|
|
1090
1113
|
export * from 'fs/promises';
|
|
@@ -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
|
* ```
|
|
@@ -1998,12 +1998,19 @@ declare module 'fs' {
|
|
|
1998
1998
|
* @param [flags='r'] See `support of file system `flags``.
|
|
1999
1999
|
* @param [mode=0o666]
|
|
2000
2000
|
*/
|
|
2001
|
-
export function open(path: PathLike, flags: OpenMode, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
2001
|
+
export function open(path: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
2002
|
+
/**
|
|
2003
|
+
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
|
|
2004
|
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
2005
|
+
* @param [flags='r'] See `support of file system `flags``.
|
|
2006
|
+
*/
|
|
2007
|
+
export function open(path: PathLike, flags: OpenMode | undefined, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
2002
2008
|
/**
|
|
2003
2009
|
* Asynchronous open(2) - open and possibly create a file. If the file is created, its mode will be `0o666`.
|
|
2004
2010
|
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
2005
2011
|
*/
|
|
2006
|
-
export function open(path: PathLike,
|
|
2012
|
+
export function open(path: PathLike, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void;
|
|
2013
|
+
|
|
2007
2014
|
export namespace open {
|
|
2008
2015
|
/**
|
|
2009
2016
|
* Asynchronous open(2) - open and possibly create a file.
|
|
@@ -2092,8 +2099,7 @@ declare module 'fs' {
|
|
|
2092
2099
|
*/
|
|
2093
2100
|
export function fsyncSync(fd: number): void;
|
|
2094
2101
|
/**
|
|
2095
|
-
* Write `buffer` to the file specified by `fd`.
|
|
2096
|
-
* must have an own `toString` function property.
|
|
2102
|
+
* Write `buffer` to the file specified by `fd`.
|
|
2097
2103
|
*
|
|
2098
2104
|
* `offset` determines the part of the buffer to be written, and `length` is
|
|
2099
2105
|
* an integer specifying the number of bytes to write.
|
|
@@ -2216,8 +2222,6 @@ declare module 'fs' {
|
|
|
2216
2222
|
}>;
|
|
2217
2223
|
}
|
|
2218
2224
|
/**
|
|
2219
|
-
* If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2220
|
-
*
|
|
2221
2225
|
* For detailed information, see the documentation of the asynchronous version of
|
|
2222
2226
|
* this API: {@link write}.
|
|
2223
2227
|
* @since v0.1.21
|
|
@@ -2289,10 +2293,7 @@ declare module 'fs' {
|
|
|
2289
2293
|
options: ReadAsyncOptions<TBuffer>,
|
|
2290
2294
|
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void
|
|
2291
2295
|
): void;
|
|
2292
|
-
export function read(
|
|
2293
|
-
fd: number,
|
|
2294
|
-
callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void
|
|
2295
|
-
): void;
|
|
2296
|
+
export function read(fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
|
|
2296
2297
|
export namespace read {
|
|
2297
2298
|
/**
|
|
2298
2299
|
* @param fd A file descriptor.
|
|
@@ -2318,9 +2319,7 @@ declare module 'fs' {
|
|
|
2318
2319
|
bytesRead: number;
|
|
2319
2320
|
buffer: TBuffer;
|
|
2320
2321
|
}>;
|
|
2321
|
-
function __promisify__(
|
|
2322
|
-
fd: number
|
|
2323
|
-
): Promise<{
|
|
2322
|
+
function __promisify__(fd: number): Promise<{
|
|
2324
2323
|
bytesRead: number;
|
|
2325
2324
|
buffer: NodeJS.ArrayBufferView;
|
|
2326
2325
|
}>;
|
|
@@ -2588,8 +2587,6 @@ declare module 'fs' {
|
|
|
2588
2587
|
*
|
|
2589
2588
|
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2590
2589
|
*
|
|
2591
|
-
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2592
|
-
*
|
|
2593
2590
|
* ```js
|
|
2594
2591
|
* import { writeFile } from 'fs';
|
|
2595
2592
|
* import { Buffer } from 'buffer';
|
|
@@ -2666,8 +2663,6 @@ declare module 'fs' {
|
|
|
2666
2663
|
/**
|
|
2667
2664
|
* Returns `undefined`.
|
|
2668
2665
|
*
|
|
2669
|
-
* If `data` is a plain object, it must have an own (not inherited) `toString`function property.
|
|
2670
|
-
*
|
|
2671
2666
|
* The `mode` option only affects the newly created file. See {@link open} for more details.
|
|
2672
2667
|
*
|
|
2673
2668
|
* For detailed information, see the documentation of the asynchronous version of
|
|
@@ -3265,9 +3260,9 @@ declare module 'fs' {
|
|
|
3265
3260
|
/**
|
|
3266
3261
|
* Tests a user's permissions for the file or directory specified by `path`.
|
|
3267
3262
|
* The `mode` argument is an optional integer that specifies the accessibility
|
|
3268
|
-
* checks to be performed.
|
|
3269
|
-
*
|
|
3270
|
-
*
|
|
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`.
|
|
3271
3266
|
*
|
|
3272
3267
|
* The final argument, `callback`, is a callback function that is invoked with
|
|
3273
3268
|
* a possible error argument. If any of the accessibility checks fail, the error
|
|
@@ -3293,14 +3288,9 @@ declare module 'fs' {
|
|
|
3293
3288
|
* console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);
|
|
3294
3289
|
* });
|
|
3295
3290
|
*
|
|
3296
|
-
* // Check if the file
|
|
3297
|
-
* access(file, constants.
|
|
3298
|
-
*
|
|
3299
|
-
* console.error(
|
|
3300
|
-
* `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
|
|
3301
|
-
* } else {
|
|
3302
|
-
* console.log(`${file} exists, and it is writable`);
|
|
3303
|
-
* }
|
|
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`);
|
|
3304
3294
|
* });
|
|
3305
3295
|
* ```
|
|
3306
3296
|
*
|
|
@@ -3444,10 +3434,9 @@ declare module 'fs' {
|
|
|
3444
3434
|
/**
|
|
3445
3435
|
* Synchronously tests a user's permissions for the file or directory specified
|
|
3446
3436
|
* by `path`. The `mode` argument is an optional integer that specifies the
|
|
3447
|
-
* accessibility checks to be performed.
|
|
3448
|
-
*
|
|
3449
|
-
*
|
|
3450
|
-
* (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`.
|
|
3451
3440
|
*
|
|
3452
3441
|
* If any of the accessibility checks fail, an `Error` will be thrown. Otherwise,
|
|
3453
3442
|
* the method will return `undefined`.
|
|
@@ -3550,9 +3539,9 @@ declare module 'fs' {
|
|
|
3550
3539
|
/**
|
|
3551
3540
|
* `options` may also include a `start` option to allow writing data at some
|
|
3552
3541
|
* position past the beginning of the file, allowed values are in the
|
|
3553
|
-
* \[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
|
|
3554
|
-
* it may require the `flags` option to be set to `r+` rather than the
|
|
3555
|
-
* 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`.
|
|
3556
3545
|
*
|
|
3557
3546
|
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
|
3558
3547
|
* then the file descriptor won't be closed, even if there's an error.
|
|
@@ -3849,8 +3838,8 @@ declare module 'fs' {
|
|
|
3849
3838
|
* @param src source path to copy.
|
|
3850
3839
|
* @param dest destination path to copy to.
|
|
3851
3840
|
*/
|
|
3852
|
-
export function cp(source: string, destination: string, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3853
|
-
export function cp(source: string, destination: string, opts: CopyOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3841
|
+
export function cp(source: string | URL, destination: string | URL, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3842
|
+
export function cp(source: string | URL, destination: string | URL, opts: CopyOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
|
|
3854
3843
|
/**
|
|
3855
3844
|
* Synchronously copies the entire directory structure from `src` to `dest`,
|
|
3856
3845
|
* including subdirectories and files.
|
|
@@ -3862,7 +3851,7 @@ declare module 'fs' {
|
|
|
3862
3851
|
* @param src source path to copy.
|
|
3863
3852
|
* @param dest destination path to copy to.
|
|
3864
3853
|
*/
|
|
3865
|
-
export function cpSync(source: string, destination: string, opts?: CopyOptions): void;
|
|
3854
|
+
export function cpSync(source: string | URL, destination: string | URL, opts?: CopyOptions): void;
|
|
3866
3855
|
}
|
|
3867
3856
|
declare module 'node:fs' {
|
|
3868
3857
|
export * from 'fs';
|
{node v17.0 → node}/globals.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -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;
|
|
@@ -251,6 +249,16 @@ declare module 'http' {
|
|
|
251
249
|
* @since v14.11.0
|
|
252
250
|
*/
|
|
253
251
|
requestTimeout: number;
|
|
252
|
+
/**
|
|
253
|
+
* Closes all connections connected to this server.
|
|
254
|
+
* @since v18.2.0
|
|
255
|
+
*/
|
|
256
|
+
closeAllConnections(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
|
259
|
+
* @since v18.2.0
|
|
260
|
+
*/
|
|
261
|
+
closeIdleConnections(): void;
|
|
254
262
|
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
255
263
|
addListener(event: 'close', listener: () => void): this;
|
|
256
264
|
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
|
@@ -392,13 +400,13 @@ declare module 'http' {
|
|
|
392
400
|
* const headers = outgoingMessage.getHeaders();
|
|
393
401
|
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
|
394
402
|
* ```
|
|
395
|
-
* @since
|
|
403
|
+
* @since v7.7.0
|
|
396
404
|
*/
|
|
397
405
|
getHeaders(): OutgoingHttpHeaders;
|
|
398
406
|
/**
|
|
399
407
|
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
|
400
408
|
* names are lowercase.
|
|
401
|
-
* @since
|
|
409
|
+
* @since v7.7.0
|
|
402
410
|
*/
|
|
403
411
|
getHeaderNames(): string[];
|
|
404
412
|
/**
|
|
@@ -408,7 +416,7 @@ declare module 'http' {
|
|
|
408
416
|
* ```js
|
|
409
417
|
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
|
410
418
|
* ```
|
|
411
|
-
* @since
|
|
419
|
+
* @since v7.7.0
|
|
412
420
|
*/
|
|
413
421
|
hasHeader(name: string): boolean;
|
|
414
422
|
/**
|
|
@@ -418,6 +426,7 @@ declare module 'http' {
|
|
|
418
426
|
* outgoingMessage.removeHeader('Content-Encoding');
|
|
419
427
|
* ```
|
|
420
428
|
* @since v0.4.0
|
|
429
|
+
* @param name Header name
|
|
421
430
|
*/
|
|
422
431
|
removeHeader(name: string): void;
|
|
423
432
|
/**
|
|
@@ -608,7 +617,7 @@ declare module 'http' {
|
|
|
608
617
|
* The `request.aborted` property will be `true` if the request has
|
|
609
618
|
* been aborted.
|
|
610
619
|
* @since v0.11.14
|
|
611
|
-
* @deprecated Since v17.0.0 - Check `destroyed` instead.
|
|
620
|
+
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
|
612
621
|
*/
|
|
613
622
|
aborted: boolean;
|
|
614
623
|
/**
|
|
@@ -622,13 +631,58 @@ declare module 'http' {
|
|
|
622
631
|
*/
|
|
623
632
|
protocol: string;
|
|
624
633
|
/**
|
|
625
|
-
*
|
|
634
|
+
* When sending request through a keep-alive enabled agent, the underlying socket
|
|
635
|
+
* might be reused. But if server closes connection at unfortunate time, client
|
|
636
|
+
* may run into a 'ECONNRESET' error.
|
|
637
|
+
*
|
|
638
|
+
* ```js
|
|
639
|
+
* const http = require('http');
|
|
640
|
+
*
|
|
641
|
+
* // Server has a 5 seconds keep-alive timeout by default
|
|
642
|
+
* http
|
|
643
|
+
* .createServer((req, res) => {
|
|
644
|
+
* res.write('hello\n');
|
|
645
|
+
* res.end();
|
|
646
|
+
* })
|
|
647
|
+
* .listen(3000);
|
|
648
|
+
*
|
|
649
|
+
* setInterval(() => {
|
|
650
|
+
* // Adapting a keep-alive agent
|
|
651
|
+
* http.get('http://localhost:3000', { agent }, (res) => {
|
|
652
|
+
* res.on('data', (data) => {
|
|
653
|
+
* // Do nothing
|
|
654
|
+
* });
|
|
655
|
+
* });
|
|
656
|
+
* }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
|
|
657
|
+
* ```
|
|
658
|
+
*
|
|
659
|
+
* By marking a request whether it reused socket or not, we can do
|
|
660
|
+
* automatic error retry base on it.
|
|
661
|
+
*
|
|
662
|
+
* ```js
|
|
663
|
+
* const http = require('http');
|
|
664
|
+
* const agent = new http.Agent({ keepAlive: true });
|
|
665
|
+
*
|
|
666
|
+
* function retriableRequest() {
|
|
667
|
+
* const req = http
|
|
668
|
+
* .get('http://localhost:3000', { agent }, (res) => {
|
|
669
|
+
* // ...
|
|
670
|
+
* })
|
|
671
|
+
* .on('error', (err) => {
|
|
672
|
+
* // Check if retry is needed
|
|
673
|
+
* if (req.reusedSocket && err.code === 'ECONNRESET') {
|
|
674
|
+
* retriableRequest();
|
|
675
|
+
* }
|
|
676
|
+
* });
|
|
677
|
+
* }
|
|
678
|
+
*
|
|
679
|
+
* retriableRequest();
|
|
680
|
+
* ```
|
|
626
681
|
* @since v13.0.0, v12.16.0
|
|
627
682
|
*/
|
|
628
683
|
reusedSocket: boolean;
|
|
629
684
|
/**
|
|
630
685
|
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
|
631
|
-
* @default 2000
|
|
632
686
|
*/
|
|
633
687
|
maxHeadersCount: number;
|
|
634
688
|
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
|
@@ -788,7 +842,7 @@ declare module 'http' {
|
|
|
788
842
|
* The `message.aborted` property will be `true` if the request has
|
|
789
843
|
* been aborted.
|
|
790
844
|
* @since v10.1.0
|
|
791
|
-
* @deprecated Since v17.0.0 - Check `message.destroyed` from
|
|
845
|
+
* @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
|
|
792
846
|
*/
|
|
793
847
|
aborted: boolean;
|
|
794
848
|
/**
|
|
@@ -840,7 +894,7 @@ declare module 'http' {
|
|
|
840
894
|
*
|
|
841
895
|
* This property is guaranteed to be an instance of the `net.Socket` class,
|
|
842
896
|
* a subclass of `stream.Duplex`, unless the user specified a socket
|
|
843
|
-
* type other than `net.Socket
|
|
897
|
+
* type other than `net.Socket` or internally nulled.
|
|
844
898
|
* @since v0.3.0
|
|
845
899
|
*/
|
|
846
900
|
socket: Socket;
|
|
@@ -855,7 +909,7 @@ declare module 'http' {
|
|
|
855
909
|
* // { 'user-agent': 'curl/7.22.0',
|
|
856
910
|
* // host: '127.0.0.1:8000',
|
|
857
911
|
* // accept: '*' }
|
|
858
|
-
* console.log(request.
|
|
912
|
+
* console.log(request.getHeaders());
|
|
859
913
|
* ```
|
|
860
914
|
*
|
|
861
915
|
* Duplicates in raw headers are handled in the following ways, depending on the
|
|
@@ -931,14 +985,14 @@ declare module 'http' {
|
|
|
931
985
|
* To parse the URL into its parts:
|
|
932
986
|
*
|
|
933
987
|
* ```js
|
|
934
|
-
* new URL(request.url, `http://${request.
|
|
988
|
+
* new URL(request.url, `http://${request.getHeaders().host}`);
|
|
935
989
|
* ```
|
|
936
990
|
*
|
|
937
|
-
* When `request.url` is `'/status?name=ryan'` and`request.
|
|
991
|
+
* When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
|
|
938
992
|
*
|
|
939
993
|
* ```console
|
|
940
994
|
* $ node
|
|
941
|
-
* > new URL(request.url, `http://${request.
|
|
995
|
+
* > new URL(request.url, `http://${request.getHeaders().host}`)
|
|
942
996
|
* URL {
|
|
943
997
|
* href: 'http://localhost:3000/status?name=ryan',
|
|
944
998
|
* origin: 'http://localhost:3000',
|
|
@@ -1137,6 +1191,8 @@ declare module 'http' {
|
|
|
1137
1191
|
// create interface RequestOptions would make the naming more clear to developers
|
|
1138
1192
|
interface RequestOptions extends ClientRequestArgs {}
|
|
1139
1193
|
/**
|
|
1194
|
+
* `options` in `socket.connect()` are also supported.
|
|
1195
|
+
*
|
|
1140
1196
|
* Node.js maintains several connections per server to make HTTP requests.
|
|
1141
1197
|
* This function allows one to transparently issue requests.
|
|
1142
1198
|
*
|
|
@@ -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
|