@types/node 18.19.51 → 18.19.53

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 v18.19/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/v18.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 25 Sep 2024 00:29:50 GMT
11
+ * Last updated: Wed, 25 Sep 2024 22:07:42 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node v18.19/buffer.d.ts CHANGED
@@ -124,7 +124,7 @@ declare module "buffer" {
124
124
  export interface BlobOptions {
125
125
  /**
126
126
  * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
127
- * will be converted to the platform native line-ending as specified by `require('node:os').EOL`.
127
+ * will be converted to the platform native line-ending as specified by `import { EOL } from 'node:node:os'`.
128
128
  */
129
129
  endings?: "transparent" | "native";
130
130
  /**
@@ -189,7 +189,7 @@ declare module "buffer" {
189
189
  export interface FileOptions {
190
190
  /**
191
191
  * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
192
- * converted to the platform native line-ending as specified by `require('node:os').EOL`.
192
+ * converted to the platform native line-ending as specified by `import { EOL } from 'node:node:os'`.
193
193
  */
194
194
  endings?: "native" | "transparent";
195
195
  /** The File content-type. */
@@ -239,6 +239,13 @@ declare module "buffer" {
239
239
  | {
240
240
  valueOf(): T;
241
241
  };
242
+ // `WithArrayBufferLike` is a backwards-compatible workaround for the addition of a `TArrayBuffer` type parameter to
243
+ // `Uint8Array` to ensure that `Buffer` remains assignment-compatible with `Uint8Array`, but without the added
244
+ // complexity involved with making `Buffer` itself generic as that would require re-introducing `"typesVersions"` to
245
+ // the NodeJS types. It is likely this interface will become deprecated in the future once `Buffer` does become generic.
246
+ interface WithArrayBufferLike<TArrayBuffer extends ArrayBufferLike> {
247
+ readonly buffer: TArrayBuffer;
248
+ }
242
249
  /**
243
250
  * Raw data is stored in instances of the Buffer class.
244
251
  * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
@@ -890,7 +897,7 @@ declare module "buffer" {
890
897
  * @param [start=0] Where the new `Buffer` will start.
891
898
  * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
892
899
  */
893
- slice(start?: number, end?: number): Buffer;
900
+ slice(start?: number, end?: number): Buffer & WithArrayBufferLike<ArrayBuffer>;
894
901
  /**
895
902
  * Returns a new `Buffer` that references the same memory as the original, but
896
903
  * offset and cropped by the `start` and `end` indices.
@@ -950,7 +957,7 @@ declare module "buffer" {
950
957
  * @param [start=0] Where the new `Buffer` will start.
951
958
  * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
952
959
  */
953
- subarray(start?: number, end?: number): Buffer;
960
+ subarray(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
954
961
  /**
955
962
  * Writes `value` to `buf` at the specified `offset` as big-endian.
956
963
  *
@@ -1608,7 +1615,7 @@ declare module "buffer" {
1608
1615
  * @since v5.10.0
1609
1616
  * @return A reference to `buf`.
1610
1617
  */
1611
- swap16(): Buffer;
1618
+ swap16(): this;
1612
1619
  /**
1613
1620
  * Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1614
1621
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
@@ -1634,7 +1641,7 @@ declare module "buffer" {
1634
1641
  * @since v5.10.0
1635
1642
  * @return A reference to `buf`.
1636
1643
  */
1637
- swap32(): Buffer;
1644
+ swap32(): this;
1638
1645
  /**
1639
1646
  * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
1640
1647
  * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
@@ -1660,7 +1667,7 @@ declare module "buffer" {
1660
1667
  * @since v6.3.0
1661
1668
  * @return A reference to `buf`.
1662
1669
  */
1663
- swap64(): Buffer;
1670
+ swap64(): this;
1664
1671
  /**
1665
1672
  * Writes `value` to `buf` at the specified `offset`. `value` must be a
1666
1673
  * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
@@ -2257,7 +2264,7 @@ declare module "buffer" {
2257
2264
  function btoa(data: string): string;
2258
2265
  interface Blob extends _Blob {}
2259
2266
  /**
2260
- * `Blob` class is a global reference for `require('node:buffer').Blob`
2267
+ * `Blob` class is a global reference for `import { Blob } from 'node:node:buffer'`
2261
2268
  * https://nodejs.org/api/buffer.html#class-blob
2262
2269
  * @since v18.0.0
2263
2270
  */
@@ -4,7 +4,7 @@
4
4
  * is primarily provided by the {@link spawn} function:
5
5
  *
6
6
  * ```js
7
- * const { spawn } = require('child_process');
7
+ * import { spawn } from 'node:child_process';
8
8
  * const ls = spawn('ls', ['-lh', '/usr']);
9
9
  *
10
10
  * ls.stdout.on('data', (data) => {
@@ -109,7 +109,7 @@ declare module "child_process" {
109
109
  * refer to the same value.
110
110
  *
111
111
  * ```js
112
- * const { spawn } = require('child_process');
112
+ * import { spawn } from 'node:child_process';
113
113
  *
114
114
  * const subprocess = spawn('ls');
115
115
  *
@@ -154,9 +154,9 @@ declare module "child_process" {
154
154
  * in the array are `null`.
155
155
  *
156
156
  * ```js
157
- * const assert = require('assert');
158
- * const fs = require('fs');
159
- * const child_process = require('child_process');
157
+ * import assert from 'node:assert';
158
+ * import fs from 'node:fs';
159
+ * import child_process from 'node:child_process';
160
160
  *
161
161
  * const subprocess = child_process.spawn('ls', {
162
162
  * stdio: [
@@ -204,7 +204,7 @@ declare module "child_process" {
204
204
  * emitted.
205
205
  *
206
206
  * ```js
207
- * const { spawn } = require('child_process');
207
+ * import { spawn } from 'node:child_process';
208
208
  * const grep = spawn('grep', ['ssh']);
209
209
  *
210
210
  * console.log(`Spawned child pid: ${grep.pid}`);
@@ -251,7 +251,7 @@ declare module "child_process" {
251
251
  * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
252
252
  *
253
253
  * ```js
254
- * const { spawn } = require('child_process');
254
+ * import { spawn } from 'node:child_process';
255
255
  * const grep = spawn('grep', ['ssh']);
256
256
  *
257
257
  * grep.on('close', (code, signal) => {
@@ -284,7 +284,7 @@ declare module "child_process" {
284
284
  *
285
285
  * ```js
286
286
  * 'use strict';
287
- * const { spawn } = require('child_process');
287
+ * import { spawn } from 'node:child_process';
288
288
  *
289
289
  * const subprocess = spawn(
290
290
  * 'sh',
@@ -322,7 +322,7 @@ declare module "child_process" {
322
322
  * For example, in the parent script:
323
323
  *
324
324
  * ```js
325
- * const cp = require('child_process');
325
+ * import cp from 'node:child_process';
326
326
  * const n = cp.fork(`${__dirname}/sub.js`);
327
327
  *
328
328
  * n.on('message', (m) => {
@@ -376,10 +376,12 @@ declare module "child_process" {
376
376
  * a TCP server object to the child process as illustrated in the example below:
377
377
  *
378
378
  * ```js
379
- * const subprocess = require('child_process').fork('subprocess.js');
379
+ * import child_process from 'node:child_process';
380
+ * const subprocess = child_process.fork('subprocess.js');
380
381
  *
381
382
  * // Open up the server object and send the handle.
382
- * const server = require('net').createServer();
383
+ * import net from 'node:net';
384
+ * const server = net.createServer();
383
385
  * server.on('connection', (socket) => {
384
386
  * socket.end('handled by parent');
385
387
  * });
@@ -415,13 +417,14 @@ declare module "child_process" {
415
417
  * handle connections with "normal" or "special" priority:
416
418
  *
417
419
  * ```js
418
- * const { fork } = require('child_process');
420
+ * import { fork } from 'node:child_process';
419
421
  * const normal = fork('subprocess.js', ['normal']);
420
422
  * const special = fork('subprocess.js', ['special']);
421
423
  *
422
424
  * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
423
- * // the sockets from being read before they are sent to the child process.
424
- * const server = require('net').createServer({ pauseOnConnect: true });
425
+ * // the sockets from being read before they are sent to the child proces
426
+ * import net from 'node:net';
427
+ * const server = met.createServer({ pauseOnConnect: true });
425
428
  * server.on('connection', (socket) => {
426
429
  *
427
430
  * // If this is special priority...
@@ -492,7 +495,7 @@ declare module "child_process" {
492
495
  * the child and the parent.
493
496
  *
494
497
  * ```js
495
- * const { spawn } = require('child_process');
498
+ * import { spawn } from 'node:child_process';
496
499
  *
497
500
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
498
501
  * detached: true,
@@ -510,7 +513,7 @@ declare module "child_process" {
510
513
  * to wait for the child to exit before exiting itself.
511
514
  *
512
515
  * ```js
513
- * const { spawn } = require('child_process');
516
+ * import { spawn } from 'node:child_process';
514
517
  *
515
518
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
516
519
  * detached: true,
@@ -713,7 +716,7 @@ declare module "child_process" {
713
716
  * exit code:
714
717
  *
715
718
  * ```js
716
- * const { spawn } = require('child_process');
719
+ * import { spawn } from 'node:child_process';
717
720
  * const ls = spawn('ls', ['-lh', '/usr']);
718
721
  *
719
722
  * ls.stdout.on('data', (data) => {
@@ -732,7 +735,7 @@ declare module "child_process" {
732
735
  * Example: A very elaborate way to run `ps ax | grep ssh`
733
736
  *
734
737
  * ```js
735
- * const { spawn } = require('child_process');
738
+ * import { spawn } from 'node:child_process';
736
739
  * const ps = spawn('ps', ['ax']);
737
740
  * const grep = spawn('grep', ['ssh']);
738
741
  *
@@ -769,7 +772,7 @@ declare module "child_process" {
769
772
  * Example of checking for failed `spawn`:
770
773
  *
771
774
  * ```js
772
- * const { spawn } = require('child_process');
775
+ * import { spawn } from 'node:child_process';
773
776
  * const subprocess = spawn('bad_command');
774
777
  *
775
778
  * subprocess.on('error', (err) => {
@@ -787,7 +790,7 @@ declare module "child_process" {
787
790
  * the error passed to the callback will be an `AbortError`:
788
791
  *
789
792
  * ```js
790
- * const { spawn } = require('child_process');
793
+ * import { spawn } from 'node:child_process';
791
794
  * const controller = new AbortController();
792
795
  * const { signal } = controller;
793
796
  * const grep = spawn('grep', ['ssh'], { signal });
@@ -906,7 +909,7 @@ declare module "child_process" {
906
909
  * need to be dealt with accordingly:
907
910
  *
908
911
  * ```js
909
- * const { exec } = require('child_process');
912
+ * import { exec } from 'node:child_process';
910
913
  *
911
914
  * exec('"/path/to/test file/test.sh" arg1 arg2');
912
915
  * // Double quotes are used so that the space in the path is not interpreted as
@@ -932,7 +935,7 @@ declare module "child_process" {
932
935
  * encoding, `Buffer` objects will be passed to the callback instead.
933
936
  *
934
937
  * ```js
935
- * const { exec } = require('child_process');
938
+ * import { exec } from 'node:child_process';
936
939
  * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
937
940
  * if (error) {
938
941
  * console.error(`exec error: ${error}`);
@@ -957,8 +960,9 @@ declare module "child_process" {
957
960
  * callback, but with two additional properties `stdout` and `stderr`.
958
961
  *
959
962
  * ```js
960
- * const util = require('util');
961
- * const exec = util.promisify(require('child_process').exec);
963
+ * import util from 'node:util';
964
+ * import child_process from 'node:child_process';
965
+ * const exec = util.promisify(child_process.exec);
962
966
  *
963
967
  * async function lsExample() {
964
968
  * const { stdout, stderr } = await exec('ls');
@@ -972,7 +976,7 @@ declare module "child_process" {
972
976
  * the error passed to the callback will be an `AbortError`:
973
977
  *
974
978
  * ```js
975
- * const { exec } = require('child_process');
979
+ * import { exec } from 'node:child_process';
976
980
  * const controller = new AbortController();
977
981
  * const { signal } = controller;
978
982
  * const child = exec('grep ssh', { signal }, (error) => {
@@ -1096,7 +1100,7 @@ declare module "child_process" {
1096
1100
  * supported.
1097
1101
  *
1098
1102
  * ```js
1099
- * const { execFile } = require('child_process');
1103
+ * import { execFile } from 'node:child_process';
1100
1104
  * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
1101
1105
  * if (error) {
1102
1106
  * throw error;
@@ -1119,8 +1123,9 @@ declare module "child_process" {
1119
1123
  * callback, but with two additional properties `stdout` and `stderr`.
1120
1124
  *
1121
1125
  * ```js
1122
- * const util = require('util');
1123
- * const execFile = util.promisify(require('child_process').execFile);
1126
+ * import util from 'node:util';
1127
+ * import child_process from 'node:child_process';
1128
+ * const execFile = util.promisify(child_process.execFile);
1124
1129
  * async function getVersion() {
1125
1130
  * const { stdout } = await execFile('node', ['--version']);
1126
1131
  * console.log(stdout);
@@ -1136,7 +1141,7 @@ declare module "child_process" {
1136
1141
  * the error passed to the callback will be an `AbortError`:
1137
1142
  *
1138
1143
  * ```js
1139
- * const { execFile } = require('child_process');
1144
+ * import { execFile } from 'node:child_process';
1140
1145
  * const controller = new AbortController();
1141
1146
  * const { signal } = controller;
1142
1147
  * const child = execFile('node', ['--version'], { signal }, (error) => {
@@ -1372,12 +1377,12 @@ declare module "child_process" {
1372
1377
  * the error passed to the callback will be an `AbortError`:
1373
1378
  *
1374
1379
  * ```js
1380
+ * import { fork } from 'node:child_process';
1375
1381
  * if (process.argv[2] === 'child') {
1376
1382
  * setTimeout(() => {
1377
1383
  * console.log(`Hello from ${process.argv[2]}!`);
1378
1384
  * }, 1_000);
1379
1385
  * } else {
1380
- * const { fork } = require('child_process');
1381
1386
  * const controller = new AbortController();
1382
1387
  * const { signal } = controller;
1383
1388
  * const child = fork(__filename, ['child'], { signal });
@@ -231,6 +231,7 @@ declare module "cluster" {
231
231
  * the `'disconnect'` event has not been emitted after some time.
232
232
  *
233
233
  * ```js
234
+ * import net from 'node:net';
234
235
  * if (cluster.isPrimary) {
235
236
  * const worker = cluster.fork();
236
237
  * let timeout;
@@ -248,7 +249,6 @@ declare module "cluster" {
248
249
  * });
249
250
  *
250
251
  * } else if (cluster.isWorker) {
251
- * const net = require('node:net');
252
252
  * const server = net.createServer((socket) => {
253
253
  * // Connections never end
254
254
  * });
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * * A `Console` class with methods such as `console.log()`, `console.error()`, and `console.warn()` that can be used to write to any Node.js stream.
8
8
  * * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstdout) and
9
- * [`process.stderr`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstderr). The global `console` can be used without calling `require('node:console')`.
9
+ * [`process.stderr`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
10
10
  *
11
11
  * _**Warning**_: The global console object's methods are neither consistently
12
12
  * synchronous like the browser APIs they resemble, nor are they consistently
@@ -362,7 +362,7 @@ declare module "node:console" {
362
362
  *
363
363
  * * A `Console` class with methods such as `console.log()`, `console.error()` and `console.warn()` that can be used to write to any Node.js stream.
364
364
  * * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstdout) and
365
- * [`process.stderr`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstderr). The global `console` can be used without calling `require('console')`.
365
+ * [`process.stderr`](https://nodejs.org/docs/latest-v18.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
366
366
  *
367
367
  * _**Warning**_: The global console object's methods are neither consistently
368
368
  * synchronous like the browser APIs they resemble, nor are they consistently
node v18.19/crypto.d.ts CHANGED
@@ -4049,7 +4049,7 @@ declare module "crypto" {
4049
4049
  saltLength: number;
4050
4050
  }
4051
4051
  /**
4052
- * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
4052
+ * Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
4053
4053
  * `Crypto` is a singleton that provides access to the remainder of the crypto API.
4054
4054
  * @since v15.0.0
4055
4055
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The `dns.promises` API provides an alternative set of asynchronous DNS methods
3
3
  * that return `Promise` objects rather than using callbacks. The API is accessible
4
- * via `require('node:dns').promises` or `require('node:dns/promises')`.
4
+ * via `import { promises } from 'node:dns'` or `import dnsPromises from 'node:dns/promises'`.
5
5
  * @since v10.6.0
6
6
  */
7
7
  declare module "dns/promises" {
@@ -60,7 +60,7 @@ declare module "dns/promises" {
60
60
  * Example usage:
61
61
  *
62
62
  * ```js
63
- * const dns = require('node:dns');
63
+ * import dns from 'node:dns';
64
64
  * const dnsPromises = dns.promises;
65
65
  * const options = {
66
66
  * family: 6,
@@ -96,8 +96,8 @@ declare module "dns/promises" {
96
96
  * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v18.x/api/errors.html#class-error) object, where `err.code` is the error code.
97
97
  *
98
98
  * ```js
99
- * const dnsPromises = require('node:dns').promises;
100
- * dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
99
+ * import dns from 'node:dns';
100
+ * dns.promises.lookupService('127.0.0.1', 22).then((result) => {
101
101
  * console.log(result.hostname, result.service);
102
102
  * // Prints: localhost ssh
103
103
  * });
@@ -392,7 +392,8 @@ declare module "dns/promises" {
392
392
  * other resolvers:
393
393
  *
394
394
  * ```js
395
- * const { Resolver } = require('node:dns').promises;
395
+ * import dns from 'node:dns';
396
+ * const { Resolver } = dns.promises;
396
397
  * const resolver = new Resolver();
397
398
  * resolver.setServers(['4.4.4.4']);
398
399
  *
node v18.19/dns.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * system do, use {@link lookup}.
10
10
  *
11
11
  * ```js
12
- * const dns = require('node:dns');
12
+ * import dns from 'node:dns';
13
13
  *
14
14
  * dns.lookup('example.org', (err, address, family) => {
15
15
  * console.log('address: %j family: IPv%s', address, family);
@@ -23,7 +23,7 @@
23
23
  * DNS queries, bypassing other name-resolution facilities.
24
24
  *
25
25
  * ```js
26
- * const dns = require('node:dns');
26
+ * import dns from 'node:dns';
27
27
  *
28
28
  * dns.resolve4('archive.org', (err, addresses) => {
29
29
  * if (err) throw err;
@@ -129,7 +129,7 @@ declare module "dns" {
129
129
  * Example usage:
130
130
  *
131
131
  * ```js
132
- * const dns = require('node:dns');
132
+ * import dns from 'node:dns';
133
133
  * const options = {
134
134
  * family: 6,
135
135
  * hints: dns.ADDRCONFIG | dns.V4MAPPED,
@@ -189,7 +189,7 @@ declare module "dns" {
189
189
  * where `err.code` is the error code.
190
190
  *
191
191
  * ```js
192
- * const dns = require('node:dns');
192
+ * import dns from 'node:dns';
193
193
  * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
194
194
  * console.log(hostname, service);
195
195
  * // Prints: localhost ssh
@@ -775,7 +775,7 @@ declare module "dns" {
775
775
  * other resolvers:
776
776
  *
777
777
  * ```js
778
- * const { Resolver } = require('node:dns');
778
+ * import { Resolver } from 'node:dns';
779
779
  * const resolver = new Resolver();
780
780
  * resolver.setServers(['4.4.4.4']);
781
781
  *
node v18.19/domain.d.ts CHANGED
@@ -63,8 +63,8 @@ declare module "domain" {
63
63
  * This is the most basic way to use a domain.
64
64
  *
65
65
  * ```js
66
- * const domain = require('domain');
67
- * const fs = require('fs');
66
+ * import domain from 'node:domain';
67
+ * import fs from 'node:fs';
68
68
  * const d = domain.create();
69
69
  * d.on('error', (er) => {
70
70
  * console.error('Caught error!', er);
node v18.19/events.d.ts CHANGED
@@ -22,7 +22,7 @@
22
22
  * the `eventEmitter.emit()` method is used to trigger the event.
23
23
  *
24
24
  * ```js
25
- * const EventEmitter = require('events');
25
+ * import EventEmitter from 'node:events';
26
26
  *
27
27
  * class MyEmitter extends EventEmitter {}
28
28
  *
@@ -116,7 +116,7 @@ declare module "events" {
116
116
  * The `EventEmitter` class is defined and exposed by the `events` module:
117
117
  *
118
118
  * ```js
119
- * const EventEmitter = require('events');
119
+ * import EventEmitter from 'node:events';
120
120
  * ```
121
121
  *
122
122
  * All `EventEmitter`s emit the event `'newListener'` when new listeners are
@@ -140,7 +140,7 @@ declare module "events" {
140
140
  * semantics and does not listen to the `'error'` event.
141
141
  *
142
142
  * ```js
143
- * const { once, EventEmitter } = require('events');
143
+ * import { once, EventEmitter } from 'node:events';
144
144
  *
145
145
  * async function run() {
146
146
  * const ee = new EventEmitter();
@@ -172,7 +172,7 @@ declare module "events" {
172
172
  * special handling:
173
173
  *
174
174
  * ```js
175
- * const { EventEmitter, once } = require('events');
175
+ * import { EventEmitter, once } from 'node:events';
176
176
  *
177
177
  * const ee = new EventEmitter();
178
178
  *
@@ -188,7 +188,7 @@ declare module "events" {
188
188
  * An `AbortSignal` can be used to cancel waiting for the event:
189
189
  *
190
190
  * ```js
191
- * const { EventEmitter, once } = require('events');
191
+ * import { EventEmitter, once } from 'node:events';
192
192
  *
193
193
  * const ee = new EventEmitter();
194
194
  * const ac = new AbortController();
@@ -220,7 +220,7 @@ declare module "events" {
220
220
  static once(emitter: _DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
221
221
  /**
222
222
  * ```js
223
- * const { on, EventEmitter } = require('events');
223
+ * import { on, EventEmitter } from 'node:events';
224
224
  *
225
225
  * (async () => {
226
226
  * const ee = new EventEmitter();
@@ -249,7 +249,7 @@ declare module "events" {
249
249
  * An `AbortSignal` can be used to cancel waiting on events:
250
250
  *
251
251
  * ```js
252
- * const { on, EventEmitter } = require('events');
252
+ * import { on, EventEmitter } from 'node:events';
253
253
  * const ac = new AbortController();
254
254
  *
255
255
  * (async () => {
@@ -285,7 +285,7 @@ declare module "events" {
285
285
  * A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
286
286
  *
287
287
  * ```js
288
- * const { EventEmitter, listenerCount } = require('events');
288
+ * import { EventEmitter, listenerCount } from 'node:events';
289
289
  * const myEmitter = new EventEmitter();
290
290
  * myEmitter.on('event', () => {});
291
291
  * myEmitter.on('event', () => {});
@@ -308,7 +308,7 @@ declare module "events" {
308
308
  * event target. This is useful for debugging and diagnostic purposes.
309
309
  *
310
310
  * ```js
311
- * const { getEventListeners, EventEmitter } = require('events');
311
+ * import { getEventListeners, EventEmitter } from 'node:events';
312
312
  *
313
313
  * {
314
314
  * const ee = new EventEmitter();
@@ -357,10 +357,10 @@ declare module "events" {
357
357
  static getMaxListeners(emitter: _DOMEventTarget | NodeJS.EventEmitter): number;
358
358
  /**
359
359
  * ```js
360
- * const {
360
+ * import {
361
361
  * setMaxListeners,
362
362
  * EventEmitter
363
- * } = require('events');
363
+ * } from 'node:events';
364
364
  *
365
365
  * const target = new EventTarget();
366
366
  * const emitter = new EventEmitter();
@@ -711,7 +711,7 @@ declare module "events" {
711
711
  * Returns `true` if the event had listeners, `false` otherwise.
712
712
  *
713
713
  * ```js
714
- * const EventEmitter = require('events');
714
+ * import EventEmitter from 'node:events';
715
715
  * const myEmitter = new EventEmitter();
716
716
  *
717
717
  * // First listener
@@ -794,7 +794,7 @@ declare module "events" {
794
794
  * listeners. The values in the array are strings or `Symbol`s.
795
795
  *
796
796
  * ```js
797
- * const EventEmitter = require('events');
797
+ * import EventEmitter from 'node:events';
798
798
  * const myEE = new EventEmitter();
799
799
  * myEE.on('foo', () => {});
800
800
  * myEE.on('bar', () => {});
@@ -909,7 +909,7 @@ declare module "fs/promises" {
909
909
  * The `fsPromises.mkdtemp()` method will append the six randomly selected
910
910
  * characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing
911
911
  * platform-specific path separator
912
- * (`require('path').sep`).
912
+ * (`import { sep } from 'node:path'`).
913
913
  * @since v10.0.0
914
914
  * @return Fulfills with a string containing the filesystem path of the newly created temporary directory.
915
915
  */
@@ -1131,7 +1131,7 @@ declare module "fs/promises" {
1131
1131
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1132
1132
  *
1133
1133
  * ```js
1134
- * const { watch } = require('fs/promises');
1134
+ * import { watch } from 'node:fs/promises';
1135
1135
  *
1136
1136
  * const ac = new AbortController();
1137
1137
  * const { signal } = ac;
node v18.19/fs.d.ts CHANGED
@@ -1867,7 +1867,7 @@ declare module "fs" {
1867
1867
  * The `fs.mkdtemp()` method will append the six randomly selected characters
1868
1868
  * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
1869
1869
  * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
1870
- * (`require('path').sep`).
1870
+ * (`import { sep } from 'node:path'`).
1871
1871
  *
1872
1872
  * ```js
1873
1873
  * import { tmpdir } from 'os';
node v18.19/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * To use the HTTP server and client one must `require('http')`.
2
+ * To use the HTTP server and client one must import the `node:http` module.
3
3
  *
4
4
  * The HTTP interfaces in Node.js are designed to support many features
5
5
  * of the protocol which have been traditionally difficult to use.
@@ -910,7 +910,7 @@ declare module "http" {
910
910
  * may run into a 'ECONNRESET' error.
911
911
  *
912
912
  * ```js
913
- * const http = require('http');
913
+ * import http from 'node:http';
914
914
  *
915
915
  * // Server has a 5 seconds keep-alive timeout by default
916
916
  * http
@@ -934,7 +934,7 @@ declare module "http" {
934
934
  * automatic error retry base on it.
935
935
  *
936
936
  * ```js
937
- * const http = require('http');
937
+ * import http from 'node:http';
938
938
  * const agent = new http.Agent({ keepAlive: true });
939
939
  *
940
940
  * function retriableRequest() {
@@ -1529,7 +1529,7 @@ declare module "http" {
1529
1529
  * upload a file with a POST request, then write to the `ClientRequest` object.
1530
1530
  *
1531
1531
  * ```js
1532
- * const http = require('http');
1532
+ * import http from 'node:http';
1533
1533
  *
1534
1534
  * const postData = JSON.stringify({
1535
1535
  * 'msg': 'Hello World!'