@types/node 16.10.8 → 16.11.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/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 13 Oct 2021 18:31:21 GMT
11
+ * Last updated: Thu, 21 Oct 2021 11:01:21 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
14
14
 
node/crypto.d.ts CHANGED
@@ -1175,7 +1175,7 @@ declare module 'crypto' {
1175
1175
  * generateKeySync
1176
1176
  * } = await import('crypto');
1177
1177
  *
1178
- * const key = generateKeySync('hmac', 64);
1178
+ * const key = generateKeySync('hmac', { length: 64 });
1179
1179
  * console.log(key.export().toString('hex')); // e89..........41e
1180
1180
  * ```
1181
1181
  * @since v15.0.0
@@ -37,6 +37,7 @@ declare module 'diagnostics_channel' {
37
37
  * // There are subscribers, prepare and publish message
38
38
  * }
39
39
  * ```
40
+ * @since v15.1.0, v14.17.0
40
41
  * @param name The channel name
41
42
  * @return If there are active subscribers
42
43
  */
@@ -51,6 +52,7 @@ declare module 'diagnostics_channel' {
51
52
  *
52
53
  * const channel = diagnostics_channel.channel('my-channel');
53
54
  * ```
55
+ * @since v15.1.0, v14.17.0
54
56
  * @param name The channel name
55
57
  * @return The named channel object
56
58
  */
@@ -63,6 +65,7 @@ declare module 'diagnostics_channel' {
63
65
  * lookups at publish time, enabling very fast publish speeds and allowing
64
66
  * for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
65
67
  * with `new Channel(name)` is not supported.
68
+ * @since v15.1.0, v14.17.0
66
69
  */
67
70
  class Channel {
68
71
  readonly name: string;
@@ -82,6 +85,7 @@ declare module 'diagnostics_channel' {
82
85
  * // There are subscribers, prepare and publish message
83
86
  * }
84
87
  * ```
88
+ * @since v15.1.0, v14.17.0
85
89
  */
86
90
  readonly hasSubscribers: boolean;
87
91
  private constructor(name: string);
@@ -99,6 +103,7 @@ declare module 'diagnostics_channel' {
99
103
  * // Received data
100
104
  * });
101
105
  * ```
106
+ * @since v15.1.0, v14.17.0
102
107
  * @param onMessage The handler to receive channel messages
103
108
  */
104
109
  subscribe(onMessage: ChannelListener): void;
@@ -118,6 +123,7 @@ declare module 'diagnostics_channel' {
118
123
  *
119
124
  * channel.unsubscribe(onMessage);
120
125
  * ```
126
+ * @since v15.1.0, v14.17.0
121
127
  * @param onMessage The previous subscribed handler to remove
122
128
  */
123
129
  unsubscribe(onMessage: ChannelListener): void;
node/fs/promises.d.ts CHANGED
@@ -31,6 +31,8 @@ declare module 'fs/promises' {
31
31
  WatchOptions,
32
32
  WatchEventType,
33
33
  CopyOptions,
34
+ ReadStream,
35
+ WriteStream,
34
36
  } from 'node:fs';
35
37
  interface FileChangeInfo<T extends string | Buffer> {
36
38
  eventType: WatchEventType;
@@ -59,6 +61,20 @@ declare module 'fs/promises' {
59
61
  length?: number | null;
60
62
  position?: number | null;
61
63
  }
64
+ interface CreateReadStreamOptions {
65
+ encoding?: BufferEncoding | null | undefined;
66
+ autoClose?: boolean | undefined;
67
+ emitClose?: boolean | undefined;
68
+ start?: number | undefined;
69
+ end?: number | undefined;
70
+ highWaterMark?: number | undefined;
71
+ }
72
+ interface CreateWriteStreamOptions {
73
+ encoding?: BufferEncoding | null | undefined;
74
+ autoClose?: boolean | undefined;
75
+ emitClose?: boolean | undefined;
76
+ start?: number | undefined;
77
+ }
62
78
  // TODO: Add `EventEmitter` close
63
79
  interface FileHandle {
64
80
  /**
@@ -90,6 +106,77 @@ declare module 'fs/promises' {
90
106
  * @return Fulfills with `undefined` upon success.
91
107
  */
92
108
  chmod(mode: Mode): Promise<void>;
109
+ /**
110
+ * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
111
+ * returned by this method has a default `highWaterMark` of 64 kb.
112
+ *
113
+ * `options` can include `start` and `end` values to read a range of bytes from
114
+ * the file instead of the entire file. Both `start` and `end` are inclusive and
115
+ * start counting at 0, allowed values are in the
116
+ * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is
117
+ * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from
118
+ * the current file position. The `encoding` can be any one of those accepted by `Buffer`.
119
+ *
120
+ * If the `FileHandle` points to a character device that only supports blocking
121
+ * reads (such as keyboard or sound card), read operations do not finish until data
122
+ * is available. This can prevent the process from exiting and the stream from
123
+ * closing naturally.
124
+ *
125
+ * By default, the stream will emit a `'close'` event after it has been
126
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
127
+ *
128
+ * ```js
129
+ * import { open } from 'fs/promises';
130
+ *
131
+ * const fd = await open('/dev/input/event0');
132
+ * // Create a stream from some character device.
133
+ * const stream = fd.createReadStream();
134
+ * setTimeout(() => {
135
+ * stream.close(); // This may not close the stream.
136
+ * // Artificially marking end-of-stream, as if the underlying resource had
137
+ * // indicated end-of-file by itself, allows the stream to close.
138
+ * // This does not cancel pending read operations, and if there is such an
139
+ * // operation, the process may still not be able to exit successfully
140
+ * // until it finishes.
141
+ * stream.push(null);
142
+ * stream.read(0);
143
+ * }, 100);
144
+ * ```
145
+ *
146
+ * If `autoClose` is false, then the file descriptor won't be closed, even if
147
+ * there's an error. It is the application's responsibility to close it and make
148
+ * sure there's no file descriptor leak. If `autoClose` is set to true (default
149
+ * behavior), on `'error'` or `'end'` the file descriptor will be closed
150
+ * automatically.
151
+ *
152
+ * An example to read the last 10 bytes of a file which is 100 bytes long:
153
+ *
154
+ * ```js
155
+ * import { open } from 'fs/promises';
156
+ *
157
+ * const fd = await open('sample.txt');
158
+ * fd.createReadStream({ start: 90, end: 99 });
159
+ * ```
160
+ * @since v16.11.0
161
+ */
162
+ createReadStream(options?: CreateReadStreamOptions): ReadStream;
163
+ /**
164
+ * `options` may also include a `start` option to allow writing data at some
165
+ * 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 replacing
167
+ * it may require the `flags` `open` option to be set to `r+` rather than the
168
+ * default `r`. The `encoding` can be any one of those accepted by `Buffer`.
169
+ *
170
+ * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
171
+ * then the file descriptor won't be closed, even if there's an error.
172
+ * It is the application's responsibility to close it and make sure there's no
173
+ * file descriptor leak.
174
+ *
175
+ * By default, the stream will emit a `'close'` event after it has been
176
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
177
+ * @since v16.11.0
178
+ */
179
+ createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
93
180
  /**
94
181
  * Forces all currently queued I/O operations associated with the file to the
95
182
  * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details.
@@ -928,7 +1015,7 @@ declare module 'fs/promises' {
928
1015
  * @since v12.12.0
929
1016
  * @return Fulfills with an {fs.Dir}.
930
1017
  */
931
- function opendir(path: string, options?: OpenDirOptions): Promise<Dir>;
1018
+ function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
932
1019
  /**
933
1020
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
934
1021
  *
node/fs.d.ts CHANGED
@@ -306,7 +306,7 @@ declare module 'fs' {
306
306
  /**
307
307
  * The path to the file the stream is reading from as specified in the first
308
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`.
309
+ * `Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.
310
310
  * @since v0.1.93
311
311
  */
312
312
  path: string | Buffer;
@@ -2763,7 +2763,7 @@ declare module 'fs' {
2763
2763
  * the numeric values in these objects are specified as `BigInt`s.
2764
2764
  *
2765
2765
  * To be notified when the file was modified, not just accessed, it is necessary
2766
- * to compare `curr.mtime` and `prev.mtime`.
2766
+ * to compare `curr.mtimeMs` and `prev.mtimeMs`.
2767
2767
  *
2768
2768
  * When an `fs.watchFile` operation results in an `ENOENT` error, it
2769
2769
  * will invoke the listener once, with all the fields zeroed (or, for dates, the
@@ -3362,7 +3362,7 @@ declare module 'fs' {
3362
3362
  end?: number | undefined;
3363
3363
  }
3364
3364
  /**
3365
- * Unlike the 16 kb default `highWaterMark` for a readable stream, the stream
3365
+ * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
3366
3366
  * returned by this method has a default `highWaterMark` of 64 kb.
3367
3367
  *
3368
3368
  * `options` can include `start` and `end` values to read a range of bytes from
@@ -3382,7 +3382,7 @@ declare module 'fs' {
3382
3382
  * closing naturally.
3383
3383
  *
3384
3384
  * By default, the stream will emit a `'close'` event after it has been
3385
- * destroyed, like most `Readable` streams. Set the `emitClose` option to`false` to change this behavior.
3385
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
3386
3386
  *
3387
3387
  * By providing the `fs` option, it is possible to override the corresponding `fs`implementations for `open`, `read`, and `close`. When providing the `fs` option,
3388
3388
  * an override for `read` is required. If no `fd` is provided, an override for`open` is also required. If `autoClose` is `true`, an override for `close` is
@@ -3424,7 +3424,6 @@ declare module 'fs' {
3424
3424
  *
3425
3425
  * If `options` is a string, then it specifies the encoding.
3426
3426
  * @since v0.1.31
3427
- * @return See `Readable Stream`.
3428
3427
  */
3429
3428
  export function createReadStream(path: PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
3430
3429
  /**
@@ -3440,7 +3439,7 @@ declare module 'fs' {
3440
3439
  * file descriptor leak.
3441
3440
  *
3442
3441
  * By default, the stream will emit a `'close'` event after it has been
3443
- * destroyed, like most `Writable` streams. Set the `emitClose` option to`false` to change this behavior.
3442
+ * destroyed. Set the `emitClose` option to `false` to change this behavior.
3444
3443
  *
3445
3444
  * By providing the `fs` option it is possible to override the corresponding `fs`implementations for `open`, `write`, `writev` and `close`. Overriding `write()`without `writev()` can reduce
3446
3445
  * performance as some optimizations (`_writev()`)
@@ -3453,7 +3452,6 @@ declare module 'fs' {
3453
3452
  *
3454
3453
  * If `options` is a string, then it specifies the encoding.
3455
3454
  * @since v0.1.31
3456
- * @return See `Writable Stream`.
3457
3455
  */
3458
3456
  export function createWriteStream(path: PathLike, options?: BufferEncoding | StreamOptions): WriteStream;
3459
3457
  /**
@@ -3651,7 +3649,7 @@ declare module 'fs' {
3651
3649
  * directory and subsequent read operations.
3652
3650
  * @since v12.12.0
3653
3651
  */
3654
- export function opendirSync(path: string, options?: OpenDirOptions): Dir;
3652
+ export function opendirSync(path: PathLike, options?: OpenDirOptions): Dir;
3655
3653
  /**
3656
3654
  * Asynchronously open a directory. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for
3657
3655
  * more details.
@@ -3663,10 +3661,10 @@ declare module 'fs' {
3663
3661
  * directory and subsequent read operations.
3664
3662
  * @since v12.12.0
3665
3663
  */
3666
- export function opendir(path: string, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3667
- export function opendir(path: string, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3664
+ export function opendir(path: PathLike, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3665
+ export function opendir(path: PathLike, options: OpenDirOptions, cb: (err: NodeJS.ErrnoException | null, dir: Dir) => void): void;
3668
3666
  export namespace opendir {
3669
- function __promisify__(path: string, options?: OpenDirOptions): Promise<Dir>;
3667
+ function __promisify__(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
3670
3668
  }
3671
3669
  export interface BigIntStats extends StatsBase<bigint> {
3672
3670
  atimeNs: bigint;
node/http.d.ts CHANGED
@@ -187,9 +187,9 @@ declare module 'http' {
187
187
  * The maximum number of requests socket can handle
188
188
  * before closing keep alive connection.
189
189
  *
190
- * A value of `null` will disable the limit.
190
+ * A value of `0` will disable the limit.
191
191
  *
192
- * When limit is reach it will set `Connection` header value to `closed`,
192
+ * When the limit is reached it will set the `Connection` header value to `close`,
193
193
  * but will not actually close the connection, subsequent requests sent
194
194
  * after the limit is reached will get `503 Service Unavailable` as a response.
195
195
  * @since v16.10.0
node/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 16.10
1
+ // Type definitions for non-npm package Node.js 16.11
2
2
  // Project: https://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
node/net.d.ts CHANGED
@@ -255,12 +255,12 @@ declare module 'net' {
255
255
  * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
256
256
  * @since v0.9.6
257
257
  */
258
- readonly localAddress: string;
258
+ readonly localAddress?: string;
259
259
  /**
260
260
  * The numeric representation of the local port. For example, `80` or `21`.
261
261
  * @since v0.9.6
262
262
  */
263
- readonly localPort: number;
263
+ readonly localPort?: number;
264
264
  /**
265
265
  * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
266
266
  * the socket is destroyed (for example, if the client disconnected).
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.10.8",
3
+ "version": "16.11.2",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -225,6 +225,6 @@
225
225
  },
226
226
  "scripts": {},
227
227
  "dependencies": {},
228
- "typesPublisherContentHash": "095c6911e5d8f133d32e7f92331756cbb657676d6b4af727743ff7dc3e02940b",
228
+ "typesPublisherContentHash": "c5efc44a208806af5f092170cc1fecd2c65728472e73dd2fe3660b9c23bf1799",
229
229
  "typeScriptVersion": "3.7"
230
230
  }
node/url.d.ts CHANGED
@@ -71,6 +71,30 @@ declare module 'url' {
71
71
  function parse(urlString: string, parseQueryString: false | undefined, slashesDenoteHost?: boolean): UrlWithStringQuery;
72
72
  function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;
73
73
  function parse(urlString: string, parseQueryString: boolean, slashesDenoteHost?: boolean): Url;
74
+ /**
75
+ * The URL object has both a `toString()` method and `href` property that return string serializations of the URL.
76
+ * These are not, however, customizable in any way. The `url.format(URL[, options])` method allows for basic
77
+ * customization of the output.
78
+ * Returns a customizable serialization of a URL `String` representation of a `WHATWG URL` object.
79
+ *
80
+ * ```js
81
+ * import url from 'url';
82
+ * const myURL = new URL('https://a:b@測試?abc#foo');
83
+ *
84
+ * console.log(myURL.href);
85
+ * // Prints https://a:b@xn--g6w251d/?abc#foo
86
+ *
87
+ * console.log(myURL.toString());
88
+ * // Prints https://a:b@xn--g6w251d/?abc#foo
89
+ *
90
+ * console.log(url.format(myURL, { fragment: false, unicode: true, auth: false }));
91
+ * // Prints 'https://測試/?abc'
92
+ * ```
93
+ * @since v7.6.0
94
+ * @param urlObject A `WHATWG URL` object
95
+ * @param options
96
+ */
97
+ function format(urlObject: URL, options?: URLFormatOptions): string;
74
98
  /**
75
99
  * The `url.format()` method returns a formatted URL string derived from`urlObject`.
76
100
  *
@@ -134,7 +158,6 @@ declare module 'url' {
134
158
  * @deprecated Legacy: Use the WHATWG URL API instead.
135
159
  * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
136
160
  */
137
- function format(urlObject: URL, options?: URLFormatOptions): string;
138
161
  function format(urlObject: UrlObject | string): string;
139
162
  /**
140
163
  * The `url.resolve()` method resolves a target URL relative to a base URL in a
node/util.d.ts CHANGED
@@ -113,6 +113,20 @@ declare module 'util' {
113
113
  * @since v10.0.0
114
114
  */
115
115
  export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
116
+ /**
117
+ * Returns the string name for a numeric error code that comes from a Node.js API.
118
+ * The mapping between error codes and error names is platform-dependent.
119
+ * See `Common System Errors` for the names of common errors.
120
+ *
121
+ * ```js
122
+ * fs.access('file/that/does/not/exist', (err) => {
123
+ * const name = util.getSystemErrorName(err.errno);
124
+ * console.error(name); // ENOENT
125
+ * });
126
+ * ```
127
+ * @since v9.7.0
128
+ */
129
+ export function getSystemErrorName(err: number): string;
116
130
  /**
117
131
  * Returns a Map of all system error codes available from the Node.js API.
118
132
  * The mapping between error codes and error names is platform-dependent.
@@ -314,6 +328,9 @@ declare module 'util' {
314
328
  * Allows changing inspect settings from the repl.
315
329
  */
316
330
  let replDefaults: InspectOptions;
331
+ /**
332
+ * That can be used to declare custom inspect functions.
333
+ */
317
334
  const custom: unique symbol;
318
335
  }
319
336
  /**
@@ -520,6 +537,7 @@ declare module 'util' {
520
537
  * @return The logging function
521
538
  */
522
539
  export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
540
+ export const debug: typeof debuglog;
523
541
  /**
524
542
  * Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
525
543
  *
@@ -789,6 +807,16 @@ declare module 'util' {
789
807
  * @since v9.0.0
790
808
  */
791
809
  export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
810
+ /**
811
+ * Returns `str` with any ANSI escape codes removed.
812
+ *
813
+ * ```js
814
+ * console.log(util.stripVTControlCharacters('\u001B[4mvalue\u001B[0m'));
815
+ * // Prints "value"
816
+ * ```
817
+ * @since v16.11.0
818
+ */
819
+ export function stripVTControlCharacters(str: string): string;
792
820
  /**
793
821
  * Takes an `async` function (or a function that returns a `Promise`) and returns a
794
822
  * function following the error-first callback style, i.e. taking
@@ -961,6 +989,9 @@ declare module 'util' {
961
989
  ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
962
990
  export function promisify(fn: Function): Function;
963
991
  export namespace promisify {
992
+ /**
993
+ * That can be used to declare custom promisified variants of functions.
994
+ */
964
995
  const custom: unique symbol;
965
996
  }
966
997
  /**