@types/node 20.12.14 → 20.14.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/url.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * ```js
6
6
  * import url from 'node:url';
7
7
  * ```
8
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/url.js)
8
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/url.js)
9
9
  */
10
10
  declare module "url" {
11
11
  import { Blob as NodeBlob } from "node:buffer";
@@ -46,6 +46,14 @@ declare module "url" {
46
46
  interface UrlWithStringQuery extends Url {
47
47
  query: string | null;
48
48
  }
49
+ interface FileUrlToPathOptions {
50
+ /**
51
+ * `true` if the `path` should be return as a windows filepath, `false` for posix, and `undefined` for the system default.
52
+ * @default undefined
53
+ */
54
+ windows?: boolean | undefined;
55
+ }
56
+ interface PathToFileUrlOptions extends FileUrlToPathOptions {}
49
57
  /**
50
58
  * The `url.parse()` method takes a URL string, parses it, and returns a URL
51
59
  * object.
@@ -298,7 +306,7 @@ declare module "url" {
298
306
  * @param url The file URL string or URL object to convert to a path.
299
307
  * @return The fully-resolved platform-specific Node.js file path.
300
308
  */
301
- function fileURLToPath(url: string | URL): string;
309
+ function fileURLToPath(url: string | URL, options?: FileUrlToPathOptions): string;
302
310
  /**
303
311
  * This function ensures that `path` is resolved absolutely, and that the URL
304
312
  * control characters are correctly encoded when converting into a File URL.
@@ -316,7 +324,7 @@ declare module "url" {
316
324
  * @param path The path to convert to a File URL.
317
325
  * @return The file URL object.
318
326
  */
319
- function pathToFileURL(path: string): URL;
327
+ function pathToFileURL(path: string, options?: PathToFileUrlOptions): URL;
320
328
  /**
321
329
  * This utility function converts a URL object into an ordinary options object as
322
330
  * expected by the `http.request()` and `https.request()` APIs.
node/util.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * ```js
7
7
  * const util = require('node:util');
8
8
  * ```
9
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/util.js)
9
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/util.js)
10
10
  */
11
11
  declare module "util" {
12
12
  import * as types from "node:util/types";
@@ -1256,16 +1256,32 @@ declare module "util" {
1256
1256
  *
1257
1257
  * ```js
1258
1258
  * console.log(
1259
- * util.styleText('underline', util.styleText('italic', 'My italic underlined message')),
1259
+ * util.styleText(['underline', 'italic'], 'My italic underlined message'),
1260
+ * );
1261
+ * ```
1262
+ *
1263
+ * When passing an array of formats, the order of the format applied is left to right so the following style
1264
+ * might overwrite the previous one.
1265
+ *
1266
+ * ```js
1267
+ * console.log(
1268
+ * util.styleText(['red', 'green'], 'text'), // green
1260
1269
  * );
1261
1270
  * ```
1262
1271
  *
1263
1272
  * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v20.x/api/util.html#modifiers).
1264
- * @param format A text format defined in `util.inspect.colors`.
1273
+ * @param format A text format or an Array of text formats defined in `util.inspect.colors`.
1265
1274
  * @param text The text to to be formatted.
1266
1275
  * @since v20.12.0
1267
1276
  */
1268
- export function styleText(format: ForegroundColors | BackgroundColors | Modifiers, text: string): string;
1277
+ export function styleText(
1278
+ format:
1279
+ | ForegroundColors
1280
+ | BackgroundColors
1281
+ | Modifiers
1282
+ | Array<ForegroundColors | BackgroundColors | Modifiers>,
1283
+ text: string,
1284
+ ): string;
1269
1285
  /**
1270
1286
  * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
1271
1287
  *
node/v8.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * ```js
5
5
  * const v8 = require('node:v8');
6
6
  * ```
7
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/v8.js)
7
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/v8.js)
8
8
  */
9
9
  declare module "v8" {
10
10
  import { Readable } from "node:stream";
@@ -183,6 +183,50 @@ declare module "v8" {
183
183
  * @since v1.0.0
184
184
  */
185
185
  function setFlagsFromString(flags: string): void;
186
+ /**
187
+ * This is similar to the [`queryObjects()` console API](https://developer.chrome.com/docs/devtools/console/utilities#queryObjects-function)
188
+ * provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain
189
+ * in the heap after a full garbage collection, which can be useful for memory leak regression tests. To avoid surprising results, users should
190
+ * avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the
191
+ * application.
192
+ *
193
+ * To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects
194
+ * found. If `options.format` is `'summary'`, it returns an array containing brief string representations for each object. The visibility provided
195
+ * in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filter the
196
+ * target objects during the search.
197
+ *
198
+ * Only objects created in the current execution context are included in the results.
199
+ *
200
+ * ```js
201
+ * import { queryObjects } from 'node:v8';
202
+ * class A { foo = 'bar'; }
203
+ * console.log(queryObjects(A)); // 0
204
+ * const a = new A();
205
+ * console.log(queryObjects(A)); // 1
206
+ * // [ "A { foo: 'bar' }" ]
207
+ * console.log(queryObjects(A, { format: 'summary' }));
208
+ *
209
+ * class B extends A { bar = 'qux'; }
210
+ * const b = new B();
211
+ * console.log(queryObjects(B)); // 1
212
+ * // [ "B { foo: 'bar', bar: 'qux' }" ]
213
+ * console.log(queryObjects(B, { format: 'summary' }));
214
+ *
215
+ * // Note that, when there are child classes inheriting from a constructor,
216
+ * // the constructor also shows up in the prototype chain of the child
217
+ * // classes's prototoype, so the child classes's prototoype would also be
218
+ * // included in the result.
219
+ * console.log(queryObjects(A)); // 3
220
+ * // [ "B { foo: 'bar', bar: 'qux' }", 'A {}', "A { foo: 'bar' }" ]
221
+ * console.log(queryObjects(A, { format: 'summary' }));
222
+ * ```
223
+ * @param ctor The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.
224
+ * @since v20.13.0
225
+ * @experimental
226
+ */
227
+ function queryObjects(ctor: Function): number | string[];
228
+ function queryObjects(ctor: Function, options: { format: "count" }): number;
229
+ function queryObjects(ctor: Function, options: { format: "summary" }): string[];
186
230
  /**
187
231
  * Generates a snapshot of the current V8 heap and returns a Readable
188
232
  * Stream that may be used to read the JSON serialized representation.
node/vm.d.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  *
35
35
  * console.log(x); // 1; y is not defined.
36
36
  * ```
37
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/vm.js)
37
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
40
  import { ImportAttributes } from "node:module";
@@ -347,11 +347,14 @@ declare module "vm" {
347
347
  sourceMapURL?: string | undefined;
348
348
  }
349
349
  /**
350
- * If given a `contextObject`, the `vm.createContext()` method will `prepare
351
- * that object` so that it can be used in calls to {@link runInContext} or `script.runInContext()`. Inside such scripts,
352
- * the `contextObject` will be the global object, retaining all of its existing
353
- * properties but also having the built-in objects and functions any standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global variables
354
- * will remain unchanged.
350
+ * If given a `contextObject`, the `vm.createContext()` method will
351
+ * [prepare that object](https://nodejs.org/docs/latest-v20.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
352
+ * and return a reference to it so that it can be used in `{@link runInContext}` or
353
+ * [`script.runInContext()`](https://nodejs.org/docs/latest-v20.x/api/vm.html#scriptrunincontextcontextifiedobject-options). Inside such
354
+ * scripts, the `contextObject` will be the global object, retaining all of its
355
+ * existing properties but also having the built-in objects and functions any
356
+ * standard [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
357
+ * variables will remain unchanged.
355
358
  *
356
359
  * ```js
357
360
  * const vm = require('node:vm');
node/wasi.d.ts CHANGED
@@ -67,7 +67,7 @@
67
67
  * wat2wasm demo.wat
68
68
  * ```
69
69
  * @experimental
70
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/wasi.js)
70
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/wasi.js)
71
71
  */
72
72
  declare module "wasi" {
73
73
  interface WASIOptions {
node/worker_threads.d.ts CHANGED
@@ -49,7 +49,7 @@
49
49
  *
50
50
  * Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
51
51
  * specifically `argv` and `execArgv` options.
52
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/worker_threads.js)
52
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/worker_threads.js)
53
53
  */
54
54
  declare module "worker_threads" {
55
55
  import { Blob } from "node:buffer";
node/zlib.d.ts CHANGED
@@ -89,7 +89,7 @@
89
89
  * });
90
90
  * ```
91
91
  * @since v0.5.8
92
- * @see [source](https://github.com/nodejs/node/blob/v20.12.2/lib/zlib.js)
92
+ * @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/zlib.js)
93
93
  */
94
94
  declare module "zlib" {
95
95
  import * as stream from "node:stream";