@types/node 16.18.110 → 16.18.112

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.
Files changed (46) hide show
  1. node v16.18/README.md +1 -1
  2. node v16.18/buffer.buffer.d.ts +365 -0
  3. node v16.18/buffer.d.ts +8 -362
  4. node v16.18/child_process.d.ts +34 -29
  5. node v16.18/cluster.d.ts +1 -1
  6. node v16.18/console.d.ts +2 -2
  7. node v16.18/crypto.d.ts +1 -1
  8. node v16.18/dns/promises.d.ts +6 -5
  9. node v16.18/dns.d.ts +5 -5
  10. node v16.18/domain.d.ts +2 -2
  11. node v16.18/events.d.ts +13 -13
  12. node v16.18/fs/promises.d.ts +2 -2
  13. node v16.18/fs.d.ts +1 -1
  14. node v16.18/globals.d.ts +0 -14
  15. node v16.18/globals.typedarray.d.ts +21 -0
  16. node v16.18/http.d.ts +2 -2
  17. node v16.18/http2.d.ts +24 -24
  18. node v16.18/https.d.ts +9 -9
  19. node v16.18/index.d.ts +5 -1
  20. node v16.18/inspector.d.ts +1 -1
  21. node v16.18/module.d.ts +3 -3
  22. node v16.18/net.d.ts +2 -2
  23. node v16.18/os.d.ts +1 -1
  24. node v16.18/package.json +9 -2
  25. node v16.18/path.d.ts +1 -1
  26. node v16.18/perf_hooks.d.ts +11 -11
  27. node v16.18/punycode.d.ts +1 -1
  28. node v16.18/querystring.d.ts +1 -1
  29. node v16.18/readline.d.ts +12 -12
  30. node v16.18/repl.d.ts +4 -4
  31. node v16.18/stream.d.ts +18 -18
  32. node v16.18/string_decoder.d.ts +3 -3
  33. node v16.18/timers/promises.d.ts +1 -1
  34. node v16.18/timers.d.ts +1 -1
  35. node v16.18/tls.d.ts +5 -5
  36. node v16.18/trace_events.d.ts +3 -3
  37. node v16.18/ts5.6/buffer.buffer.d.ts +365 -0
  38. node v16.18/ts5.6/globals.typedarray.d.ts +19 -0
  39. node v16.18/ts5.6/index.d.ts +90 -0
  40. node v16.18/tty.d.ts +1 -1
  41. node v16.18/url.d.ts +6 -6
  42. node v16.18/util.d.ts +40 -40
  43. node v16.18/v8.d.ts +11 -11
  44. node v16.18/vm.d.ts +11 -12
  45. node v16.18/worker_threads.d.ts +19 -19
  46. node v16.18/zlib.d.ts +8 -8
node v16.18/buffer.d.ts CHANGED
@@ -102,7 +102,7 @@ declare module "buffer" {
102
102
  export interface BlobOptions {
103
103
  /**
104
104
  * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
105
- * will be converted to the platform native line-ending as specified by `require('node:os').EOL`.
105
+ * will be converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.
106
106
  */
107
107
  endings?: "transparent" | "native";
108
108
  /**
@@ -188,109 +188,15 @@ declare module "buffer" {
188
188
  | {
189
189
  valueOf(): T;
190
190
  };
191
- // `WithArrayBufferLike` is a backwards-compatible workaround for the addition of a `TArrayBuffer` type parameter to
192
- // `Uint8Array` to ensure that `Buffer` remains assignment-compatible with `Uint8Array`, but without the added
193
- // complexity involved with making `Buffer` itself generic as that would require re-introducing `"typesVersions"` to
194
- // the NodeJS types. It is likely this interface will become deprecated in the future once `Buffer` does become generic.
195
- interface WithArrayBufferLike<TArrayBuffer extends ArrayBufferLike> {
196
- readonly buffer: TArrayBuffer;
197
- }
198
191
  /**
199
192
  * Raw data is stored in instances of the Buffer class.
200
193
  * 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.
201
194
  * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
202
195
  */
203
196
  interface BufferConstructor {
204
- /**
205
- * Allocates a new buffer containing the given {str}.
206
- *
207
- * @param str String to store in buffer.
208
- * @param encoding encoding to use, optional. Default is 'utf8'
209
- * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
210
- */
211
- new(str: string, encoding?: BufferEncoding): Buffer;
212
- /**
213
- * Allocates a new buffer of {size} octets.
214
- *
215
- * @param size count of octets to allocate.
216
- * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
217
- */
218
- new(size: number): Buffer;
219
- /**
220
- * Allocates a new buffer containing the given {array} of octets.
221
- *
222
- * @param array The octets to store.
223
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
224
- */
225
- new(array: Uint8Array): Buffer;
226
- /**
227
- * Produces a Buffer backed by the same allocated memory as
228
- * the given {ArrayBuffer}/{SharedArrayBuffer}.
229
- *
230
- * @param arrayBuffer The ArrayBuffer with which to share memory.
231
- * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
232
- */
233
- new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
234
- /**
235
- * Allocates a new buffer containing the given {array} of octets.
236
- *
237
- * @param array The octets to store.
238
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
239
- */
240
- new(array: readonly any[]): Buffer;
241
- /**
242
- * Copies the passed {buffer} data onto a new {Buffer} instance.
243
- *
244
- * @param buffer The buffer to copy.
245
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
246
- */
247
- new(buffer: Buffer): Buffer;
248
- /**
249
- * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
250
- * Array entries outside that range will be truncated to fit into it.
251
- *
252
- * ```js
253
- * import { Buffer } from 'node:buffer';
254
- *
255
- * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
256
- * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
257
- * ```
258
- *
259
- * A `TypeError` will be thrown if `array` is not an `Array` or another type
260
- * appropriate for `Buffer.from()` variants.
261
- *
262
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
263
- * @since v5.10.0
264
- */
265
- from(
266
- arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
267
- byteOffset?: number,
268
- length?: number,
269
- ): Buffer;
270
- /**
271
- * Creates a new Buffer using the passed {data}
272
- * @param data data to create a new Buffer
273
- */
274
- from(data: Uint8Array | readonly number[]): Buffer;
275
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
276
- /**
277
- * Creates a new Buffer containing the given JavaScript string {str}.
278
- * If provided, the {encoding} parameter identifies the character encoding.
279
- * If not provided, {encoding} defaults to 'utf8'.
280
- */
281
- from(
282
- str:
283
- | WithImplicitCoercion<string>
284
- | {
285
- [Symbol.toPrimitive](hint: "string"): string;
286
- },
287
- encoding?: BufferEncoding,
288
- ): Buffer;
289
- /**
290
- * Creates a new Buffer using the passed {data}
291
- * @param values to create a new Buffer
292
- */
293
- of(...items: number[]): Buffer;
197
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
198
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
199
+
294
200
  /**
295
201
  * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
296
202
  *
@@ -362,45 +268,6 @@ declare module "buffer" {
362
268
  string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
363
269
  encoding?: BufferEncoding,
364
270
  ): number;
365
- /**
366
- * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
367
- *
368
- * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
369
- *
370
- * If `totalLength` is not provided, it is calculated from the `Buffer` instances
371
- * in `list` by adding their lengths.
372
- *
373
- * If `totalLength` is provided, it is coerced to an unsigned integer. If the
374
- * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
375
- * truncated to `totalLength`.
376
- *
377
- * ```js
378
- * import { Buffer } from 'node:buffer';
379
- *
380
- * // Create a single `Buffer` from a list of three `Buffer` instances.
381
- *
382
- * const buf1 = Buffer.alloc(10);
383
- * const buf2 = Buffer.alloc(14);
384
- * const buf3 = Buffer.alloc(18);
385
- * const totalLength = buf1.length + buf2.length + buf3.length;
386
- *
387
- * console.log(totalLength);
388
- * // Prints: 42
389
- *
390
- * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
391
- *
392
- * console.log(bufA);
393
- * // Prints: <Buffer 00 00 00 00 ...>
394
- * console.log(bufA.length);
395
- * // Prints: 42
396
- * ```
397
- *
398
- * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
399
- * @since v0.7.11
400
- * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
401
- * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
402
- */
403
- concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
404
271
  /**
405
272
  * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
406
273
  *
@@ -419,136 +286,6 @@ declare module "buffer" {
419
286
  * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
420
287
  */
421
288
  compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
422
- /**
423
- * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
424
- *
425
- * ```js
426
- * import { Buffer } from 'node:buffer';
427
- *
428
- * const buf = Buffer.alloc(5);
429
- *
430
- * console.log(buf);
431
- * // Prints: <Buffer 00 00 00 00 00>
432
- * ```
433
- *
434
- * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
435
- *
436
- * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
437
- *
438
- * ```js
439
- * import { Buffer } from 'node:buffer';
440
- *
441
- * const buf = Buffer.alloc(5, 'a');
442
- *
443
- * console.log(buf);
444
- * // Prints: <Buffer 61 61 61 61 61>
445
- * ```
446
- *
447
- * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
448
- * initialized by calling `buf.fill(fill, encoding)`.
449
- *
450
- * ```js
451
- * import { Buffer } from 'node:buffer';
452
- *
453
- * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
454
- *
455
- * console.log(buf);
456
- * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
457
- * ```
458
- *
459
- * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
460
- * contents will never contain sensitive data from previous allocations, including
461
- * data that might not have been allocated for `Buffer`s.
462
- *
463
- * A `TypeError` will be thrown if `size` is not a number.
464
- * @since v5.10.0
465
- * @param size The desired length of the new `Buffer`.
466
- * @param [fill=0] A value to pre-fill the new `Buffer` with.
467
- * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
468
- */
469
- alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
470
- /**
471
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
472
- *
473
- * The underlying memory for `Buffer` instances created in this way is _not_
474
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
475
- *
476
- * ```js
477
- * import { Buffer } from 'node:buffer';
478
- *
479
- * const buf = Buffer.allocUnsafe(10);
480
- *
481
- * console.log(buf);
482
- * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
483
- *
484
- * buf.fill(0);
485
- *
486
- * console.log(buf);
487
- * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
488
- * ```
489
- *
490
- * A `TypeError` will be thrown if `size` is not a number.
491
- *
492
- * The `Buffer` module pre-allocates an internal `Buffer` instance of
493
- * size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`, `Buffer.concat()`, and the
494
- * deprecated `new Buffer(size)` constructor only when `size` is less than or equal
495
- * to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
496
- *
497
- * Use of this pre-allocated internal memory pool is a key difference between
498
- * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
499
- * Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
500
- * than or equal to half `Buffer.poolSize`. The
501
- * difference is subtle but can be important when an application requires the
502
- * additional performance that `Buffer.allocUnsafe()` provides.
503
- * @since v5.10.0
504
- * @param size The desired length of the new `Buffer`.
505
- */
506
- allocUnsafe(size: number): Buffer;
507
- /**
508
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. A zero-length `Buffer` is created if
509
- * `size` is 0.
510
- *
511
- * The underlying memory for `Buffer` instances created in this way is _not_
512
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
513
- * such `Buffer` instances with zeroes.
514
- *
515
- * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
516
- * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
517
- * allows applications to avoid the garbage collection overhead of creating many
518
- * individually allocated `Buffer` instances. This approach improves both
519
- * performance and memory usage by eliminating the need to track and clean up as
520
- * many individual `ArrayBuffer` objects.
521
- *
522
- * However, in the case where a developer may need to retain a small chunk of
523
- * memory from a pool for an indeterminate amount of time, it may be appropriate
524
- * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
525
- * then copying out the relevant bits.
526
- *
527
- * ```js
528
- * import { Buffer } from 'node:buffer';
529
- *
530
- * // Need to keep around a few small chunks of memory.
531
- * const store = [];
532
- *
533
- * socket.on('readable', () => {
534
- * let data;
535
- * while (null !== (data = readable.read())) {
536
- * // Allocate for retained data.
537
- * const sb = Buffer.allocUnsafeSlow(10);
538
- *
539
- * // Copy the data into the new allocation.
540
- * data.copy(sb, 0, 0, 10);
541
- *
542
- * store.push(sb);
543
- * }
544
- * });
545
- * ```
546
- *
547
- * A `TypeError` will be thrown if `size` is not a number.
548
- * @since v5.12.0
549
- * @param size The desired length of the new `Buffer`.
550
- */
551
- allocUnsafeSlow(size: number): Buffer;
552
289
  /**
553
290
  * This is the size (in bytes) of pre-allocated internal `Buffer` instances used
554
291
  * for pooling. This value may be modified.
@@ -556,7 +293,10 @@ declare module "buffer" {
556
293
  */
557
294
  poolSize: number;
558
295
  }
559
- interface Buffer extends Uint8Array {
296
+ interface Buffer {
297
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
298
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
299
+
560
300
  /**
561
301
  * Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
562
302
  * not contain enough space to fit the entire string, only part of `string` will be
@@ -793,100 +533,6 @@ declare module "buffer" {
793
533
  * @return The number of bytes copied.
794
534
  */
795
535
  copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
796
- /**
797
- * Returns a new `Buffer` that references the same memory as the original, but
798
- * offset and cropped by the `start` and `end` indices.
799
- *
800
- * This method is not compatible with the `Uint8Array.prototype.slice()`,
801
- * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
802
- *
803
- * ```js
804
- * import { Buffer } from 'node:buffer';
805
- *
806
- * const buf = Buffer.from('buffer');
807
- *
808
- * const copiedBuf = Uint8Array.prototype.slice.call(buf);
809
- * copiedBuf[0]++;
810
- * console.log(copiedBuf.toString());
811
- * // Prints: cuffer
812
- *
813
- * console.log(buf.toString());
814
- * // Prints: buffer
815
- *
816
- * // With buf.slice(), the original buffer is modified.
817
- * const notReallyCopiedBuf = buf.slice();
818
- * notReallyCopiedBuf[0]++;
819
- * console.log(notReallyCopiedBuf.toString());
820
- * // Prints: cuffer
821
- * console.log(buf.toString());
822
- * // Also prints: cuffer (!)
823
- * ```
824
- * @since v0.3.0
825
- * @deprecated Use `subarray` instead.
826
- * @param [start=0] Where the new `Buffer` will start.
827
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
828
- */
829
- slice(start?: number, end?: number): Buffer & WithArrayBufferLike<ArrayBuffer>;
830
- /**
831
- * Returns a new `Buffer` that references the same memory as the original, but
832
- * offset and cropped by the `start` and `end` indices.
833
- *
834
- * Specifying `end` greater than `buf.length` will return the same result as
835
- * that of `end` equal to `buf.length`.
836
- *
837
- * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
838
- *
839
- * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
840
- *
841
- * ```js
842
- * import { Buffer } from 'node:buffer';
843
- *
844
- * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
845
- * // from the original `Buffer`.
846
- *
847
- * const buf1 = Buffer.allocUnsafe(26);
848
- *
849
- * for (let i = 0; i < 26; i++) {
850
- * // 97 is the decimal ASCII value for 'a'.
851
- * buf1[i] = i + 97;
852
- * }
853
- *
854
- * const buf2 = buf1.subarray(0, 3);
855
- *
856
- * console.log(buf2.toString('ascii', 0, buf2.length));
857
- * // Prints: abc
858
- *
859
- * buf1[0] = 33;
860
- *
861
- * console.log(buf2.toString('ascii', 0, buf2.length));
862
- * // Prints: !bc
863
- * ```
864
- *
865
- * Specifying negative indexes causes the slice to be generated relative to the
866
- * end of `buf` rather than the beginning.
867
- *
868
- * ```js
869
- * import { Buffer } from 'node:buffer';
870
- *
871
- * const buf = Buffer.from('buffer');
872
- *
873
- * console.log(buf.subarray(-6, -1).toString());
874
- * // Prints: buffe
875
- * // (Equivalent to buf.subarray(0, 5).)
876
- *
877
- * console.log(buf.subarray(-6, -2).toString());
878
- * // Prints: buff
879
- * // (Equivalent to buf.subarray(0, 4).)
880
- *
881
- * console.log(buf.subarray(-5, -2).toString());
882
- * // Prints: uff
883
- * // (Equivalent to buf.subarray(1, 4).)
884
- * ```
885
- * @since v3.0.0
886
- * @param [start=0] Where the new `Buffer` will start.
887
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
888
- */
889
- subarray(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
890
536
  /**
891
537
  * Writes `value` to `buf` at the specified `offset` as big-endian.
892
538
  *
@@ -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) => {
@@ -106,7 +106,7 @@ declare module "child_process" {
106
106
  * refer to the same value.
107
107
  *
108
108
  * ```js
109
- * const { spawn } = require('child_process');
109
+ * import { spawn } from 'node:child_process';
110
110
  *
111
111
  * const subprocess = spawn('ls');
112
112
  *
@@ -151,9 +151,9 @@ declare module "child_process" {
151
151
  * in the array are `null`.
152
152
  *
153
153
  * ```js
154
- * const assert = require('assert');
155
- * const fs = require('fs');
156
- * const child_process = require('child_process');
154
+ * import assert from 'node:assert';
155
+ * import fs from 'node:fs';
156
+ * import child_process from 'node:child_process';
157
157
  *
158
158
  * const subprocess = child_process.spawn('ls', {
159
159
  * stdio: [
@@ -201,7 +201,7 @@ declare module "child_process" {
201
201
  * emitted.
202
202
  *
203
203
  * ```js
204
- * const { spawn } = require('child_process');
204
+ * import { spawn } from 'node:child_process';
205
205
  * const grep = spawn('grep', ['ssh']);
206
206
  *
207
207
  * console.log(`Spawned child pid: ${grep.pid}`);
@@ -248,7 +248,7 @@ declare module "child_process" {
248
248
  * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
249
249
  *
250
250
  * ```js
251
- * const { spawn } = require('child_process');
251
+ * import { spawn } from 'node:child_process';
252
252
  * const grep = spawn('grep', ['ssh']);
253
253
  *
254
254
  * grep.on('close', (code, signal) => {
@@ -281,7 +281,7 @@ declare module "child_process" {
281
281
  *
282
282
  * ```js
283
283
  * 'use strict';
284
- * const { spawn } = require('child_process');
284
+ * import { spawn } from 'node:child_process';
285
285
  *
286
286
  * const subprocess = spawn(
287
287
  * 'sh',
@@ -314,7 +314,7 @@ declare module "child_process" {
314
314
  * For example, in the parent script:
315
315
  *
316
316
  * ```js
317
- * const cp = require('child_process');
317
+ * import cp from 'node:child_process';
318
318
  * const n = cp.fork(`${__dirname}/sub.js`);
319
319
  *
320
320
  * n.on('message', (m) => {
@@ -368,10 +368,12 @@ declare module "child_process" {
368
368
  * a TCP server object to the child process as illustrated in the example below:
369
369
  *
370
370
  * ```js
371
- * const subprocess = require('child_process').fork('subprocess.js');
371
+ * import child_process from 'node:child_process';
372
+ * const subprocess = child_process.fork('subprocess.js');
372
373
  *
373
374
  * // Open up the server object and send the handle.
374
- * const server = require('net').createServer();
375
+ * import net from 'node:net';
376
+ * const server = net.createServer();
375
377
  * server.on('connection', (socket) => {
376
378
  * socket.end('handled by parent');
377
379
  * });
@@ -407,13 +409,14 @@ declare module "child_process" {
407
409
  * handle connections with "normal" or "special" priority:
408
410
  *
409
411
  * ```js
410
- * const { fork } = require('child_process');
412
+ * import { fork } from 'node:child_process';
411
413
  * const normal = fork('subprocess.js', ['normal']);
412
414
  * const special = fork('subprocess.js', ['special']);
413
415
  *
414
416
  * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
415
417
  * // the sockets from being read before they are sent to the child process.
416
- * const server = require('net').createServer({ pauseOnConnect: true });
418
+ * import net from 'node:net';
419
+ * const server = net.createServer({ pauseOnConnect: true });
417
420
  * server.on('connection', (socket) => {
418
421
  *
419
422
  * // If this is special priority...
@@ -484,7 +487,7 @@ declare module "child_process" {
484
487
  * the child and the parent.
485
488
  *
486
489
  * ```js
487
- * const { spawn } = require('child_process');
490
+ * import { spawn } from 'node:child_process';
488
491
  *
489
492
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
490
493
  * detached: true,
@@ -502,7 +505,7 @@ declare module "child_process" {
502
505
  * to wait for the child to exit before exiting itself.
503
506
  *
504
507
  * ```js
505
- * const { spawn } = require('child_process');
508
+ * import { spawn } from 'node:child_process';
506
509
  *
507
510
  * const subprocess = spawn(process.argv[0], ['child_program.js'], {
508
511
  * detached: true,
@@ -705,7 +708,7 @@ declare module "child_process" {
705
708
  * exit code:
706
709
  *
707
710
  * ```js
708
- * const { spawn } = require('child_process');
711
+ * import { spawn } from 'node:child_process';
709
712
  * const ls = spawn('ls', ['-lh', '/usr']);
710
713
  *
711
714
  * ls.stdout.on('data', (data) => {
@@ -724,7 +727,7 @@ declare module "child_process" {
724
727
  * Example: A very elaborate way to run `ps ax | grep ssh`
725
728
  *
726
729
  * ```js
727
- * const { spawn } = require('child_process');
730
+ * import { spawn } from 'node:child_process';
728
731
  * const ps = spawn('ps', ['ax']);
729
732
  * const grep = spawn('grep', ['ssh']);
730
733
  *
@@ -761,7 +764,7 @@ declare module "child_process" {
761
764
  * Example of checking for failed `spawn`:
762
765
  *
763
766
  * ```js
764
- * const { spawn } = require('child_process');
767
+ * import { spawn } from 'node:child_process';
765
768
  * const subprocess = spawn('bad_command');
766
769
  *
767
770
  * subprocess.on('error', (err) => {
@@ -779,7 +782,7 @@ declare module "child_process" {
779
782
  * the error passed to the callback will be an `AbortError`:
780
783
  *
781
784
  * ```js
782
- * const { spawn } = require('child_process');
785
+ * import { spawn } from 'node:child_process';
783
786
  * const controller = new AbortController();
784
787
  * const { signal } = controller;
785
788
  * const grep = spawn('grep', ['ssh'], { signal });
@@ -898,7 +901,7 @@ declare module "child_process" {
898
901
  * need to be dealt with accordingly:
899
902
  *
900
903
  * ```js
901
- * const { exec } = require('child_process');
904
+ * import { exec } from 'node:child_process';
902
905
  *
903
906
  * exec('"/path/to/test file/test.sh" arg1 arg2');
904
907
  * // Double quotes are used so that the space in the path is not interpreted as
@@ -924,7 +927,7 @@ declare module "child_process" {
924
927
  * encoding, `Buffer` objects will be passed to the callback instead.
925
928
  *
926
929
  * ```js
927
- * const { exec } = require('child_process');
930
+ * import { exec } from 'node:child_process';
928
931
  * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
929
932
  * if (error) {
930
933
  * console.error(`exec error: ${error}`);
@@ -949,8 +952,9 @@ declare module "child_process" {
949
952
  * callback, but with two additional properties `stdout` and `stderr`.
950
953
  *
951
954
  * ```js
952
- * const util = require('util');
953
- * const exec = util.promisify(require('child_process').exec);
955
+ * import util from 'node:util';
956
+ * import child_process from 'node:child_process';
957
+ * const exec = util.promisify(child_process.exec);
954
958
  *
955
959
  * async function lsExample() {
956
960
  * const { stdout, stderr } = await exec('ls');
@@ -964,7 +968,7 @@ declare module "child_process" {
964
968
  * the error passed to the callback will be an `AbortError`:
965
969
  *
966
970
  * ```js
967
- * const { exec } = require('child_process');
971
+ * import { exec } from 'node:child_process';
968
972
  * const controller = new AbortController();
969
973
  * const { signal } = controller;
970
974
  * const child = exec('grep ssh', { signal }, (error) => {
@@ -1088,7 +1092,7 @@ declare module "child_process" {
1088
1092
  * supported.
1089
1093
  *
1090
1094
  * ```js
1091
- * const { execFile } = require('child_process');
1095
+ * import { execFile } from 'node:child_process';
1092
1096
  * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
1093
1097
  * if (error) {
1094
1098
  * throw error;
@@ -1111,8 +1115,9 @@ declare module "child_process" {
1111
1115
  * callback, but with two additional properties `stdout` and `stderr`.
1112
1116
  *
1113
1117
  * ```js
1114
- * const util = require('util');
1115
- * const execFile = util.promisify(require('child_process').execFile);
1118
+ * import util from 'node:util';
1119
+ * import child_process from 'node:child_process';
1120
+ * const execFile = util.promisify(child_process.execFile);
1116
1121
  * async function getVersion() {
1117
1122
  * const { stdout } = await execFile('node', ['--version']);
1118
1123
  * console.log(stdout);
@@ -1128,7 +1133,7 @@ declare module "child_process" {
1128
1133
  * the error passed to the callback will be an `AbortError`:
1129
1134
  *
1130
1135
  * ```js
1131
- * const { execFile } = require('child_process');
1136
+ * import { execFile } from 'node:child_process';
1132
1137
  * const controller = new AbortController();
1133
1138
  * const { signal } = controller;
1134
1139
  * const child = execFile('node', ['--version'], { signal }, (error) => {
@@ -1364,12 +1369,12 @@ declare module "child_process" {
1364
1369
  * the error passed to the callback will be an `AbortError`:
1365
1370
  *
1366
1371
  * ```js
1372
+ * import { fork } from 'node:child_process';
1367
1373
  * if (process.argv[2] === 'child') {
1368
1374
  * setTimeout(() => {
1369
1375
  * console.log(`Hello from ${process.argv[2]}!`);
1370
1376
  * }, 1_000);
1371
1377
  * } else {
1372
- * const { fork } = require('child_process');
1373
1378
  * const controller = new AbortController();
1374
1379
  * const { signal } = controller;
1375
1380
  * 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
  * });