@types/node 16.4.14 → 16.7.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/fs.d.ts CHANGED
@@ -5,30 +5,18 @@
5
5
  * To use the promise-based APIs:
6
6
  *
7
7
  * ```js
8
- * // Using ESM Module syntax:
9
8
  * import * as fs from 'fs/promises';
10
9
  * ```
11
10
  *
12
- * ```js
13
- * // Using CommonJS syntax:
14
- * const fs = require('fs/promises');
15
- * ```
16
- *
17
11
  * To use the callback and sync APIs:
18
12
  *
19
13
  * ```js
20
- * // Using ESM Module syntax:
21
14
  * import * as fs from 'fs';
22
15
  * ```
23
16
  *
24
- * ```js
25
- * // Using CommonJS syntax:
26
- * const fs = require('fs');
27
- * ```
28
- *
29
17
  * All file system operations have synchronous, callback, and promise-based
30
18
  * forms, and are accessible using both CommonJS syntax and ES6 Modules (ESM).
31
- * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/fs.js)
19
+ * @see [source](https://github.com/nodejs/node/blob/v16.7.0/lib/fs.js)
32
20
  */
33
21
  declare module 'fs' {
34
22
  import * as stream from 'node:stream';
@@ -83,7 +71,7 @@ declare module 'fs' {
83
71
  }
84
72
  export interface Stats extends StatsBase<number> {}
85
73
  /**
86
- * A `<fs.Stats>` object provides information about a file.
74
+ * A `fs.Stats` object provides information about a file.
87
75
  *
88
76
  * Objects returned from {@link stat}, {@link lstat} and {@link fstat} and
89
77
  * their synchronous counterparts are of this type.
@@ -145,53 +133,53 @@ declare module 'fs' {
145
133
  export class Stats {}
146
134
  /**
147
135
  * A representation of a directory entry, which can be a file or a subdirectory
148
- * within the directory, as returned by reading from an `<fs.Dir>`. The
136
+ * within the directory, as returned by reading from an `fs.Dir`. The
149
137
  * directory entry is a combination of the file name and file type pairs.
150
138
  *
151
139
  * Additionally, when {@link readdir} or {@link readdirSync} is called with
152
- * the `withFileTypes` option set to `true`, the resulting array is filled with `<fs.Dirent>` objects, rather than strings or `<Buffer>` s.
140
+ * the `withFileTypes` option set to `true`, the resulting array is filled with `fs.Dirent` objects, rather than strings or `Buffer` s.
153
141
  * @since v10.10.0
154
142
  */
155
143
  export class Dirent {
156
144
  /**
157
- * Returns `true` if the `<fs.Dirent>` object describes a regular file.
145
+ * Returns `true` if the `fs.Dirent` object describes a regular file.
158
146
  * @since v10.10.0
159
147
  */
160
148
  isFile(): boolean;
161
149
  /**
162
- * Returns `true` if the `<fs.Dirent>` object describes a file system
150
+ * Returns `true` if the `fs.Dirent` object describes a file system
163
151
  * directory.
164
152
  * @since v10.10.0
165
153
  */
166
154
  isDirectory(): boolean;
167
155
  /**
168
- * Returns `true` if the `<fs.Dirent>` object describes a block device.
156
+ * Returns `true` if the `fs.Dirent` object describes a block device.
169
157
  * @since v10.10.0
170
158
  */
171
159
  isBlockDevice(): boolean;
172
160
  /**
173
- * Returns `true` if the `<fs.Dirent>` object describes a character device.
161
+ * Returns `true` if the `fs.Dirent` object describes a character device.
174
162
  * @since v10.10.0
175
163
  */
176
164
  isCharacterDevice(): boolean;
177
165
  /**
178
- * Returns `true` if the `<fs.Dirent>` object describes a symbolic link.
166
+ * Returns `true` if the `fs.Dirent` object describes a symbolic link.
179
167
  * @since v10.10.0
180
168
  */
181
169
  isSymbolicLink(): boolean;
182
170
  /**
183
- * Returns `true` if the `<fs.Dirent>` object describes a first-in-first-out
171
+ * Returns `true` if the `fs.Dirent` object describes a first-in-first-out
184
172
  * (FIFO) pipe.
185
173
  * @since v10.10.0
186
174
  */
187
175
  isFIFO(): boolean;
188
176
  /**
189
- * Returns `true` if the `<fs.Dirent>` object describes a socket.
177
+ * Returns `true` if the `fs.Dirent` object describes a socket.
190
178
  * @since v10.10.0
191
179
  */
192
180
  isSocket(): boolean;
193
181
  /**
194
- * The file name that this `<fs.Dirent>` object refers to. The type of this
182
+ * The file name that this `fs.Dirent` object refers to. The type of this
195
183
  * value is determined by the `options.encoding` passed to {@link readdir} or {@link readdirSync}.
196
184
  * @since v10.10.0
197
185
  */
@@ -214,7 +202,7 @@ declare module 'fs' {
214
202
  * }
215
203
  * ```
216
204
  *
217
- * When using the async iterator, the `<fs.Dir>` object will be automatically
205
+ * When using the async iterator, the `fs.Dir` object will be automatically
218
206
  * closed after the iterator exits.
219
207
  * @since v12.12.0
220
208
  */
@@ -245,9 +233,9 @@ declare module 'fs' {
245
233
  */
246
234
  closeSync(): void;
247
235
  /**
248
- * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `<fs.Dirent>`.
236
+ * Asynchronously read the next directory entry via [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) as an `fs.Dirent`.
249
237
  *
250
- * A promise is returned that will be resolved with an `<fs.Dirent>`, or `null`if there are no more directory entries to read.
238
+ * A promise is returned that will be resolved with an `fs.Dirent`, or `null`if there are no more directory entries to read.
251
239
  *
252
240
  * Directory entries returned by this function are in no particular order as
253
241
  * provided by the operating system's underlying directory mechanisms.
@@ -259,7 +247,7 @@ declare module 'fs' {
259
247
  read(): Promise<Dirent | null>;
260
248
  read(cb: (err: NodeJS.ErrnoException | null, dirEnt: Dirent | null) => void): void;
261
249
  /**
262
- * Synchronously read the next directory entry as an `<fs.Dirent>`. See the
250
+ * Synchronously read the next directory entry as an `fs.Dirent`. See the
263
251
  * POSIX [`readdir(3)`](http://man7.org/linux/man-pages/man3/readdir.3.html) documentation for more detail.
264
252
  *
265
253
  * If there are no more directory entries to read, `null` will be returned.
@@ -274,7 +262,7 @@ declare module 'fs' {
274
262
  }
275
263
  export interface FSWatcher extends EventEmitter {
276
264
  /**
277
- * Stop watching for changes on the given `<fs.FSWatcher>`. Once stopped, the `<fs.FSWatcher>` object is no longer usable.
265
+ * Stop watching for changes on the given `fs.FSWatcher`. Once stopped, the `fs.FSWatcher` object is no longer usable.
278
266
  * @since v0.5.8
279
267
  */
280
268
  close(): void;
@@ -305,7 +293,7 @@ declare module 'fs' {
305
293
  prependOnceListener(event: 'close', listener: () => void): this;
306
294
  }
307
295
  /**
308
- * Instances of `<fs.ReadStream>` are created and returned using the {@link createReadStream} function.
296
+ * Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.
309
297
  * @since v0.1.93
310
298
  */
311
299
  export class ReadStream extends stream.Readable {
@@ -317,8 +305,8 @@ declare module 'fs' {
317
305
  bytesRead: number;
318
306
  /**
319
307
  * The path to the file the stream is reading from as specified in the first
320
- * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `<Buffer>`, then`readStream.path` will be a
321
- * `<Buffer>`.
308
+ * argument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a
309
+ * `Buffer`.
322
310
  * @since v0.1.93
323
311
  */
324
312
  path: string | Buffer;
@@ -386,9 +374,9 @@ declare module 'fs' {
386
374
  prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
387
375
  }
388
376
  /**
389
- * * Extends `<stream.Writable>`
377
+ * * Extends `stream.Writable`
390
378
  *
391
- * Instances of `<fs.WriteStream>` are created and returned using the {@link createWriteStream} function.
379
+ * Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.
392
380
  * @since v0.1.93
393
381
  */
394
382
  export class WriteStream extends stream.Writable {
@@ -406,8 +394,8 @@ declare module 'fs' {
406
394
  bytesWritten: number;
407
395
  /**
408
396
  * The path to the file the stream is writing to as specified in the first
409
- * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `<Buffer>`, then`writeStream.path` will be a
410
- * `<Buffer>`.
397
+ * argument to {@link createWriteStream}. If `path` is passed as a string, then`writeStream.path` will be a string. If `path` is passed as a `Buffer`, then`writeStream.path` will be a
398
+ * `Buffer`.
411
399
  * @since v0.1.93
412
400
  */
413
401
  path: string | Buffer;
@@ -511,6 +499,15 @@ declare module 'fs' {
511
499
  * given to the completion callback. A file descriptor can also be passed as the
512
500
  * first argument. In this case, `fs.ftruncate()` is called.
513
501
  *
502
+ * ```js
503
+ * import { truncate } from 'fs';
504
+ * // Assuming that 'path/file.txt' is a regular file.
505
+ * truncate('path/file.txt', (err) => {
506
+ * if (err) throw err;
507
+ * console.log('path/file.txt was truncated');
508
+ * });
509
+ * ```
510
+ *
514
511
  * Passing a file descriptor is deprecated and may result in an error being thrown
515
512
  * in the future.
516
513
  *
@@ -789,7 +786,7 @@ declare module 'fs' {
789
786
  */
790
787
  export function lchmodSync(path: PathLike, mode: Mode): void;
791
788
  /**
792
- * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `<fs.Stats>` object.
789
+ * Asynchronous [`stat(2)`](http://man7.org/linux/man-pages/man2/stat.2.html). The callback gets two arguments `(err, stats)` where`stats` is an `fs.Stats` object.
793
790
  *
794
791
  * In case of an error, the `err.code` will be one of `Common System Errors`.
795
792
  *
@@ -950,7 +947,7 @@ declare module 'fs' {
950
947
  */
951
948
  export const statSync: StatSyncFn;
952
949
  /**
953
- * Invokes the callback with the `<fs.Stats>` for the file descriptor.
950
+ * Invokes the callback with the `fs.Stats` for the file descriptor.
954
951
  *
955
952
  * See the POSIX [`fstat(2)`](http://man7.org/linux/man-pages/man2/fstat.2.html) documentation for more detail.
956
953
  * @since v0.1.95
@@ -998,8 +995,8 @@ declare module 'fs' {
998
995
  */
999
996
  export const fstatSync: StatSyncFn<number>;
1000
997
  /**
1001
- * Retrieves the `<fs.Stats>` for the symbolic link referred to by the path.
1002
- * The callback gets two arguments `(err, stats)` where `stats` is a `<fs.Stats>` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
998
+ * Retrieves the `fs.Stats` for the symbolic link referred to by the path.
999
+ * The callback gets two arguments `(err, stats)` where `stats` is a `fs.Stats` object. `lstat()` is identical to `stat()`, except that if `path` is a symbolic
1003
1000
  * link, then the link itself is stat-ed, not the file that it refers to.
1004
1001
  *
1005
1002
  * See the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) documentation for more details.
@@ -1133,7 +1130,7 @@ declare module 'fs' {
1133
1130
  * The optional `options` argument can be a string specifying an encoding, or an
1134
1131
  * object with an `encoding` property specifying the character encoding to use for
1135
1132
  * the link path passed to the callback. If the `encoding` is set to `'buffer'`,
1136
- * the link path returned will be passed as a `<Buffer>` object.
1133
+ * the link path returned will be passed as a `Buffer` object.
1137
1134
  * @since v0.1.31
1138
1135
  */
1139
1136
  export function readlink(path: PathLike, options: EncodingOption, callback: (err: NodeJS.ErrnoException | null, linkString: string) => void): void;
@@ -1182,7 +1179,7 @@ declare module 'fs' {
1182
1179
  * The optional `options` argument can be a string specifying an encoding, or an
1183
1180
  * object with an `encoding` property specifying the character encoding to use for
1184
1181
  * the link path returned. If the `encoding` is set to `'buffer'`,
1185
- * the link path returned will be passed as a `<Buffer>` object.
1182
+ * the link path returned will be passed as a `Buffer` object.
1186
1183
  * @since v0.1.31
1187
1184
  */
1188
1185
  export function readlinkSync(path: PathLike, options?: EncodingOption): string;
@@ -1218,7 +1215,7 @@ declare module 'fs' {
1218
1215
  * The optional `options` argument can be a string specifying an encoding, or an
1219
1216
  * object with an `encoding` property specifying the character encoding to use for
1220
1217
  * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1221
- * the path returned will be passed as a `<Buffer>` object.
1218
+ * the path returned will be passed as a `Buffer` object.
1222
1219
  *
1223
1220
  * If `path` resolves to a socket or a pipe, the function will return a system
1224
1221
  * dependent name for that object.
@@ -1271,7 +1268,7 @@ declare module 'fs' {
1271
1268
  * The optional `options` argument can be a string specifying an encoding, or an
1272
1269
  * object with an `encoding` property specifying the character encoding to use for
1273
1270
  * the path passed to the callback. If the `encoding` is set to `'buffer'`,
1274
- * the path returned will be passed as a `<Buffer>` object.
1271
+ * the path returned will be passed as a `Buffer` object.
1275
1272
  *
1276
1273
  * On Linux, when Node.js is linked against musl libc, the procfs file system must
1277
1274
  * be mounted on `/proc` in order for this function to work. Glibc does not have
@@ -1731,9 +1728,9 @@ declare module 'fs' {
1731
1728
  * The optional `options` argument can be a string specifying an encoding, or an
1732
1729
  * object with an `encoding` property specifying the character encoding to use for
1733
1730
  * the filenames passed to the callback. If the `encoding` is set to `'buffer'`,
1734
- * the filenames returned will be passed as `<Buffer>` objects.
1731
+ * the filenames returned will be passed as `Buffer` objects.
1735
1732
  *
1736
- * If `options.withFileTypes` is set to `true`, the `files` array will contain `<fs.Dirent>` objects.
1733
+ * If `options.withFileTypes` is set to `true`, the `files` array will contain `fs.Dirent` objects.
1737
1734
  * @since v0.1.8
1738
1735
  */
1739
1736
  export function readdir(
@@ -1860,9 +1857,9 @@ declare module 'fs' {
1860
1857
  * The optional `options` argument can be a string specifying an encoding, or an
1861
1858
  * object with an `encoding` property specifying the character encoding to use for
1862
1859
  * the filenames returned. If the `encoding` is set to `'buffer'`,
1863
- * the filenames returned will be passed as `<Buffer>` objects.
1860
+ * the filenames returned will be passed as `Buffer` objects.
1864
1861
  *
1865
- * If `options.withFileTypes` is set to `true`, the result will contain `<fs.Dirent>` objects.
1862
+ * If `options.withFileTypes` is set to `true`, the result will contain `fs.Dirent` objects.
1866
1863
  * @since v0.1.21
1867
1864
  */
1868
1865
  export function readdirSync(
@@ -2177,6 +2174,8 @@ declare module 'fs' {
2177
2174
  }>;
2178
2175
  }
2179
2176
  /**
2177
+ * If `buffer` is a plain object, it must have an own (not inherited) `toString`function property.
2178
+ *
2180
2179
  * For detailed information, see the documentation of the asynchronous version of
2181
2180
  * this API: {@link write}.
2182
2181
  * @since v0.1.21
@@ -2510,10 +2509,12 @@ declare module 'fs' {
2510
2509
  * a file descriptor.
2511
2510
  *
2512
2511
  * The `encoding` option is ignored if `data` is a buffer.
2513
- * If `data` is a normal object, it must have an own `toString` function property.
2512
+ *
2513
+ * If `data` is a plain object, it must have an own (not inherited) `toString`function property.
2514
2514
  *
2515
2515
  * ```js
2516
2516
  * import { writeFile } from 'fs';
2517
+ * import { Buffer } from 'buffer';
2517
2518
  *
2518
2519
  * const data = new Uint8Array(Buffer.from('Hello Node.js'));
2519
2520
  * writeFile('message.txt', data, (err) => {
@@ -2538,12 +2539,13 @@ declare module 'fs' {
2538
2539
  * performs multiple `write` calls internally to write the buffer passed to it.
2539
2540
  * For performance sensitive code consider using {@link createWriteStream}.
2540
2541
  *
2541
- * It is possible to use an `<AbortSignal>` to cancel an `fs.writeFile()`.
2542
+ * It is possible to use an `AbortSignal` to cancel an `fs.writeFile()`.
2542
2543
  * Cancelation is "best effort", and some amount of data is likely still
2543
2544
  * to be written.
2544
2545
  *
2545
2546
  * ```js
2546
2547
  * import { writeFile } from 'fs';
2548
+ * import { Buffer } from 'buffer';
2547
2549
  *
2548
2550
  * const controller = new AbortController();
2549
2551
  * const { signal } = controller;
@@ -2586,6 +2588,8 @@ declare module 'fs' {
2586
2588
  /**
2587
2589
  * Returns `undefined`.
2588
2590
  *
2591
+ * If `data` is a plain object, it must have an own (not inherited) `toString`function property.
2592
+ *
2589
2593
  * For detailed information, see the documentation of the asynchronous version of
2590
2594
  * this API: {@link writeFile}.
2591
2595
  * @since v0.1.29
@@ -2594,7 +2598,7 @@ declare module 'fs' {
2594
2598
  export function writeFileSync(file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: WriteFileOptions): void;
2595
2599
  /**
2596
2600
  * Asynchronously append data to a file, creating the file if it does not yet
2597
- * exist. `data` can be a string or a `<Buffer>`.
2601
+ * exist. `data` can be a string or a `Buffer`.
2598
2602
  *
2599
2603
  * ```js
2600
2604
  * import { appendFile } from 'fs';
@@ -2668,7 +2672,7 @@ declare module 'fs' {
2668
2672
  }
2669
2673
  /**
2670
2674
  * Synchronously append data to a file, creating the file if it does not yet
2671
- * exist. `data` can be a string or a `<Buffer>`.
2675
+ * exist. `data` can be a string or a `Buffer`.
2672
2676
  *
2673
2677
  * ```js
2674
2678
  * import { appendFileSync } from 'fs';
@@ -2806,10 +2810,10 @@ declare module 'fs' {
2806
2810
  * On most platforms, `'rename'` is emitted whenever a filename appears or
2807
2811
  * disappears in the directory.
2808
2812
  *
2809
- * The listener callback is attached to the `'change'` event fired by `<fs.FSWatcher>`, but it is not the same thing as the `'change'` value of`eventType`.
2813
+ * The listener callback is attached to the `'change'` event fired by `fs.FSWatcher`, but it is not the same thing as the `'change'` value of`eventType`.
2810
2814
  *
2811
2815
  * If a `signal` is passed, aborting the corresponding AbortController will close
2812
- * the returned `<fs.FSWatcher>`.
2816
+ * the returned `fs.FSWatcher`.
2813
2817
  * @since v0.5.10
2814
2818
  * @param listener
2815
2819
  */
@@ -3146,7 +3150,7 @@ declare module 'fs' {
3146
3150
  * });
3147
3151
  *
3148
3152
  * // Check if the file exists in the current directory, and if it is writable.
3149
- * access(file, constants.F_OK | fs.constants.W_OK, (err) => {
3153
+ * access(file, constants.F_OK | constants.W_OK, (err) => {
3150
3154
  * if (err) {
3151
3155
  * console.error(
3152
3156
  * `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);
@@ -3343,11 +3347,11 @@ declare module 'fs' {
3343
3347
  * start counting at 0, allowed values are in the
3344
3348
  * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `fd` is specified and `start` is
3345
3349
  * omitted or `undefined`, `fs.createReadStream()` reads sequentially from the
3346
- * current file position. The `encoding` can be any one of those accepted by `<Buffer>`.
3350
+ * current file position. The `encoding` can be any one of those accepted by `Buffer`.
3347
3351
  *
3348
3352
  * If `fd` is specified, `ReadStream` will ignore the `path` argument and will use
3349
3353
  * the specified file descriptor. This means that no `'open'` event will be
3350
- * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `<net.Socket>`.
3354
+ * emitted. `fd` should be blocking; non-blocking `fd`s should be passed to `net.Socket`.
3351
3355
  *
3352
3356
  * If `fd` points to a character device that only supports blocking reads
3353
3357
  * (such as keyboard or sound card), read operations do not finish until data is
@@ -3404,7 +3408,7 @@ declare module 'fs' {
3404
3408
  * position past the beginning of the file, allowed values are in the
3405
3409
  * \[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 replacing
3406
3410
  * it may require the `flags` option to be set to `r+` rather than the default `w`.
3407
- * The `encoding` can be any one of those accepted by `<Buffer>`.
3411
+ * The `encoding` can be any one of those accepted by `Buffer`.
3408
3412
  *
3409
3413
  * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
3410
3414
  * then the file descriptor won't be closed, even if there's an error.
@@ -3418,9 +3422,9 @@ declare module 'fs' {
3418
3422
  * performance as some optimizations (`_writev()`)
3419
3423
  * will be disabled. When providing the `fs` option, overrides for `open`,`close`, and at least one of `write` and `writev` are required.
3420
3424
  *
3421
- * Like `<fs.ReadStream>`, if `fd` is specified, `<fs.WriteStream>` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
3425
+ * Like `fs.ReadStream`, if `fd` is specified, `fs.WriteStream` will ignore the`path` argument and will use the specified file descriptor. This means that no`'open'` event will be
3422
3426
  * emitted. `fd` should be blocking; non-blocking `fd`s
3423
- * should be passed to `<net.Socket>`.
3427
+ * should be passed to `net.Socket`.
3424
3428
  *
3425
3429
  * If `options` is a string, then it specifies the encoding.
3426
3430
  * @since v0.1.31
@@ -3615,7 +3619,7 @@ declare module 'fs' {
3615
3619
  /**
3616
3620
  * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
3617
3621
  *
3618
- * Creates an `<fs.Dir>`, which contains all further functions for reading from
3622
+ * Creates an `fs.Dir`, which contains all further functions for reading from
3619
3623
  * and cleaning up the directory.
3620
3624
  *
3621
3625
  * The `encoding` option sets the encoding for the `path` while opening the
@@ -3627,7 +3631,7 @@ declare module 'fs' {
3627
3631
  * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
3628
3632
  * more details.
3629
3633
  *
3630
- * Creates an `<fs.Dir>`, which contains all further functions for reading from
3634
+ * Creates an `fs.Dir`, which contains all further functions for reading from
3631
3635
  * and cleaning up the directory.
3632
3636
  *
3633
3637
  * The `encoding` option sets the encoding for the `path` while opening the
@@ -3652,6 +3656,67 @@ declare module 'fs' {
3652
3656
  bigint?: boolean | undefined;
3653
3657
  throwIfNoEntry?: boolean | undefined;
3654
3658
  }
3659
+ export interface CopyOptions {
3660
+ /**
3661
+ * Dereference symlinks
3662
+ * @default false
3663
+ */
3664
+ dereference?: boolean;
3665
+ /**
3666
+ * When `force` is `false`, and the destination
3667
+ * exists, throw an error.
3668
+ * @default false
3669
+ */
3670
+ errorOnExist?: boolean;
3671
+ /**
3672
+ * Function to filter copied files/directories. Return
3673
+ * `true` to copy the item, `false` to ignore it.
3674
+ */
3675
+ filter?(source: string, destination: string): boolean;
3676
+ /**
3677
+ * Overwrite existing file or directory. _The copy
3678
+ * operation will ignore errors if you set this to false and the destination
3679
+ * exists. Use the `errorOnExist` option to change this behavior.
3680
+ * @default true
3681
+ */
3682
+ force?: boolean;
3683
+ /**
3684
+ * When `true` timestamps from `src` will
3685
+ * be preserved.
3686
+ * @default false
3687
+ */
3688
+ preserveTimestamps?: boolean;
3689
+ /**
3690
+ * Copy directories recursively.
3691
+ * @default false
3692
+ */
3693
+ recursive?: boolean;
3694
+ }
3695
+ /**
3696
+ * Asynchronously copies the entire directory structure from `src` to `dest`,
3697
+ * including subdirectories and files.
3698
+ *
3699
+ * When copying a directory to another directory, globs are not supported and
3700
+ * behavior is similar to `cp dir1/ dir2/`.
3701
+ * @since v16.7.0
3702
+ * @experimental
3703
+ * @param src source path to copy.
3704
+ * @param dest destination path to copy to.
3705
+ */
3706
+ export function cp(source: string, destination: string, callback: (err: NodeJS.ErrnoException | null) => void): void;
3707
+ export function cp(source: string, destination: string, opts: CopyOptions, callback: (err: NodeJS.ErrnoException | null) => void): void;
3708
+ /**
3709
+ * Synchronously copies the entire directory structure from `src` to `dest`,
3710
+ * including subdirectories and files.
3711
+ *
3712
+ * When copying a directory to another directory, globs are not supported and
3713
+ * behavior is similar to `cp dir1/ dir2/`.
3714
+ * @since v16.7.0
3715
+ * @experimental
3716
+ * @param src source path to copy.
3717
+ * @param dest destination path to copy to.
3718
+ */
3719
+ export function cpSync(source: string, destination: string, opts?: CopyOptions): void;
3655
3720
  }
3656
3721
  declare module 'node:fs' {
3657
3722
  export * from 'fs';
node/globals.d.ts CHANGED
@@ -13,19 +13,6 @@ interface ErrorConstructor {
13
13
  stackTraceLimit: number;
14
14
  }
15
15
 
16
- // Node.js ESNEXT support
17
- interface String {
18
- /** Removes whitespace from the left end of a string. */
19
- trimLeft(): string;
20
- /** Removes whitespace from the right end of a string. */
21
- trimRight(): string;
22
-
23
- /** Returns a copy with leading whitespace removed. */
24
- trimStart(): string;
25
- /** Returns a copy with trailing whitespace removed. */
26
- trimEnd(): string;
27
- }
28
-
29
16
  /*-----------------------------------------------*
30
17
  * *
31
18
  * GLOBAL *
@@ -89,6 +76,30 @@ declare var AbortSignal: {
89
76
  };
90
77
  //#endregion borrowed
91
78
 
79
+ //#region ArrayLike.at()
80
+ interface RelativeIndexable<T> {
81
+ /**
82
+ * Takes an integer value and returns the item at that index,
83
+ * allowing for positive and negative integers.
84
+ * Negative integers count back from the last item in the array.
85
+ */
86
+ at(index: number): T | undefined;
87
+ }
88
+ interface String extends RelativeIndexable<string> {}
89
+ interface Array<T> extends RelativeIndexable<T> {}
90
+ interface Int8Array extends RelativeIndexable<number> {}
91
+ interface Uint8Array extends RelativeIndexable<number> {}
92
+ interface Uint8ClampedArray extends RelativeIndexable<number> {}
93
+ interface Int16Array extends RelativeIndexable<number> {}
94
+ interface Uint16Array extends RelativeIndexable<number> {}
95
+ interface Int32Array extends RelativeIndexable<number> {}
96
+ interface Uint32Array extends RelativeIndexable<number> {}
97
+ interface Float32Array extends RelativeIndexable<number> {}
98
+ interface Float64Array extends RelativeIndexable<number> {}
99
+ interface BigInt64Array extends RelativeIndexable<bigint> {}
100
+ interface BigUint64Array extends RelativeIndexable<bigint> {}
101
+ //#endregion ArrayLike.at() end
102
+
92
103
  /*----------------------------------------------*
93
104
  * *
94
105
  * GLOBAL INTERFACES *
node/http.d.ts CHANGED
@@ -37,7 +37,7 @@
37
37
  * 'Host', 'mysite.com',
38
38
  * 'accepT', '*' ]
39
39
  * ```
40
- * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/http.js)
40
+ * @see [source](https://github.com/nodejs/node/blob/v16.7.0/lib/http.js)
41
41
  */
42
42
  declare module 'http' {
43
43
  import * as stream from 'node:stream';
@@ -162,26 +162,80 @@ declare module 'http' {
162
162
  class Server extends NetServer {
163
163
  constructor(requestListener?: RequestListener);
164
164
  constructor(options: ServerOptions, requestListener?: RequestListener);
165
+ /**
166
+ * Sets the timeout value for sockets, and emits a `'timeout'` event on
167
+ * the Server object, passing the socket as an argument, if a timeout
168
+ * occurs.
169
+ *
170
+ * If there is a `'timeout'` event listener on the Server object, then it
171
+ * will be called with the timed-out socket as an argument.
172
+ *
173
+ * By default, the Server does not timeout sockets. However, if a callback
174
+ * is assigned to the Server's `'timeout'` event, timeouts must be handled
175
+ * explicitly.
176
+ * @since v0.9.12
177
+ * @param [msecs=0 (no timeout)]
178
+ */
165
179
  setTimeout(msecs?: number, callback?: () => void): this;
166
180
  setTimeout(callback: () => void): this;
167
181
  /**
168
182
  * Limits maximum incoming headers count. If set to 0, no limit will be applied.
169
- * @default 2000
170
- * {@link https://nodejs.org/api/http.html#http_server_maxheaderscount}
183
+ * @since v0.7.0
171
184
  */
172
185
  maxHeadersCount: number | null;
186
+ /**
187
+ * The number of milliseconds of inactivity before a socket is presumed
188
+ * to have timed out.
189
+ *
190
+ * A value of `0` will disable the timeout behavior on incoming connections.
191
+ *
192
+ * The socket timeout logic is set up on connection, so changing this
193
+ * value only affects new connections to the server, not any existing connections.
194
+ * @since v0.9.12
195
+ */
173
196
  timeout: number;
174
197
  /**
175
- * Limit the amount of time the parser will wait to receive the complete HTTP headers.
176
- * @default 60000
177
- * {@link https://nodejs.org/api/http.html#http_server_headerstimeout}
198
+ * Limit the amount of time the parser will wait to receive the complete HTTP
199
+ * headers.
200
+ *
201
+ * In case of inactivity, the rules defined in `server.timeout` apply. However,
202
+ * that inactivity based timeout would still allow the connection to be kept open
203
+ * if the headers are being sent very slowly (by default, up to a byte per 2
204
+ * minutes). In order to prevent this, whenever header data arrives an additional
205
+ * check is made that more than `server.headersTimeout` milliseconds has not
206
+ * passed since the connection was established. If the check fails, a `'timeout'`event is emitted on the server object, and (by default) the socket is destroyed.
207
+ * See `server.timeout` for more information on how timeout behavior can be
208
+ * customized.
209
+ * @since v11.3.0, v10.14.0
178
210
  */
179
211
  headersTimeout: number;
212
+ /**
213
+ * The number of milliseconds of inactivity a server needs to wait for additional
214
+ * incoming data, after it has finished writing the last response, before a socket
215
+ * will be destroyed. If the server receives new data before the keep-alive
216
+ * timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
217
+ *
218
+ * A value of `0` will disable the keep-alive timeout behavior on incoming
219
+ * connections.
220
+ * A value of `0` makes the http server behave similarly to Node.js versions prior
221
+ * to 8.0.0, which did not have a keep-alive timeout.
222
+ *
223
+ * The socket timeout logic is set up on connection, so changing this value only
224
+ * affects new connections to the server, not any existing connections.
225
+ * @since v8.0.0
226
+ */
180
227
  keepAliveTimeout: number;
181
228
  /**
182
- * Sets the timeout value in milliseconds for receiving the entire request from the client.
183
- * @default 0
184
- * {@link https://nodejs.org/api/http.html#http_server_requesttimeout}
229
+ * Sets the timeout value in milliseconds for receiving the entire request from
230
+ * the client.
231
+ *
232
+ * If the timeout expires, the server responds with status 408 without
233
+ * forwarding the request to the request listener and then closes the connection.
234
+ *
235
+ * It must be set to a non-zero value (e.g. 120 seconds) to protect against
236
+ * potential Denial-of-Service attacks in case the server is deployed without a
237
+ * reverse proxy in front.
238
+ * @since v14.11.0
185
239
  */
186
240
  requestTimeout: number;
187
241
  addListener(event: string, listener: (...args: any[]) => void): this;
@@ -686,7 +740,7 @@ declare module 'http' {
686
740
  * access response
687
741
  * status, headers and data.
688
742
  *
689
- * Different from its `socket` value which is a subclass of `<stream.Duplex>`, the`IncomingMessage` itself extends `<stream.Readable>` and is created separately to
743
+ * Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
690
744
  * parse and emit the incoming HTTP headers and payload, as the underlying socket
691
745
  * may be reused multiple times in case of keep-alive.
692
746
  * @since v0.1.17
@@ -746,9 +800,9 @@ declare module 'http' {
746
800
  * With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the
747
801
  * client's authentication details.
748
802
  *
749
- * This property is guaranteed to be an instance of the `<net.Socket>` class,
750
- * a subclass of `<stream.Duplex>`, unless the user specified a socket
751
- * type other than `<net.Socket>`.
803
+ * This property is guaranteed to be an instance of the `net.Socket` class,
804
+ * a subclass of `stream.Duplex`, unless the user specified a socket
805
+ * type other than `net.Socket`.
752
806
  * @since v0.3.0
753
807
  */
754
808
  socket: Socket;