@types/node 20.9.5 → 20.10.1

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 (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: Thu, 23 Nov 2023 21:35:40 GMT
11
+ * Last updated: Wed, 29 Nov 2023 19:35:57 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/dgram.d.ts CHANGED
@@ -501,7 +501,7 @@ declare module "dgram" {
501
501
  * process active, allowing the process to exit even if the socket is still
502
502
  * listening.
503
503
  *
504
- * Calling `socket.unref()` multiple times will have no addition effect.
504
+ * Calling `socket.unref()` multiple times will have no additional effect.
505
505
  *
506
506
  * The `socket.unref()` method returns a reference to the socket so calls can be
507
507
  * chained.
node/events.d.ts CHANGED
@@ -470,13 +470,41 @@ declare module "events" {
470
470
  }
471
471
 
472
472
  /**
473
- * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that require
474
- * manual async tracking. Specifically, all events emitted by instances of
475
- * `EventEmitterAsyncResource` will run within its async context.
473
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
474
+ * require manual async tracking. Specifically, all events emitted by instances
475
+ * of `events.EventEmitterAsyncResource` will run within its `async context`.
476
476
  *
477
- * The EventEmitterAsyncResource class has the same methods and takes the
478
- * same options as EventEmitter and AsyncResource themselves.
479
- * @throws if `options.name` is not provided when instantiated directly.
477
+ * ```js
478
+ * import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
479
+ * import { notStrictEqual, strictEqual } from 'node:assert';
480
+ * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
481
+ *
482
+ * // Async tracking tooling will identify this as 'Q'.
483
+ * const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
484
+ *
485
+ * // 'foo' listeners will run in the EventEmitters async context.
486
+ * ee1.on('foo', () => {
487
+ * strictEqual(executionAsyncId(), ee1.asyncId);
488
+ * strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
489
+ * });
490
+ *
491
+ * const ee2 = new EventEmitter();
492
+ *
493
+ * // 'foo' listeners on ordinary EventEmitters that do not track async
494
+ * // context, however, run in the same async context as the emit().
495
+ * ee2.on('foo', () => {
496
+ * notStrictEqual(executionAsyncId(), ee2.asyncId);
497
+ * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
498
+ * });
499
+ *
500
+ * Promise.resolve().then(() => {
501
+ * ee1.emit('foo');
502
+ * ee2.emit('foo');
503
+ * });
504
+ * ```
505
+ *
506
+ * The `EventEmitterAsyncResource` class has the same methods and takes the
507
+ * same options as `EventEmitter` and `AsyncResource` themselves.
480
508
  * @since v17.4.0, v16.14.0
481
509
  */
482
510
  export class EventEmitterAsyncResource extends EventEmitter {
@@ -485,17 +513,24 @@ declare module "events" {
485
513
  */
486
514
  constructor(options?: EventEmitterAsyncResourceOptions);
487
515
  /**
488
- * Call all destroy hooks. This should only ever be called once. An
489
- * error will be thrown if it is called more than once. This must be
490
- * manually called. If the resource is left to be collected by the GC then
491
- * the destroy hooks will never be called.
516
+ * Call all `destroy` hooks. This should only ever be called once. An error will
517
+ * be thrown if it is called more than once. This **must** be manually called. If
518
+ * the resource is left to be collected by the GC then the `destroy` hooks will
519
+ * never be called.
492
520
  */
493
521
  emitDestroy(): void;
494
- /** The unique asyncId assigned to the resource. */
522
+ /**
523
+ * The unique `asyncId` assigned to the resource.
524
+ */
495
525
  readonly asyncId: number;
496
- /** The same triggerAsyncId that is passed to the AsyncResource constructor. */
526
+ /**
527
+ * The same triggerAsyncId that is passed to the AsyncResource constructor.
528
+ */
497
529
  readonly triggerAsyncId: number;
498
- /** The underlying AsyncResource */
530
+ /**
531
+ * The returned `AsyncResource` object has an additional `eventEmitter` property
532
+ * that provides a reference to this `EventEmitterAsyncResource`.
533
+ */
499
534
  readonly asyncResource: EventEmitterReferencingAsyncResource;
500
535
  }
501
536
  }
node/fs/promises.d.ts CHANGED
@@ -82,6 +82,7 @@ declare module "fs/promises" {
82
82
  emitClose?: boolean | undefined;
83
83
  start?: number | undefined;
84
84
  highWaterMark?: number | undefined;
85
+ flush?: boolean | undefined;
85
86
  }
86
87
  interface ReadableWebStreamOptions {
87
88
  /**
@@ -107,7 +108,10 @@ declare module "fs/promises" {
107
108
  */
108
109
  appendFile(
109
110
  data: string | Uint8Array,
110
- options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
111
+ options?:
112
+ | (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined })
113
+ | BufferEncoding
114
+ | null,
111
115
  ): Promise<void>;
112
116
  /**
113
117
  * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
@@ -366,7 +370,7 @@ declare module "fs/promises" {
366
370
  */
367
371
  truncate(len?: number): Promise<void>;
368
372
  /**
369
- * Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
373
+ * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success.
370
374
  * @since v10.0.0
371
375
  */
372
376
  utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
@@ -374,14 +378,14 @@ declare module "fs/promises" {
374
378
  * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
375
379
  * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
376
380
  * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
377
- * The promise is resolved with no arguments upon success.
381
+ * The promise is fulfilled with no arguments upon success.
378
382
  *
379
383
  * If `options` is a string, then it specifies the `encoding`.
380
384
  *
381
385
  * The `FileHandle` has to support writing.
382
386
  *
383
387
  * It is unsafe to use `filehandle.writeFile()` multiple times on the same file
384
- * without waiting for the promise to be resolved (or rejected).
388
+ * without waiting for the promise to be fulfilled (or rejected).
385
389
  *
386
390
  * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
387
391
  * current position till the end of the file. It doesn't always write from the
@@ -390,15 +394,18 @@ declare module "fs/promises" {
390
394
  */
391
395
  writeFile(
392
396
  data: string | Uint8Array,
393
- options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null,
397
+ options?:
398
+ | (ObjectEncodingOptions & FlagAndOpenMode & Abortable & { flush?: boolean | undefined })
399
+ | BufferEncoding
400
+ | null,
394
401
  ): Promise<void>;
395
402
  /**
396
403
  * Write `buffer` to the file.
397
404
  *
398
- * The promise is resolved with an object containing two properties:
405
+ * The promise is fulfilled with an object containing two properties:
399
406
  *
400
407
  * It is unsafe to use `filehandle.write()` multiple times on the same file
401
- * without waiting for the promise to be resolved (or rejected). For this
408
+ * without waiting for the promise to be fulfilled (or rejected). For this
402
409
  * scenario, use `filehandle.createWriteStream()`.
403
410
  *
404
411
  * On Linux, positional writes do not work when the file is opened in append mode.
@@ -430,10 +437,10 @@ declare module "fs/promises" {
430
437
  /**
431
438
  * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
432
439
  *
433
- * The promise is resolved with an object containing a two properties:
440
+ * The promise is fulfilled with an object containing a two properties:
434
441
  *
435
442
  * It is unsafe to call `writev()` multiple times on the same file without waiting
436
- * for the promise to be resolved (or rejected).
443
+ * for the promise to be fulfilled (or rejected).
437
444
  *
438
445
  * On Linux, positional writes don't work when the file is opened in append mode.
439
446
  * The kernel ignores the position argument and always appends the data to
@@ -482,7 +489,7 @@ declare module "fs/promises" {
482
489
  * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
483
490
  * possible values of `mode`.
484
491
  *
485
- * If the accessibility check is successful, the promise is resolved with no
492
+ * If the accessibility check is successful, the promise is fulfilled with no
486
493
  * value. If any of the accessibility checks fail, the promise is rejected
487
494
  * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
488
495
  * written by the current process.
@@ -645,7 +652,7 @@ declare module "fs/promises" {
645
652
  * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
646
653
  * will be passed as `Buffer` objects.
647
654
  *
648
- * If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects.
655
+ * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
649
656
  *
650
657
  * ```js
651
658
  * import { readdir } from 'node:fs/promises';
@@ -715,7 +722,7 @@ declare module "fs/promises" {
715
722
  ): Promise<Dirent[]>;
716
723
  /**
717
724
  * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
718
- * resolved with the`linkString` upon success.
725
+ * fulfilled with the`linkString` upon success.
719
726
  *
720
727
  * The optional `options` argument can be a string specifying an encoding, or an
721
728
  * object with an `encoding` property specifying the character encoding to use for
@@ -1022,7 +1029,7 @@ declare module "fs/promises" {
1022
1029
  function appendFile(
1023
1030
  path: PathLike | FileHandle,
1024
1031
  data: string | Uint8Array,
1025
- options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
1032
+ options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
1026
1033
  ): Promise<void>;
1027
1034
  /**
1028
1035
  * Asynchronously reads the entire contents of a file.
node/fs.d.ts CHANGED
@@ -2861,6 +2861,7 @@ declare module "fs" {
2861
2861
  & {
2862
2862
  mode?: Mode | undefined;
2863
2863
  flag?: string | undefined;
2864
+ flush?: boolean | undefined;
2864
2865
  }
2865
2866
  )
2866
2867
  | BufferEncoding
@@ -3813,6 +3814,7 @@ declare module "fs" {
3813
3814
  }
3814
3815
  interface WriteStreamOptions extends StreamOptions {
3815
3816
  fs?: CreateWriteStreamFSImplementation | null | undefined;
3817
+ flush?: boolean | undefined;
3816
3818
  }
3817
3819
  /**
3818
3820
  * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
node/module.d.ts CHANGED
@@ -122,7 +122,9 @@ declare module "module" {
122
122
  */
123
123
  findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
124
124
  }
125
- interface ImportAssertions extends NodeJS.Dict<string> {
125
+ /** @deprecated Use `ImportAttributes` instead */
126
+ interface ImportAssertions extends ImportAttributes {}
127
+ interface ImportAttributes extends NodeJS.Dict<string> {
126
128
  type?: string | undefined;
127
129
  }
128
130
  type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
@@ -154,10 +156,14 @@ declare module "module" {
154
156
  * Export conditions of the relevant `package.json`
155
157
  */
156
158
  conditions: string[];
159
+ /**
160
+ * @deprecated Use `importAttributes` instead
161
+ */
162
+ importAssertions: ImportAttributes;
157
163
  /**
158
164
  * An object whose key-value pairs represent the assertions for the module to import
159
165
  */
160
- importAssertions: ImportAssertions;
166
+ importAttributes: ImportAttributes;
161
167
  /**
162
168
  * The module importing this one, or undefined if this is the Node.js entry point
163
169
  */
@@ -169,9 +175,13 @@ declare module "module" {
169
175
  */
170
176
  format?: ModuleFormat | null | undefined;
171
177
  /**
172
- * The import assertions to use when caching the module (optional; if excluded the input will be used)
178
+ * @deprecated Use `importAttributes` instead
179
+ */
180
+ importAssertions?: ImportAttributes | undefined;
181
+ /**
182
+ * The import attributes to use when caching the module (optional; if excluded the input will be used)
173
183
  */
174
- importAssertions?: ImportAssertions | undefined;
184
+ importAttributes?: ImportAttributes | undefined;
175
185
  /**
176
186
  * A signal that this hook intends to terminate the chain of `resolve` hooks.
177
187
  * @default false
@@ -208,10 +218,14 @@ declare module "module" {
208
218
  * The format optionally supplied by the `resolve` hook chain
209
219
  */
210
220
  format: ModuleFormat;
221
+ /**
222
+ * @deprecated Use `importAttributes` instead
223
+ */
224
+ importAssertions: ImportAttributes;
211
225
  /**
212
226
  * An object whose key-value pairs represent the assertions for the module to import
213
227
  */
214
- importAssertions: ImportAssertions;
228
+ importAttributes: ImportAttributes;
215
229
  }
216
230
  interface LoadFnOutput {
217
231
  format: ModuleFormat;
node/os.d.ts CHANGED
@@ -400,7 +400,8 @@ declare module "os" {
400
400
  const EOL: string;
401
401
  /**
402
402
  * Returns the operating system CPU architecture for which the Node.js binary was
403
- * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
403
+ * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`,`'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`,
404
+ * and `'x64'`.
404
405
  *
405
406
  * The return value is equivalent to `process.arch`.
406
407
  * @since v0.5.0
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.9.5",
3
+ "version": "20.10.1",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -224,7 +224,7 @@
224
224
  "dependencies": {
225
225
  "undici-types": "~5.26.4"
226
226
  },
227
- "typesPublisherContentHash": "cd8a86c6bd22ad627d5e5634db95682b25018090a58b6227bd20bc170181834d",
228
- "typeScriptVersion": "4.5",
227
+ "typesPublisherContentHash": "0b15d1ef7892c4399bd0b2f190b187e4127a3f86fbd7ce440409b864961cdc93",
228
+ "typeScriptVersion": "4.6",
229
229
  "nonNpm": true
230
230
  }
node/process.d.ts CHANGED
@@ -902,6 +902,13 @@ declare module "process" {
902
902
  * @experimental
903
903
  */
904
904
  readonly sourceMapsEnabled: boolean;
905
+ /**
906
+ * This function enables or disables the Source Map v3 support for stack traces.
907
+ * It provides same features as launching Node.js process with commandline options --enable-source-maps.
908
+ * @since v16.6.0
909
+ * @experimental
910
+ */
911
+ setSourceMapsEnabled(value: boolean): void;
905
912
  /**
906
913
  * The `process.version` property contains the Node.js version string.
907
914
  *
@@ -1075,7 +1082,7 @@ declare module "process" {
1075
1082
  title: string;
1076
1083
  /**
1077
1084
  * The operating system CPU architecture for which the Node.js binary was compiled.
1078
- * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
1085
+ * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
1079
1086
  *
1080
1087
  * ```js
1081
1088
  * import { arch } from 'node:process';
node/test.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * 1. A synchronous function that is considered failing if it throws an exception,
20
20
  * and is considered passing otherwise.
21
- * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` resolves.
21
+ * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` fulfills.
22
22
  * 3. A function that receives a callback function. If the callback receives any
23
23
  * truthy value as its first argument, the test is considered failing. If a
24
24
  * falsy value is passed as the first argument to the callback, the test is
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * test('asynchronous passing test', async (t) => {
42
42
  * // This test passes because the Promise returned by the async
43
- * // function is not rejected.
43
+ * // function is settled and not rejected.
44
44
  * assert.strictEqual(1, 1);
45
45
  * });
46
46
  *
@@ -104,8 +104,8 @@ declare module "node:test" {
104
104
  * actions related to the current test. Examples include skipping the test, adding
105
105
  * additional diagnostic information, or creating subtests.
106
106
  *
107
- * `test()` returns a `Promise` that resolves once the test completes.
108
- * if `test()` is called within a `describe()` block, it resolve immediately.
107
+ * `test()` returns a `Promise` that fulfills once the test completes.
108
+ * if `test()` is called within a `describe()` block, it fulfills immediately.
109
109
  * The return value can usually be discarded for top level tests.
110
110
  * However, the return value from subtests should be used to prevent the parent
111
111
  * test from finishing first and cancelling the subtest
@@ -132,7 +132,7 @@ declare module "node:test" {
132
132
  * @param options Configuration options for the test. The following properties are supported:
133
133
  * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the
134
134
  * second argument.
135
- * @return Resolved with `undefined` once the test completes, or immediately if the test runs within {@link describe}.
135
+ * @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within {@link describe}.
136
136
  */
137
137
  function test(name?: string, fn?: TestFn): Promise<void>;
138
138
  function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
node/ts4.8/dgram.d.ts CHANGED
@@ -501,7 +501,7 @@ declare module "dgram" {
501
501
  * process active, allowing the process to exit even if the socket is still
502
502
  * listening.
503
503
  *
504
- * Calling `socket.unref()` multiple times will have no addition effect.
504
+ * Calling `socket.unref()` multiple times will have no additional effect.
505
505
  *
506
506
  * The `socket.unref()` method returns a reference to the socket so calls can be
507
507
  * chained.
node/ts4.8/events.d.ts CHANGED
@@ -35,6 +35,7 @@
35
35
  * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/events.js)
36
36
  */
37
37
  declare module "events" {
38
+ import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
38
39
  // NOTE: This class is in the docs but is **not actually exported** by Node.
39
40
  // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
40
41
  // actually starts exporting the class, uncomment below.
@@ -107,6 +108,9 @@ declare module "events" {
107
108
  */
108
109
  class EventEmitter {
109
110
  constructor(options?: EventEmitterOptions);
111
+
112
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
113
+
110
114
  /**
111
115
  * Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
112
116
  * event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
@@ -378,7 +382,7 @@ declare module "events" {
378
382
  * ```
379
383
  * @since v20.5.0
380
384
  * @experimental
381
- * @return that removes the `abort` listener.
385
+ * @return Disposable that removes the `abort` listener.
382
386
  */
383
387
  static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
384
388
  /**
@@ -451,10 +455,89 @@ declare module "events" {
451
455
  */
452
456
  signal?: AbortSignal | undefined;
453
457
  }
458
+
459
+ export interface EventEmitterReferencingAsyncResource extends AsyncResource {
460
+ readonly eventEmitter: EventEmitterAsyncResource;
461
+ }
462
+
463
+ export interface EventEmitterAsyncResourceOptions extends AsyncResourceOptions, EventEmitterOptions {
464
+ /**
465
+ * The type of async event, this is required when instantiating `EventEmitterAsyncResource`
466
+ * directly rather than as a child class.
467
+ * @default new.target.name if instantiated as a child class.
468
+ */
469
+ name?: string;
470
+ }
471
+
472
+ /**
473
+ * Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
474
+ * require manual async tracking. Specifically, all events emitted by instances
475
+ * of `events.EventEmitterAsyncResource` will run within its `async context`.
476
+ *
477
+ * ```js
478
+ * import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
479
+ * import { notStrictEqual, strictEqual } from 'node:assert';
480
+ * import { executionAsyncId, triggerAsyncId } from 'node:async_hooks';
481
+ *
482
+ * // Async tracking tooling will identify this as 'Q'.
483
+ * const ee1 = new EventEmitterAsyncResource({ name: 'Q' });
484
+ *
485
+ * // 'foo' listeners will run in the EventEmitters async context.
486
+ * ee1.on('foo', () => {
487
+ * strictEqual(executionAsyncId(), ee1.asyncId);
488
+ * strictEqual(triggerAsyncId(), ee1.triggerAsyncId);
489
+ * });
490
+ *
491
+ * const ee2 = new EventEmitter();
492
+ *
493
+ * // 'foo' listeners on ordinary EventEmitters that do not track async
494
+ * // context, however, run in the same async context as the emit().
495
+ * ee2.on('foo', () => {
496
+ * notStrictEqual(executionAsyncId(), ee2.asyncId);
497
+ * notStrictEqual(triggerAsyncId(), ee2.triggerAsyncId);
498
+ * });
499
+ *
500
+ * Promise.resolve().then(() => {
501
+ * ee1.emit('foo');
502
+ * ee2.emit('foo');
503
+ * });
504
+ * ```
505
+ *
506
+ * The `EventEmitterAsyncResource` class has the same methods and takes the
507
+ * same options as `EventEmitter` and `AsyncResource` themselves.
508
+ * @since v17.4.0, v16.14.0
509
+ */
510
+ export class EventEmitterAsyncResource extends EventEmitter {
511
+ /**
512
+ * @param options Only optional in child class.
513
+ */
514
+ constructor(options?: EventEmitterAsyncResourceOptions);
515
+ /**
516
+ * Call all `destroy` hooks. This should only ever be called once. An error will
517
+ * be thrown if it is called more than once. This **must** be manually called. If
518
+ * the resource is left to be collected by the GC then the `destroy` hooks will
519
+ * never be called.
520
+ */
521
+ emitDestroy(): void;
522
+ /**
523
+ * The unique `asyncId` assigned to the resource.
524
+ */
525
+ readonly asyncId: number;
526
+ /**
527
+ * The same triggerAsyncId that is passed to the AsyncResource constructor.
528
+ */
529
+ readonly triggerAsyncId: number;
530
+ /**
531
+ * The returned `AsyncResource` object has an additional `eventEmitter` property
532
+ * that provides a reference to this `EventEmitterAsyncResource`.
533
+ */
534
+ readonly asyncResource: EventEmitterReferencingAsyncResource;
535
+ }
454
536
  }
455
537
  global {
456
538
  namespace NodeJS {
457
539
  interface EventEmitter {
540
+ [EventEmitter.captureRejectionSymbol]?(error: Error, event: string, ...args: any[]): void;
458
541
  /**
459
542
  * Alias for `emitter.on(eventName, listener)`.
460
543
  * @since v0.1.26
@@ -82,6 +82,7 @@ declare module "fs/promises" {
82
82
  emitClose?: boolean | undefined;
83
83
  start?: number | undefined;
84
84
  highWaterMark?: number | undefined;
85
+ flush?: boolean | undefined;
85
86
  }
86
87
  interface ReadableWebStreamOptions {
87
88
  /**
@@ -107,7 +108,10 @@ declare module "fs/promises" {
107
108
  */
108
109
  appendFile(
109
110
  data: string | Uint8Array,
110
- options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
111
+ options?:
112
+ | (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined })
113
+ | BufferEncoding
114
+ | null,
111
115
  ): Promise<void>;
112
116
  /**
113
117
  * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
@@ -366,7 +370,7 @@ declare module "fs/promises" {
366
370
  */
367
371
  truncate(len?: number): Promise<void>;
368
372
  /**
369
- * Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
373
+ * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success.
370
374
  * @since v10.0.0
371
375
  */
372
376
  utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
@@ -374,14 +378,14 @@ declare module "fs/promises" {
374
378
  * Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
375
379
  * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
376
380
  * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
377
- * The promise is resolved with no arguments upon success.
381
+ * The promise is fulfilled with no arguments upon success.
378
382
  *
379
383
  * If `options` is a string, then it specifies the `encoding`.
380
384
  *
381
385
  * The `FileHandle` has to support writing.
382
386
  *
383
387
  * It is unsafe to use `filehandle.writeFile()` multiple times on the same file
384
- * without waiting for the promise to be resolved (or rejected).
388
+ * without waiting for the promise to be fulfilled (or rejected).
385
389
  *
386
390
  * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
387
391
  * current position till the end of the file. It doesn't always write from the
@@ -390,15 +394,18 @@ declare module "fs/promises" {
390
394
  */
391
395
  writeFile(
392
396
  data: string | Uint8Array,
393
- options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null,
397
+ options?:
398
+ | (ObjectEncodingOptions & FlagAndOpenMode & Abortable & { flush?: boolean | undefined })
399
+ | BufferEncoding
400
+ | null,
394
401
  ): Promise<void>;
395
402
  /**
396
403
  * Write `buffer` to the file.
397
404
  *
398
- * The promise is resolved with an object containing two properties:
405
+ * The promise is fulfilled with an object containing two properties:
399
406
  *
400
407
  * It is unsafe to use `filehandle.write()` multiple times on the same file
401
- * without waiting for the promise to be resolved (or rejected). For this
408
+ * without waiting for the promise to be fulfilled (or rejected). For this
402
409
  * scenario, use `filehandle.createWriteStream()`.
403
410
  *
404
411
  * On Linux, positional writes do not work when the file is opened in append mode.
@@ -430,10 +437,10 @@ declare module "fs/promises" {
430
437
  /**
431
438
  * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
432
439
  *
433
- * The promise is resolved with an object containing a two properties:
440
+ * The promise is fulfilled with an object containing a two properties:
434
441
  *
435
442
  * It is unsafe to call `writev()` multiple times on the same file without waiting
436
- * for the promise to be resolved (or rejected).
443
+ * for the promise to be fulfilled (or rejected).
437
444
  *
438
445
  * On Linux, positional writes don't work when the file is opened in append mode.
439
446
  * The kernel ignores the position argument and always appends the data to
@@ -482,7 +489,7 @@ declare module "fs/promises" {
482
489
  * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
483
490
  * possible values of `mode`.
484
491
  *
485
- * If the accessibility check is successful, the promise is resolved with no
492
+ * If the accessibility check is successful, the promise is fulfilled with no
486
493
  * value. If any of the accessibility checks fail, the promise is rejected
487
494
  * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
488
495
  * written by the current process.
@@ -645,7 +652,7 @@ declare module "fs/promises" {
645
652
  * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
646
653
  * will be passed as `Buffer` objects.
647
654
  *
648
- * If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects.
655
+ * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
649
656
  *
650
657
  * ```js
651
658
  * import { readdir } from 'node:fs/promises';
@@ -715,7 +722,7 @@ declare module "fs/promises" {
715
722
  ): Promise<Dirent[]>;
716
723
  /**
717
724
  * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
718
- * resolved with the`linkString` upon success.
725
+ * fulfilled with the`linkString` upon success.
719
726
  *
720
727
  * The optional `options` argument can be a string specifying an encoding, or an
721
728
  * object with an `encoding` property specifying the character encoding to use for
@@ -1022,7 +1029,7 @@ declare module "fs/promises" {
1022
1029
  function appendFile(
1023
1030
  path: PathLike | FileHandle,
1024
1031
  data: string | Uint8Array,
1025
- options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null,
1032
+ options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
1026
1033
  ): Promise<void>;
1027
1034
  /**
1028
1035
  * Asynchronously reads the entire contents of a file.
node/ts4.8/fs.d.ts CHANGED
@@ -2861,6 +2861,7 @@ declare module "fs" {
2861
2861
  & {
2862
2862
  mode?: Mode | undefined;
2863
2863
  flag?: string | undefined;
2864
+ flush?: boolean | undefined;
2864
2865
  }
2865
2866
  )
2866
2867
  | BufferEncoding
@@ -3813,6 +3814,7 @@ declare module "fs" {
3813
3814
  }
3814
3815
  interface WriteStreamOptions extends StreamOptions {
3815
3816
  fs?: CreateWriteStreamFSImplementation | null | undefined;
3817
+ flush?: boolean | undefined;
3816
3818
  }
3817
3819
  /**
3818
3820
  * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
node/ts4.8/module.d.ts CHANGED
@@ -122,7 +122,9 @@ declare module "module" {
122
122
  */
123
123
  findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
124
124
  }
125
- interface ImportAssertions extends NodeJS.Dict<string> {
125
+ /** @deprecated Use `ImportAttributes` instead */
126
+ interface ImportAssertions extends ImportAttributes {}
127
+ interface ImportAttributes extends NodeJS.Dict<string> {
126
128
  type?: string | undefined;
127
129
  }
128
130
  type ModuleFormat = "builtin" | "commonjs" | "json" | "module" | "wasm";
@@ -154,10 +156,14 @@ declare module "module" {
154
156
  * Export conditions of the relevant `package.json`
155
157
  */
156
158
  conditions: string[];
159
+ /**
160
+ * @deprecated Use `importAttributes` instead
161
+ */
162
+ importAssertions: ImportAttributes;
157
163
  /**
158
164
  * An object whose key-value pairs represent the assertions for the module to import
159
165
  */
160
- importAssertions: ImportAssertions;
166
+ importAttributes: ImportAttributes;
161
167
  /**
162
168
  * The module importing this one, or undefined if this is the Node.js entry point
163
169
  */
@@ -169,9 +175,13 @@ declare module "module" {
169
175
  */
170
176
  format?: ModuleFormat | null | undefined;
171
177
  /**
172
- * The import assertions to use when caching the module (optional; if excluded the input will be used)
178
+ * @deprecated Use `importAttributes` instead
179
+ */
180
+ importAssertions?: ImportAttributes | undefined;
181
+ /**
182
+ * The import attributes to use when caching the module (optional; if excluded the input will be used)
173
183
  */
174
- importAssertions?: ImportAssertions | undefined;
184
+ importAttributes?: ImportAttributes | undefined;
175
185
  /**
176
186
  * A signal that this hook intends to terminate the chain of `resolve` hooks.
177
187
  * @default false
@@ -208,10 +218,14 @@ declare module "module" {
208
218
  * The format optionally supplied by the `resolve` hook chain
209
219
  */
210
220
  format: ModuleFormat;
221
+ /**
222
+ * @deprecated Use `importAttributes` instead
223
+ */
224
+ importAssertions: ImportAttributes;
211
225
  /**
212
226
  * An object whose key-value pairs represent the assertions for the module to import
213
227
  */
214
- importAssertions: ImportAssertions;
228
+ importAttributes: ImportAttributes;
215
229
  }
216
230
  interface LoadFnOutput {
217
231
  format: ModuleFormat;
node/ts4.8/os.d.ts CHANGED
@@ -400,7 +400,8 @@ declare module "os" {
400
400
  const EOL: string;
401
401
  /**
402
402
  * Returns the operating system CPU architecture for which the Node.js binary was
403
- * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
403
+ * compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`,`'mips'`, `'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`,
404
+ * and `'x64'`.
404
405
  *
405
406
  * The return value is equivalent to `process.arch`.
406
407
  * @since v0.5.0
node/ts4.8/process.d.ts CHANGED
@@ -902,6 +902,13 @@ declare module "process" {
902
902
  * @experimental
903
903
  */
904
904
  readonly sourceMapsEnabled: boolean;
905
+ /**
906
+ * This function enables or disables the Source Map v3 support for stack traces.
907
+ * It provides same features as launching Node.js process with commandline options --enable-source-maps.
908
+ * @since v16.6.0
909
+ * @experimental
910
+ */
911
+ setSourceMapsEnabled(value: boolean): void;
905
912
  /**
906
913
  * The `process.version` property contains the Node.js version string.
907
914
  *
@@ -1075,7 +1082,7 @@ declare module "process" {
1075
1082
  title: string;
1076
1083
  /**
1077
1084
  * The operating system CPU architecture for which the Node.js binary was compiled.
1078
- * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`,`'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
1085
+ * Possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'riscv64'`, `'s390'`, `'s390x'`, and `'x64'`.
1079
1086
  *
1080
1087
  * ```js
1081
1088
  * import { arch } from 'node:process';
node/ts4.8/test.d.ts CHANGED
@@ -18,7 +18,7 @@
18
18
  *
19
19
  * 1. A synchronous function that is considered failing if it throws an exception,
20
20
  * and is considered passing otherwise.
21
- * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` resolves.
21
+ * 2. A function that returns a `Promise` that is considered failing if the`Promise` rejects, and is considered passing if the `Promise` fulfills.
22
22
  * 3. A function that receives a callback function. If the callback receives any
23
23
  * truthy value as its first argument, the test is considered failing. If a
24
24
  * falsy value is passed as the first argument to the callback, the test is
@@ -40,7 +40,7 @@
40
40
  *
41
41
  * test('asynchronous passing test', async (t) => {
42
42
  * // This test passes because the Promise returned by the async
43
- * // function is not rejected.
43
+ * // function is settled and not rejected.
44
44
  * assert.strictEqual(1, 1);
45
45
  * });
46
46
  *
@@ -104,8 +104,8 @@ declare module "node:test" {
104
104
  * actions related to the current test. Examples include skipping the test, adding
105
105
  * additional diagnostic information, or creating subtests.
106
106
  *
107
- * `test()` returns a `Promise` that resolves once the test completes.
108
- * if `test()` is called within a `describe()` block, it resolve immediately.
107
+ * `test()` returns a `Promise` that fulfills once the test completes.
108
+ * if `test()` is called within a `describe()` block, it fulfills immediately.
109
109
  * The return value can usually be discarded for top level tests.
110
110
  * However, the return value from subtests should be used to prevent the parent
111
111
  * test from finishing first and cancelling the subtest
@@ -132,7 +132,7 @@ declare module "node:test" {
132
132
  * @param options Configuration options for the test. The following properties are supported:
133
133
  * @param [fn='A no-op function'] The function under test. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the
134
134
  * second argument.
135
- * @return Resolved with `undefined` once the test completes, or immediately if the test runs within {@link describe}.
135
+ * @return Fulfilled with `undefined` once the test completes, or immediately if the test runs within {@link describe}.
136
136
  */
137
137
  function test(name?: string, fn?: TestFn): Promise<void>;
138
138
  function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
node/ts4.8/vm.d.ts CHANGED
@@ -37,7 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
- import { ImportAssertions } from "node:module";
40
+ import { ImportAttributes } from "node:module";
41
41
  interface Context extends NodeJS.Dict<any> {}
42
42
  interface BaseOptions {
43
43
  /**
@@ -68,7 +68,7 @@ declare module "vm" {
68
68
  * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
69
69
  */
70
70
  importModuleDynamically?:
71
- | ((specifier: string, script: Script, importAssertions: ImportAssertions) => Module)
71
+ | ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module)
72
72
  | undefined;
73
73
  }
74
74
  interface RunningScriptOptions extends BaseOptions {
@@ -593,7 +593,9 @@ declare module "vm" {
593
593
  specifier: string,
594
594
  referencingModule: Module,
595
595
  extra: {
596
- assert: Object;
596
+ /** @deprecated Use `attributes` instead */
597
+ assert: ImportAttributes;
598
+ attributes: ImportAttributes;
597
599
  },
598
600
  ) => Module | Promise<Module>;
599
601
  type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
@@ -602,8 +604,8 @@ declare module "vm" {
602
604
  * flag enabled.
603
605
  *
604
606
  * The `vm.Module` class provides a low-level interface for using
605
- * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://www.ecma-international.org/ecma-262/#sec-abstract-module-records)
606
- * s as defined in the ECMAScript
607
+ * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://262.ecma-international.org/14.0/#sec-abstract-module-records) s as
608
+ * defined in the ECMAScript
607
609
  * specification.
608
610
  *
609
611
  * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from
node/vm.d.ts CHANGED
@@ -37,7 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
- import { ImportAssertions } from "node:module";
40
+ import { ImportAttributes } from "node:module";
41
41
  interface Context extends NodeJS.Dict<any> {}
42
42
  interface BaseOptions {
43
43
  /**
@@ -68,7 +68,7 @@ declare module "vm" {
68
68
  * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
69
69
  */
70
70
  importModuleDynamically?:
71
- | ((specifier: string, script: Script, importAssertions: ImportAssertions) => Module)
71
+ | ((specifier: string, script: Script, importAttributes: ImportAttributes) => Module)
72
72
  | undefined;
73
73
  }
74
74
  interface RunningScriptOptions extends BaseOptions {
@@ -593,7 +593,9 @@ declare module "vm" {
593
593
  specifier: string,
594
594
  referencingModule: Module,
595
595
  extra: {
596
- assert: Object;
596
+ /** @deprecated Use `attributes` instead */
597
+ assert: ImportAttributes;
598
+ attributes: ImportAttributes;
597
599
  },
598
600
  ) => Module | Promise<Module>;
599
601
  type ModuleStatus = "unlinked" | "linking" | "linked" | "evaluating" | "evaluated" | "errored";
@@ -602,8 +604,8 @@ declare module "vm" {
602
604
  * flag enabled.
603
605
  *
604
606
  * The `vm.Module` class provides a low-level interface for using
605
- * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://www.ecma-international.org/ecma-262/#sec-abstract-module-records)
606
- * s as defined in the ECMAScript
607
+ * ECMAScript modules in VM contexts. It is the counterpart of the `vm.Script`class that closely mirrors [Module Record](https://262.ecma-international.org/14.0/#sec-abstract-module-records) s as
608
+ * defined in the ECMAScript
607
609
  * specification.
608
610
  *
609
611
  * Unlike `vm.Script` however, every `vm.Module` object is bound to a context from