@types/node 22.7.0 → 22.7.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 (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, 25 Sep 2024 00:56:18 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/async_hooks.d.ts CHANGED
@@ -77,7 +77,7 @@ declare module "async_hooks" {
77
77
  * executionAsyncId,
78
78
  * executionAsyncResource,
79
79
  * createHook,
80
- * } from 'async_hooks';
80
+ * } from 'node:async_hooks';
81
81
  * const sym = Symbol('state'); // Private symbol to avoid pollution
82
82
  *
83
83
  * createHook({
node/buffer.d.ts CHANGED
@@ -134,7 +134,7 @@ declare module "buffer" {
134
134
  export interface BlobOptions {
135
135
  /**
136
136
  * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
137
- * will be converted to the platform native line-ending as specified by `require('node:os').EOL`.
137
+ * will be converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.
138
138
  */
139
139
  endings?: "transparent" | "native";
140
140
  /**
@@ -210,7 +210,7 @@ declare module "buffer" {
210
210
  export interface FileOptions {
211
211
  /**
212
212
  * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
213
- * converted to the platform native line-ending as specified by `require('node:os').EOL`.
213
+ * converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.
214
214
  */
215
215
  endings?: "native" | "transparent";
216
216
  /** The File content-type. */
@@ -261,6 +261,13 @@ declare module "buffer" {
261
261
  | {
262
262
  valueOf(): T;
263
263
  };
264
+ // `WithArrayBufferLike` is a backwards-compatible workaround for the addition of a `TArrayBuffer` type parameter to
265
+ // `Uint8Array` to ensure that `Buffer` remains assignment-compatible with `Uint8Array`, but without the added
266
+ // complexity involved with making `Buffer` itself generic as that would require re-introducing `"typesVersions"` to
267
+ // the NodeJS types. It is likely this interface will become deprecated in the future once `Buffer` does become generic.
268
+ interface WithArrayBufferLike<TArrayBuffer extends ArrayBufferLike> {
269
+ readonly buffer: TArrayBuffer;
270
+ }
264
271
  /**
265
272
  * Raw data is stored in instances of the Buffer class.
266
273
  * 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.
@@ -912,7 +919,7 @@ declare module "buffer" {
912
919
  * @param [start=0] Where the new `Buffer` will start.
913
920
  * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
914
921
  */
915
- slice(start?: number, end?: number): Buffer;
922
+ slice(start?: number, end?: number): Buffer & WithArrayBufferLike<ArrayBuffer>;
916
923
  /**
917
924
  * Returns a new `Buffer` that references the same memory as the original, but
918
925
  * offset and cropped by the `start` and `end` indices.
@@ -972,7 +979,7 @@ declare module "buffer" {
972
979
  * @param [start=0] Where the new `Buffer` will start.
973
980
  * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
974
981
  */
975
- subarray(start?: number, end?: number): Buffer;
982
+ subarray(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
976
983
  /**
977
984
  * Writes `value` to `buf` at the specified `offset` as big-endian.
978
985
  *
@@ -1630,7 +1637,7 @@ declare module "buffer" {
1630
1637
  * @since v5.10.0
1631
1638
  * @return A reference to `buf`.
1632
1639
  */
1633
- swap16(): Buffer;
1640
+ swap16(): this;
1634
1641
  /**
1635
1642
  * Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1636
1643
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
@@ -1656,7 +1663,7 @@ declare module "buffer" {
1656
1663
  * @since v5.10.0
1657
1664
  * @return A reference to `buf`.
1658
1665
  */
1659
- swap32(): Buffer;
1666
+ swap32(): this;
1660
1667
  /**
1661
1668
  * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
1662
1669
  * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
@@ -1682,7 +1689,7 @@ declare module "buffer" {
1682
1689
  * @since v6.3.0
1683
1690
  * @return A reference to `buf`.
1684
1691
  */
1685
- swap64(): Buffer;
1692
+ swap64(): this;
1686
1693
  /**
1687
1694
  * Writes `value` to `buf` at the specified `offset`. `value` must be a
1688
1695
  * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
@@ -2279,7 +2286,7 @@ declare module "buffer" {
2279
2286
  function btoa(data: string): string;
2280
2287
  interface Blob extends _Blob {}
2281
2288
  /**
2282
- * `Blob` class is a global reference for `require('node:buffer').Blob`
2289
+ * `Blob` class is a global reference for `import { Blob } from 'node:buffer'`
2283
2290
  * https://nodejs.org/api/buffer.html#class-blob
2284
2291
  * @since v18.0.0
2285
2292
  */
@@ -2287,7 +2294,7 @@ declare module "buffer" {
2287
2294
  : typeof import("buffer").Blob;
2288
2295
  interface File extends _File {}
2289
2296
  /**
2290
- * `File` class is a global reference for `require('node:buffer').File`
2297
+ * `File` class is a global reference for `import { File } from 'node:buffer'`
2291
2298
  * https://nodejs.org/api/buffer.html#class-file
2292
2299
  * @since v20.0.0
2293
2300
  */
node/child_process.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * is primarily provided by the {@link spawn} function:
5
5
  *
6
6
  * ```js
7
- * const { spawn } = require('node: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('node:child_process');
112
+ * import { spawn } from 'node:child_process';
113
113
  *
114
114
  * const subprocess = spawn('ls');
115
115
  *
@@ -152,9 +152,9 @@ declare module "child_process" {
152
152
  * in the array are `null`.
153
153
  *
154
154
  * ```js
155
- * const assert = require('node:assert');
156
- * const fs = require('node:fs');
157
- * const child_process = require('node:child_process');
155
+ * import assert from 'node:assert';
156
+ * import fs from 'node:fs';
157
+ * import child_process from 'node:child_process';
158
158
  *
159
159
  * const subprocess = child_process.spawn('ls', {
160
160
  * stdio: [
@@ -202,7 +202,7 @@ declare module "child_process" {
202
202
  * emitted.
203
203
  *
204
204
  * ```js
205
- * const { spawn } = require('node:child_process');
205
+ * import { spawn } from 'node:child_process';
206
206
  * const grep = spawn('grep', ['ssh']);
207
207
  *
208
208
  * console.log(`Spawned child pid: ${grep.pid}`);
@@ -249,7 +249,7 @@ declare module "child_process" {
249
249
  * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
250
250
  *
251
251
  * ```js
252
- * const { spawn } = require('node:child_process');
252
+ * import { spawn } from 'node:child_process';
253
253
  * const grep = spawn('grep', ['ssh']);
254
254
  *
255
255
  * grep.on('close', (code, signal) => {
@@ -282,7 +282,7 @@ declare module "child_process" {
282
282
  *
283
283
  * ```js
284
284
  * 'use strict';
285
- * const { spawn } = require('node:child_process');
285
+ * import { spawn } from 'node:child_process';
286
286
  *
287
287
  * const subprocess = spawn(
288
288
  * 'sh',
@@ -320,7 +320,7 @@ declare module "child_process" {
320
320
  * For example, in the parent script:
321
321
  *
322
322
  * ```js
323
- * const cp = require('node:child_process');
323
+ * import cp from 'node:child_process';
324
324
  * const n = cp.fork(`${__dirname}/sub.js`);
325
325
  *
326
326
  * n.on('message', (m) => {
@@ -374,10 +374,12 @@ declare module "child_process" {
374
374
  * a TCP server object to the child process as illustrated in the example below:
375
375
  *
376
376
  * ```js
377
- * const subprocess = require('node:child_process').fork('subprocess.js');
377
+ * import { createServer } from 'node:net';
378
+ * import { fork } from 'node:child_process';
379
+ * const subprocess = fork('subprocess.js');
378
380
  *
379
381
  * // Open up the server object and send the handle.
380
- * const server = require('node:net').createServer();
382
+ * const server = createServer();
381
383
  * server.on('connection', (socket) => {
382
384
  * socket.end('handled by parent');
383
385
  * });
@@ -412,13 +414,14 @@ declare module "child_process" {
412
414
  * handle connections with "normal" or "special" priority:
413
415
  *
414
416
  * ```js
415
- * const { fork } = require('node:child_process');
417
+ * import { createServer } from 'node:net';
418
+ * import { fork } from 'node:child_process';
416
419
  * const normal = fork('subprocess.js', ['normal']);
417
420
  * const special = fork('subprocess.js', ['special']);
418
421
  *
419
422
  * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
420
423
  * // the sockets from being read before they are sent to the child process.
421
- * const server = require('node:net').createServer({ pauseOnConnect: true });
424
+ * const server = createServer({ pauseOnConnect: true });
422
425
  * server.on('connection', (socket) => {
423
426
  *
424
427
  * // If this is special priority...
@@ -490,7 +493,7 @@ declare module "child_process" {
490
493
  * the child and the parent.
491
494
  *
492
495
  * ```js
493
- * const { spawn } = require('node:child_process');
496
+ * import { spawn } from 'node:child_process';
494
497
  *
495
498
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
496
499
  * detached: true,
@@ -508,7 +511,7 @@ declare module "child_process" {
508
511
  * to wait for the child to exit before exiting itself.
509
512
  *
510
513
  * ```js
511
- * const { spawn } = require('node:child_process');
514
+ * import { spawn } from 'node:child_process';
512
515
  *
513
516
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
514
517
  * detached: true,
@@ -711,7 +714,7 @@ declare module "child_process" {
711
714
  * exit code:
712
715
  *
713
716
  * ```js
714
- * const { spawn } = require('node:child_process');
717
+ * import { spawn } from 'node:child_process';
715
718
  * const ls = spawn('ls', ['-lh', '/usr']);
716
719
  *
717
720
  * ls.stdout.on('data', (data) => {
@@ -730,7 +733,7 @@ declare module "child_process" {
730
733
  * Example: A very elaborate way to run `ps ax | grep ssh`
731
734
  *
732
735
  * ```js
733
- * const { spawn } = require('node:child_process');
736
+ * import { spawn } from 'node:child_process';
734
737
  * const ps = spawn('ps', ['ax']);
735
738
  * const grep = spawn('grep', ['ssh']);
736
739
  *
@@ -767,7 +770,7 @@ declare module "child_process" {
767
770
  * Example of checking for failed `spawn`:
768
771
  *
769
772
  * ```js
770
- * const { spawn } = require('node:child_process');
773
+ * import { spawn } from 'node:child_process';
771
774
  * const subprocess = spawn('bad_command');
772
775
  *
773
776
  * subprocess.on('error', (err) => {
@@ -785,7 +788,7 @@ declare module "child_process" {
785
788
  * the error passed to the callback will be an `AbortError`:
786
789
  *
787
790
  * ```js
788
- * const { spawn } = require('node:child_process');
791
+ * import { spawn } from 'node:child_process';
789
792
  * const controller = new AbortController();
790
793
  * const { signal } = controller;
791
794
  * 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('node: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('node: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('node:util');
961
- * const exec = util.promisify(require('node: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('node: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('node: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('node:util');
1123
- * const execFile = util.promisify(require('node: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('node: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) => {
@@ -1377,7 +1382,7 @@ declare module "child_process" {
1377
1382
  * console.log(`Hello from ${process.argv[2]}!`);
1378
1383
  * }, 1_000);
1379
1384
  * } else {
1380
- * const { fork } = require('node:child_process');
1385
+ * import { fork } from 'node:child_process';
1381
1386
  * const controller = new AbortController();
1382
1387
  * const { signal } = controller;
1383
1388
  * const child = fork(__filename, ['child'], { signal });
node/cluster.d.ts CHANGED
@@ -231,6 +231,8 @@ 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';
235
+ *
234
236
  * if (cluster.isPrimary) {
235
237
  * const worker = cluster.fork();
236
238
  * let timeout;
@@ -248,7 +250,6 @@ declare module "cluster" {
248
250
  * });
249
251
  *
250
252
  * } else if (cluster.isWorker) {
251
- * const net = require('node:net');
252
253
  * const server = net.createServer((socket) => {
253
254
  * // Connections never end
254
255
  * });
node/console.d.ts CHANGED
@@ -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-v22.x/api/process.html#processstdout) and
9
- * [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without calling `require('node:console')`.
9
+ * [`process.stderr`](https://nodejs.org/docs/latest-v22.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-v22.x/api/process.html#processstdout) and
365
- * [`process.stderr`](https://nodejs.org/docs/latest-v22.x/api/process.html#processstderr). The global `console` can be used without calling `require('console')`.
365
+ * [`process.stderr`](https://nodejs.org/docs/latest-v22.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/crypto.d.ts CHANGED
@@ -3316,8 +3316,8 @@ declare module "crypto" {
3316
3316
  * Example:
3317
3317
  *
3318
3318
  * ```js
3319
- * const crypto = require('node:crypto');
3320
- * const { Buffer } = require('node:buffer');
3319
+ * import crypto from 'node:crypto';
3320
+ * import { Buffer } from 'node:buffer';
3321
3321
  *
3322
3322
  * // Hashing a string and return the result as a hex-encoded string.
3323
3323
  * const string = 'Node.js';
@@ -4034,7 +4034,7 @@ declare module "crypto" {
4034
4034
  saltLength: number;
4035
4035
  }
4036
4036
  /**
4037
- * Calling `require('node:crypto').webcrypto` returns an instance of the `Crypto` class.
4037
+ * Importing the `webcrypto` object (`import { webcrypto } from 'node:crypto'`) gives an instance of the `Crypto` class.
4038
4038
  * `Crypto` is a singleton that provides access to the remainder of the crypto API.
4039
4039
  * @since v15.0.0
4040
4040
  */
node/dns/promises.d.ts CHANGED
@@ -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 as dnsPromises } 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,7 +96,7 @@ declare module "dns/promises" {
96
96
  * On error, the `Promise` is rejected with an [`Error`](https://nodejs.org/docs/latest-v20.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;
99
+ * import dnsPromises from 'node:dns';
100
100
  * dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
101
101
  * console.log(result.hostname, result.service);
102
102
  * // Prints: localhost ssh
@@ -394,8 +394,8 @@ declare module "dns/promises" {
394
394
  * other resolvers:
395
395
  *
396
396
  * ```js
397
- * const { Resolver } = require('node:dns').promises;
398
- * const resolver = new Resolver();
397
+ * import { promises } from 'node:dns';
398
+ * const resolver = new promises.Resolver();
399
399
  * resolver.setServers(['4.4.4.4']);
400
400
  *
401
401
  * // This request will use the server at 4.4.4.4, independent of global settings.
node/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;
@@ -139,7 +139,7 @@ declare module "dns" {
139
139
  * Example usage:
140
140
  *
141
141
  * ```js
142
- * const dns = require('node:dns');
142
+ * import dns from 'node:dns';
143
143
  * const options = {
144
144
  * family: 6,
145
145
  * hints: dns.ADDRCONFIG | dns.V4MAPPED,
@@ -199,7 +199,7 @@ declare module "dns" {
199
199
  * where `err.code` is the error code.
200
200
  *
201
201
  * ```js
202
- * const dns = require('node:dns');
202
+ * import dns from 'node:dns';
203
203
  * dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
204
204
  * console.log(hostname, service);
205
205
  * // Prints: localhost ssh
@@ -787,7 +787,7 @@ declare module "dns" {
787
787
  * other resolvers:
788
788
  *
789
789
  * ```js
790
- * const { Resolver } = require('node:dns');
790
+ * import { Resolver } from 'node:dns';
791
791
  * const resolver = new Resolver();
792
792
  * resolver.setServers(['4.4.4.4']);
793
793
  *
node/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('node:domain');
67
- * const fs = require('node: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/fs/promises.d.ts CHANGED
@@ -932,7 +932,7 @@ declare module "fs/promises" {
932
932
  * The `fsPromises.mkdtemp()` method will append the six randomly selected
933
933
  * 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
934
934
  * platform-specific path separator
935
- * (`require('node:path').sep`).
935
+ * (`import { sep } from 'node:path'`).
936
936
  * @since v10.0.0
937
937
  * @return Fulfills with a string containing the file system path of the newly created temporary directory.
938
938
  */
@@ -1174,7 +1174,7 @@ declare module "fs/promises" {
1174
1174
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1175
1175
  *
1176
1176
  * ```js
1177
- * const { watch } = require('node:fs/promises');
1177
+ * import { watch } from 'node:fs/promises';
1178
1178
  *
1179
1179
  * const ac = new AbortController();
1180
1180
  * const { signal } = ac;
node/fs.d.ts CHANGED
@@ -1900,7 +1900,7 @@ declare module "fs" {
1900
1900
  * The `fs.mkdtemp()` method will append the six randomly selected characters
1901
1901
  * directly to the `prefix` string. For instance, given a directory `/tmp`, if the
1902
1902
  * intention is to create a temporary directory _within_`/tmp`, the `prefix`must end with a trailing platform-specific path separator
1903
- * (`require('node:path').sep`).
1903
+ * (`import { sep } from 'node:path'`).
1904
1904
  *
1905
1905
  * ```js
1906
1906
  * import { tmpdir } from 'node:os';
@@ -3156,7 +3156,7 @@ declare module "fs" {
3156
3156
  * stat object:
3157
3157
  *
3158
3158
  * ```js
3159
- * import { watchFile } from 'fs';
3159
+ * import { watchFile } from 'node:fs';
3160
3160
  *
3161
3161
  * watchFile('message.text', (curr, prev) => {
3162
3162
  * console.log(`the current mtime is: ${curr.mtime}`);
node/http.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * To use the HTTP server and client one must `require('node: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.
@@ -1447,7 +1447,7 @@ declare module "http" {
1447
1447
  * To configure any of them, a custom {@link Agent} instance must be created.
1448
1448
  *
1449
1449
  * ```js
1450
- * const http = require('node:http');
1450
+ * import http from 'node:http';
1451
1451
  * const keepAliveAgent = new http.Agent({ keepAlive: true });
1452
1452
  * options.agent = keepAliveAgent;
1453
1453
  * http.request(options, onResponseCallback)