@types/node 18.16.2 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. node/README.md +1 -1
  2. node/assert.d.ts +68 -73
  3. node/async_hooks.d.ts +62 -42
  4. node/buffer.d.ts +123 -95
  5. node/child_process.d.ts +50 -54
  6. node/cluster.d.ts +12 -12
  7. node/console.d.ts +5 -5
  8. node/crypto.d.ts +209 -220
  9. node/dgram.d.ts +15 -15
  10. node/diagnostics_channel.d.ts +25 -26
  11. node/dns/promises.d.ts +6 -6
  12. node/dns.d.ts +16 -16
  13. node/domain.d.ts +3 -3
  14. node/events.d.ts +60 -60
  15. node/fs/promises.d.ts +74 -48
  16. node/fs.d.ts +91 -81
  17. node/http.d.ts +147 -144
  18. node/http2.d.ts +42 -46
  19. node/https.d.ts +52 -153
  20. node/index.d.ts +1 -1
  21. node/inspector.d.ts +10 -3
  22. node/module.d.ts +5 -4
  23. node/net.d.ts +21 -18
  24. node/os.d.ts +22 -18
  25. node/package.json +2 -2
  26. node/path.d.ts +4 -4
  27. node/perf_hooks.d.ts +28 -15
  28. node/process.d.ts +43 -46
  29. node/punycode.d.ts +1 -1
  30. node/querystring.d.ts +5 -5
  31. node/readline/promises.d.ts +6 -4
  32. node/readline.d.ts +15 -15
  33. node/repl.d.ts +9 -9
  34. node/stream/consumers.d.ts +1 -1
  35. node/stream.d.ts +74 -136
  36. node/string_decoder.d.ts +6 -6
  37. node/test.d.ts +0 -76
  38. node/timers/promises.d.ts +3 -3
  39. node/timers.d.ts +2 -2
  40. node/tls.d.ts +29 -15
  41. node/trace_events.d.ts +20 -9
  42. node/ts4.8/assert.d.ts +68 -73
  43. node/ts4.8/async_hooks.d.ts +59 -31
  44. node/ts4.8/buffer.d.ts +123 -95
  45. node/ts4.8/child_process.d.ts +50 -54
  46. node/ts4.8/cluster.d.ts +12 -12
  47. node/ts4.8/console.d.ts +5 -5
  48. node/ts4.8/crypto.d.ts +209 -220
  49. node/ts4.8/dgram.d.ts +15 -15
  50. node/ts4.8/diagnostics_channel.d.ts +25 -26
  51. node/ts4.8/dns/promises.d.ts +6 -6
  52. node/ts4.8/dns.d.ts +16 -16
  53. node/ts4.8/domain.d.ts +3 -3
  54. node/ts4.8/events.d.ts +60 -60
  55. node/ts4.8/fs/promises.d.ts +72 -45
  56. node/ts4.8/fs.d.ts +81 -67
  57. node/ts4.8/http.d.ts +133 -126
  58. node/ts4.8/http2.d.ts +42 -46
  59. node/ts4.8/https.d.ts +52 -153
  60. node/ts4.8/inspector.d.ts +10 -3
  61. node/ts4.8/module.d.ts +5 -4
  62. node/ts4.8/net.d.ts +21 -18
  63. node/ts4.8/os.d.ts +22 -18
  64. node/ts4.8/path.d.ts +4 -4
  65. node/ts4.8/perf_hooks.d.ts +28 -15
  66. node/ts4.8/process.d.ts +43 -46
  67. node/ts4.8/punycode.d.ts +1 -1
  68. node/ts4.8/querystring.d.ts +5 -5
  69. node/ts4.8/readline/promises.d.ts +6 -4
  70. node/ts4.8/readline.d.ts +15 -15
  71. node/ts4.8/repl.d.ts +9 -9
  72. node/ts4.8/stream/consumers.d.ts +1 -1
  73. node/ts4.8/stream.d.ts +77 -139
  74. node/ts4.8/string_decoder.d.ts +6 -6
  75. node/ts4.8/test.d.ts +0 -75
  76. node/ts4.8/timers/promises.d.ts +3 -3
  77. node/ts4.8/timers.d.ts +2 -2
  78. node/ts4.8/tls.d.ts +29 -15
  79. node/ts4.8/trace_events.d.ts +20 -9
  80. node/ts4.8/tty.d.ts +4 -5
  81. node/ts4.8/url.d.ts +26 -36
  82. node/ts4.8/util.d.ts +143 -116
  83. node/ts4.8/v8.d.ts +107 -16
  84. node/ts4.8/vm.d.ts +292 -42
  85. node/ts4.8/wasi.d.ts +8 -14
  86. node/ts4.8/worker_threads.d.ts +32 -34
  87. node/ts4.8/zlib.d.ts +11 -11
  88. node/tty.d.ts +4 -5
  89. node/url.d.ts +26 -36
  90. node/util.d.ts +146 -111
  91. node/v8.d.ts +110 -16
  92. node/vm.d.ts +292 -42
  93. node/wasi.d.ts +8 -14
  94. node/worker_threads.d.ts +32 -34
  95. node/zlib.d.ts +11 -11
node/buffer.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * recommended to explicitly reference it via an import or require statement.
11
11
  *
12
12
  * ```js
13
- * import { Buffer } from 'buffer';
13
+ * import { Buffer } from 'node:buffer';
14
14
  *
15
15
  * // Creates a zero-filled Buffer of length 10.
16
16
  * const buf1 = Buffer.alloc(10);
@@ -41,12 +41,28 @@
41
41
  * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
42
42
  * const buf7 = Buffer.from('tést', 'latin1');
43
43
  * ```
44
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/buffer.js)
44
+ * @see [source](https://github.com/nodejs/node/blob/v20.0.0/lib/buffer.js)
45
45
  */
46
46
  declare module 'buffer' {
47
47
  import { BinaryLike } from 'node:crypto';
48
48
  import { ReadableStream as WebReadableStream } from 'node:stream/web';
49
+ /**
50
+ * This function returns `true` if `input` contains only valid UTF-8-encoded data,
51
+ * including the case in which `input` is empty.
52
+ *
53
+ * Throws if the `input` is a detached array buffer.
54
+ * @since v19.4.0, v18.14.0
55
+ * @param input The input to validate.
56
+ */
49
57
  export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
58
+ /**
59
+ * This function returns `true` if `input` contains only valid ASCII-encoded data,
60
+ * including the case in which `input` is empty.
61
+ *
62
+ * Throws if the `input` is a detached array buffer.
63
+ * @since v19.6.0, v18.15.0
64
+ * @param input The input to validate.
65
+ */
50
66
  export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
51
67
  export const INSPECT_MAX_BYTES: number;
52
68
  export const kMaxLength: number;
@@ -69,7 +85,7 @@ declare module 'buffer' {
69
85
  * sequence cannot be adequately represented in the target encoding. For instance:
70
86
  *
71
87
  * ```js
72
- * import { Buffer, transcode } from 'buffer';
88
+ * import { Buffer, transcode } from 'node:buffer';
73
89
  *
74
90
  * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
75
91
  * console.log(newBuf.toString('ascii'));
@@ -160,7 +176,7 @@ declare module 'buffer' {
160
176
  */
161
177
  text(): Promise<string>;
162
178
  /**
163
- * Returns a new (WHATWG) `ReadableStream` that allows the content of the `Blob` to be read.
179
+ * Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
164
180
  * @since v16.7.0
165
181
  */
166
182
  stream(): WebReadableStream;
@@ -178,25 +194,23 @@ declare module 'buffer' {
178
194
  }
179
195
  /**
180
196
  * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.
181
- * @experimental
182
- * @since v18.13.0
197
+ * @since v19.2.0, v18.13.0
183
198
  */
184
199
  export class File extends Blob {
185
200
  constructor(sources: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions);
186
201
  /**
187
202
  * The name of the `File`.
188
- * @since v18.13.0
203
+ * @since v19.2.0, v18.13.0
189
204
  */
190
205
  readonly name: string;
191
206
  /**
192
207
  * The last modified date of the `File`.
193
- * @since v18.13.0
208
+ * @since v19.2.0, v18.13.0
194
209
  */
195
210
  readonly lastModified: number;
196
211
  }
197
212
  export import atob = globalThis.atob;
198
213
  export import btoa = globalThis.btoa;
199
-
200
214
  import { Blob as NodeBlob } from 'buffer';
201
215
  // This conditional type will be the existing global Blob in a browser, or
202
216
  // the copy below in a Node environment.
@@ -276,7 +290,7 @@ declare module 'buffer' {
276
290
  * Array entries outside that range will be truncated to fit into it.
277
291
  *
278
292
  * ```js
279
- * import { Buffer } from 'buffer';
293
+ * import { Buffer } from 'node:buffer';
280
294
  *
281
295
  * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
282
296
  * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
@@ -321,7 +335,7 @@ declare module 'buffer' {
321
335
  * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
322
336
  *
323
337
  * ```js
324
- * import { Buffer } from 'buffer';
338
+ * import { Buffer } from 'node:buffer';
325
339
  *
326
340
  * Buffer.isBuffer(Buffer.alloc(10)); // true
327
341
  * Buffer.isBuffer(Buffer.from('foo')); // true
@@ -337,7 +351,7 @@ declare module 'buffer' {
337
351
  * or `false` otherwise.
338
352
  *
339
353
  * ```js
340
- * import { Buffer } from 'buffer';
354
+ * import { Buffer } from 'node:buffer';
341
355
  *
342
356
  * console.log(Buffer.isEncoding('utf8'));
343
357
  * // Prints: true
@@ -366,7 +380,7 @@ declare module 'buffer' {
366
380
  * string.
367
381
  *
368
382
  * ```js
369
- * import { Buffer } from 'buffer';
383
+ * import { Buffer } from 'node:buffer';
370
384
  *
371
385
  * const str = '\u00bd + \u00bc = \u00be';
372
386
  *
@@ -401,7 +415,7 @@ declare module 'buffer' {
401
415
  * truncated to `totalLength`.
402
416
  *
403
417
  * ```js
404
- * import { Buffer } from 'buffer';
418
+ * import { Buffer } from 'node:buffer';
405
419
  *
406
420
  * // Create a single `Buffer` from a list of three `Buffer` instances.
407
421
  *
@@ -429,17 +443,26 @@ declare module 'buffer' {
429
443
  concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
430
444
  /**
431
445
  * Copies the underlying memory of `view` into a new `Buffer`.
432
- * @since v18.16.0
433
- * @param view The `TypedArray` to copy.
434
- * @param offset The starting offset within `view`.
435
- * @param length The number of elements from `view` to copy.
446
+ *
447
+ * ```js
448
+ * const u16 = new Uint16Array([0, 0xffff]);
449
+ * const buf = Buffer.copyBytesFrom(u16, 0, 1);
450
+ * u16[1] = 0;
451
+ * console.log(buf.length); // 2
452
+ * console.log(buf[0]); // 255
453
+ * console.log(buf[1]); // 255
454
+ * ```
455
+ * @since v19.8.0
456
+ * @param view The {TypedArray} to copy.
457
+ * @param [offset=': 0'] The starting offset within `view`.
458
+ * @param [length=view.length - offset] The number of elements from `view` to copy.
436
459
  */
437
460
  copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
438
461
  /**
439
462
  * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
440
463
  *
441
464
  * ```js
442
- * import { Buffer } from 'buffer';
465
+ * import { Buffer } from 'node:buffer';
443
466
  *
444
467
  * const buf1 = Buffer.from('1234');
445
468
  * const buf2 = Buffer.from('0123');
@@ -457,7 +480,7 @@ declare module 'buffer' {
457
480
  * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
458
481
  *
459
482
  * ```js
460
- * import { Buffer } from 'buffer';
483
+ * import { Buffer } from 'node:buffer';
461
484
  *
462
485
  * const buf = Buffer.alloc(5);
463
486
  *
@@ -470,7 +493,7 @@ declare module 'buffer' {
470
493
  * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
471
494
  *
472
495
  * ```js
473
- * import { Buffer } from 'buffer';
496
+ * import { Buffer } from 'node:buffer';
474
497
  *
475
498
  * const buf = Buffer.alloc(5, 'a');
476
499
  *
@@ -482,7 +505,7 @@ declare module 'buffer' {
482
505
  * initialized by calling `buf.fill(fill, encoding)`.
483
506
  *
484
507
  * ```js
485
- * import { Buffer } from 'buffer';
508
+ * import { Buffer } from 'node:buffer';
486
509
  *
487
510
  * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
488
511
  *
@@ -508,7 +531,7 @@ declare module 'buffer' {
508
531
  * _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.
509
532
  *
510
533
  * ```js
511
- * import { Buffer } from 'buffer';
534
+ * import { Buffer } from 'node:buffer';
512
535
  *
513
536
  * const buf = Buffer.allocUnsafe(10);
514
537
  *
@@ -547,7 +570,7 @@ declare module 'buffer' {
547
570
  * such `Buffer` instances with zeroes.
548
571
  *
549
572
  * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
550
- * allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This
573
+ * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
551
574
  * allows applications to avoid the garbage collection overhead of creating many
552
575
  * individually allocated `Buffer` instances. This approach improves both
553
576
  * performance and memory usage by eliminating the need to track and clean up as
@@ -559,7 +582,7 @@ declare module 'buffer' {
559
582
  * then copying out the relevant bits.
560
583
  *
561
584
  * ```js
562
- * import { Buffer } from 'buffer';
585
+ * import { Buffer } from 'node:buffer';
563
586
  *
564
587
  * // Need to keep around a few small chunks of memory.
565
588
  * const store = [];
@@ -597,7 +620,7 @@ declare module 'buffer' {
597
620
  * written. However, partially encoded characters will not be written.
598
621
  *
599
622
  * ```js
600
- * import { Buffer } from 'buffer';
623
+ * import { Buffer } from 'node:buffer';
601
624
  *
602
625
  * const buf = Buffer.alloc(256);
603
626
  *
@@ -633,7 +656,7 @@ declare module 'buffer' {
633
656
  * as {@link constants.MAX_STRING_LENGTH}.
634
657
  *
635
658
  * ```js
636
- * import { Buffer } from 'buffer';
659
+ * import { Buffer } from 'node:buffer';
637
660
  *
638
661
  * const buf1 = Buffer.allocUnsafe(26);
639
662
  *
@@ -670,7 +693,7 @@ declare module 'buffer' {
670
693
  * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
671
694
  *
672
695
  * ```js
673
- * import { Buffer } from 'buffer';
696
+ * import { Buffer } from 'node:buffer';
674
697
  *
675
698
  * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
676
699
  * const json = JSON.stringify(buf);
@@ -697,7 +720,7 @@ declare module 'buffer' {
697
720
  * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
698
721
  *
699
722
  * ```js
700
- * import { Buffer } from 'buffer';
723
+ * import { Buffer } from 'node:buffer';
701
724
  *
702
725
  * const buf1 = Buffer.from('ABC');
703
726
  * const buf2 = Buffer.from('414243', 'hex');
@@ -721,7 +744,7 @@ declare module 'buffer' {
721
744
  * * `-1` is returned if `target` should come _after_`buf` when sorted.
722
745
  *
723
746
  * ```js
724
- * import { Buffer } from 'buffer';
747
+ * import { Buffer } from 'node:buffer';
725
748
  *
726
749
  * const buf1 = Buffer.from('ABC');
727
750
  * const buf2 = Buffer.from('BCD');
@@ -745,7 +768,7 @@ declare module 'buffer' {
745
768
  * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
746
769
  *
747
770
  * ```js
748
- * import { Buffer } from 'buffer';
771
+ * import { Buffer } from 'node:buffer';
749
772
  *
750
773
  * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
751
774
  * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
@@ -781,7 +804,7 @@ declare module 'buffer' {
781
804
  * different function arguments.
782
805
  *
783
806
  * ```js
784
- * import { Buffer } from 'buffer';
807
+ * import { Buffer } from 'node:buffer';
785
808
  *
786
809
  * // Create two `Buffer` instances.
787
810
  * const buf1 = Buffer.allocUnsafe(26);
@@ -802,7 +825,7 @@ declare module 'buffer' {
802
825
  * ```
803
826
  *
804
827
  * ```js
805
- * import { Buffer } from 'buffer';
828
+ * import { Buffer } from 'node:buffer';
806
829
  *
807
830
  * // Create a `Buffer` and copy data from one region to an overlapping region
808
831
  * // within the same `Buffer`.
@@ -835,7 +858,7 @@ declare module 'buffer' {
835
858
  * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
836
859
  *
837
860
  * ```js
838
- * import { Buffer } from 'buffer';
861
+ * import { Buffer } from 'node:buffer';
839
862
  *
840
863
  * const buf = Buffer.from('buffer');
841
864
  *
@@ -873,7 +896,7 @@ declare module 'buffer' {
873
896
  * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
874
897
  *
875
898
  * ```js
876
- * import { Buffer } from 'buffer';
899
+ * import { Buffer } from 'node:buffer';
877
900
  *
878
901
  * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
879
902
  * // from the original `Buffer`.
@@ -900,7 +923,7 @@ declare module 'buffer' {
900
923
  * end of `buf` rather than the beginning.
901
924
  *
902
925
  * ```js
903
- * import { Buffer } from 'buffer';
926
+ * import { Buffer } from 'node:buffer';
904
927
  *
905
928
  * const buf = Buffer.from('buffer');
906
929
  *
@@ -927,7 +950,7 @@ declare module 'buffer' {
927
950
  * `value` is interpreted and written as a two's complement signed integer.
928
951
  *
929
952
  * ```js
930
- * import { Buffer } from 'buffer';
953
+ * import { Buffer } from 'node:buffer';
931
954
  *
932
955
  * const buf = Buffer.allocUnsafe(8);
933
956
  *
@@ -948,7 +971,7 @@ declare module 'buffer' {
948
971
  * `value` is interpreted and written as a two's complement signed integer.
949
972
  *
950
973
  * ```js
951
- * import { Buffer } from 'buffer';
974
+ * import { Buffer } from 'node:buffer';
952
975
  *
953
976
  * const buf = Buffer.allocUnsafe(8);
954
977
  *
@@ -969,7 +992,7 @@ declare module 'buffer' {
969
992
  * This function is also available under the `writeBigUint64BE` alias.
970
993
  *
971
994
  * ```js
972
- * import { Buffer } from 'buffer';
995
+ * import { Buffer } from 'node:buffer';
973
996
  *
974
997
  * const buf = Buffer.allocUnsafe(8);
975
998
  *
@@ -993,7 +1016,7 @@ declare module 'buffer' {
993
1016
  * Writes `value` to `buf` at the specified `offset` as little-endian
994
1017
  *
995
1018
  * ```js
996
- * import { Buffer } from 'buffer';
1019
+ * import { Buffer } from 'node:buffer';
997
1020
  *
998
1021
  * const buf = Buffer.allocUnsafe(8);
999
1022
  *
@@ -1022,7 +1045,7 @@ declare module 'buffer' {
1022
1045
  * This function is also available under the `writeUintLE` alias.
1023
1046
  *
1024
1047
  * ```js
1025
- * import { Buffer } from 'buffer';
1048
+ * import { Buffer } from 'node:buffer';
1026
1049
  *
1027
1050
  * const buf = Buffer.allocUnsafe(6);
1028
1051
  *
@@ -1050,7 +1073,7 @@ declare module 'buffer' {
1050
1073
  * This function is also available under the `writeUintBE` alias.
1051
1074
  *
1052
1075
  * ```js
1053
- * import { Buffer } from 'buffer';
1076
+ * import { Buffer } from 'node:buffer';
1054
1077
  *
1055
1078
  * const buf = Buffer.allocUnsafe(6);
1056
1079
  *
@@ -1076,7 +1099,7 @@ declare module 'buffer' {
1076
1099
  * when `value` is anything other than a signed integer.
1077
1100
  *
1078
1101
  * ```js
1079
- * import { Buffer } from 'buffer';
1102
+ * import { Buffer } from 'node:buffer';
1080
1103
  *
1081
1104
  * const buf = Buffer.allocUnsafe(6);
1082
1105
  *
@@ -1097,7 +1120,7 @@ declare module 'buffer' {
1097
1120
  * signed integer.
1098
1121
  *
1099
1122
  * ```js
1100
- * import { Buffer } from 'buffer';
1123
+ * import { Buffer } from 'node:buffer';
1101
1124
  *
1102
1125
  * const buf = Buffer.allocUnsafe(6);
1103
1126
  *
@@ -1119,7 +1142,7 @@ declare module 'buffer' {
1119
1142
  * This function is also available under the `readBigUint64BE` alias.
1120
1143
  *
1121
1144
  * ```js
1122
- * import { Buffer } from 'buffer';
1145
+ * import { Buffer } from 'node:buffer';
1123
1146
  *
1124
1147
  * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
1125
1148
  *
@@ -1141,7 +1164,7 @@ declare module 'buffer' {
1141
1164
  * This function is also available under the `readBigUint64LE` alias.
1142
1165
  *
1143
1166
  * ```js
1144
- * import { Buffer } from 'buffer';
1167
+ * import { Buffer } from 'node:buffer';
1145
1168
  *
1146
1169
  * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
1147
1170
  *
@@ -1182,7 +1205,7 @@ declare module 'buffer' {
1182
1205
  * This function is also available under the `readUintLE` alias.
1183
1206
  *
1184
1207
  * ```js
1185
- * import { Buffer } from 'buffer';
1208
+ * import { Buffer } from 'node:buffer';
1186
1209
  *
1187
1210
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1188
1211
  *
@@ -1206,7 +1229,7 @@ declare module 'buffer' {
1206
1229
  * This function is also available under the `readUintBE` alias.
1207
1230
  *
1208
1231
  * ```js
1209
- * import { Buffer } from 'buffer';
1232
+ * import { Buffer } from 'node:buffer';
1210
1233
  *
1211
1234
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1212
1235
  *
@@ -1230,7 +1253,7 @@ declare module 'buffer' {
1230
1253
  * supporting up to 48 bits of accuracy.
1231
1254
  *
1232
1255
  * ```js
1233
- * import { Buffer } from 'buffer';
1256
+ * import { Buffer } from 'node:buffer';
1234
1257
  *
1235
1258
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1236
1259
  *
@@ -1247,7 +1270,7 @@ declare module 'buffer' {
1247
1270
  * supporting up to 48 bits of accuracy.
1248
1271
  *
1249
1272
  * ```js
1250
- * import { Buffer } from 'buffer';
1273
+ * import { Buffer } from 'node:buffer';
1251
1274
  *
1252
1275
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1253
1276
  *
@@ -1269,7 +1292,7 @@ declare module 'buffer' {
1269
1292
  * This function is also available under the `readUint8` alias.
1270
1293
  *
1271
1294
  * ```js
1272
- * import { Buffer } from 'buffer';
1295
+ * import { Buffer } from 'node:buffer';
1273
1296
  *
1274
1297
  * const buf = Buffer.from([1, -2]);
1275
1298
  *
@@ -1295,7 +1318,7 @@ declare module 'buffer' {
1295
1318
  * This function is also available under the `readUint16LE` alias.
1296
1319
  *
1297
1320
  * ```js
1298
- * import { Buffer } from 'buffer';
1321
+ * import { Buffer } from 'node:buffer';
1299
1322
  *
1300
1323
  * const buf = Buffer.from([0x12, 0x34, 0x56]);
1301
1324
  *
@@ -1321,7 +1344,7 @@ declare module 'buffer' {
1321
1344
  * This function is also available under the `readUint16BE` alias.
1322
1345
  *
1323
1346
  * ```js
1324
- * import { Buffer } from 'buffer';
1347
+ * import { Buffer } from 'node:buffer';
1325
1348
  *
1326
1349
  * const buf = Buffer.from([0x12, 0x34, 0x56]);
1327
1350
  *
@@ -1345,7 +1368,7 @@ declare module 'buffer' {
1345
1368
  * This function is also available under the `readUint32LE` alias.
1346
1369
  *
1347
1370
  * ```js
1348
- * import { Buffer } from 'buffer';
1371
+ * import { Buffer } from 'node:buffer';
1349
1372
  *
1350
1373
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
1351
1374
  *
@@ -1369,7 +1392,7 @@ declare module 'buffer' {
1369
1392
  * This function is also available under the `readUint32BE` alias.
1370
1393
  *
1371
1394
  * ```js
1372
- * import { Buffer } from 'buffer';
1395
+ * import { Buffer } from 'node:buffer';
1373
1396
  *
1374
1397
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
1375
1398
  *
@@ -1391,7 +1414,7 @@ declare module 'buffer' {
1391
1414
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1392
1415
  *
1393
1416
  * ```js
1394
- * import { Buffer } from 'buffer';
1417
+ * import { Buffer } from 'node:buffer';
1395
1418
  *
1396
1419
  * const buf = Buffer.from([-1, 5]);
1397
1420
  *
@@ -1412,7 +1435,7 @@ declare module 'buffer' {
1412
1435
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1413
1436
  *
1414
1437
  * ```js
1415
- * import { Buffer } from 'buffer';
1438
+ * import { Buffer } from 'node:buffer';
1416
1439
  *
1417
1440
  * const buf = Buffer.from([0, 5]);
1418
1441
  *
@@ -1431,7 +1454,7 @@ declare module 'buffer' {
1431
1454
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1432
1455
  *
1433
1456
  * ```js
1434
- * import { Buffer } from 'buffer';
1457
+ * import { Buffer } from 'node:buffer';
1435
1458
  *
1436
1459
  * const buf = Buffer.from([0, 5]);
1437
1460
  *
@@ -1448,7 +1471,7 @@ declare module 'buffer' {
1448
1471
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1449
1472
  *
1450
1473
  * ```js
1451
- * import { Buffer } from 'buffer';
1474
+ * import { Buffer } from 'node:buffer';
1452
1475
  *
1453
1476
  * const buf = Buffer.from([0, 0, 0, 5]);
1454
1477
  *
@@ -1467,7 +1490,7 @@ declare module 'buffer' {
1467
1490
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1468
1491
  *
1469
1492
  * ```js
1470
- * import { Buffer } from 'buffer';
1493
+ * import { Buffer } from 'node:buffer';
1471
1494
  *
1472
1495
  * const buf = Buffer.from([0, 0, 0, 5]);
1473
1496
  *
@@ -1482,7 +1505,7 @@ declare module 'buffer' {
1482
1505
  * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
1483
1506
  *
1484
1507
  * ```js
1485
- * import { Buffer } from 'buffer';
1508
+ * import { Buffer } from 'node:buffer';
1486
1509
  *
1487
1510
  * const buf = Buffer.from([1, 2, 3, 4]);
1488
1511
  *
@@ -1499,7 +1522,7 @@ declare module 'buffer' {
1499
1522
  * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
1500
1523
  *
1501
1524
  * ```js
1502
- * import { Buffer } from 'buffer';
1525
+ * import { Buffer } from 'node:buffer';
1503
1526
  *
1504
1527
  * const buf = Buffer.from([1, 2, 3, 4]);
1505
1528
  *
@@ -1514,7 +1537,7 @@ declare module 'buffer' {
1514
1537
  * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
1515
1538
  *
1516
1539
  * ```js
1517
- * import { Buffer } from 'buffer';
1540
+ * import { Buffer } from 'node:buffer';
1518
1541
  *
1519
1542
  * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1520
1543
  *
@@ -1531,7 +1554,7 @@ declare module 'buffer' {
1531
1554
  * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
1532
1555
  *
1533
1556
  * ```js
1534
- * import { Buffer } from 'buffer';
1557
+ * import { Buffer } from 'node:buffer';
1535
1558
  *
1536
1559
  * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1537
1560
  *
@@ -1548,7 +1571,7 @@ declare module 'buffer' {
1548
1571
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
1549
1572
  *
1550
1573
  * ```js
1551
- * import { Buffer } from 'buffer';
1574
+ * import { Buffer } from 'node:buffer';
1552
1575
  *
1553
1576
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1554
1577
  *
@@ -1570,7 +1593,7 @@ declare module 'buffer' {
1570
1593
  * between UTF-16 little-endian and UTF-16 big-endian:
1571
1594
  *
1572
1595
  * ```js
1573
- * import { Buffer } from 'buffer';
1596
+ * import { Buffer } from 'node:buffer';
1574
1597
  *
1575
1598
  * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1576
1599
  * buf.swap16(); // Convert to big-endian UTF-16 text.
@@ -1584,7 +1607,7 @@ declare module 'buffer' {
1584
1607
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
1585
1608
  *
1586
1609
  * ```js
1587
- * import { Buffer } from 'buffer';
1610
+ * import { Buffer } from 'node:buffer';
1588
1611
  *
1589
1612
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1590
1613
  *
@@ -1610,7 +1633,7 @@ declare module 'buffer' {
1610
1633
  * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
1611
1634
  *
1612
1635
  * ```js
1613
- * import { Buffer } from 'buffer';
1636
+ * import { Buffer } from 'node:buffer';
1614
1637
  *
1615
1638
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1616
1639
  *
@@ -1639,7 +1662,7 @@ declare module 'buffer' {
1639
1662
  * This function is also available under the `writeUint8` alias.
1640
1663
  *
1641
1664
  * ```js
1642
- * import { Buffer } from 'buffer';
1665
+ * import { Buffer } from 'node:buffer';
1643
1666
  *
1644
1667
  * const buf = Buffer.allocUnsafe(4);
1645
1668
  *
@@ -1669,7 +1692,7 @@ declare module 'buffer' {
1669
1692
  * This function is also available under the `writeUint16LE` alias.
1670
1693
  *
1671
1694
  * ```js
1672
- * import { Buffer } from 'buffer';
1695
+ * import { Buffer } from 'node:buffer';
1673
1696
  *
1674
1697
  * const buf = Buffer.allocUnsafe(4);
1675
1698
  *
@@ -1697,7 +1720,7 @@ declare module 'buffer' {
1697
1720
  * This function is also available under the `writeUint16BE` alias.
1698
1721
  *
1699
1722
  * ```js
1700
- * import { Buffer } from 'buffer';
1723
+ * import { Buffer } from 'node:buffer';
1701
1724
  *
1702
1725
  * const buf = Buffer.allocUnsafe(4);
1703
1726
  *
@@ -1725,7 +1748,7 @@ declare module 'buffer' {
1725
1748
  * This function is also available under the `writeUint32LE` alias.
1726
1749
  *
1727
1750
  * ```js
1728
- * import { Buffer } from 'buffer';
1751
+ * import { Buffer } from 'node:buffer';
1729
1752
  *
1730
1753
  * const buf = Buffer.allocUnsafe(4);
1731
1754
  *
@@ -1752,7 +1775,7 @@ declare module 'buffer' {
1752
1775
  * This function is also available under the `writeUint32BE` alias.
1753
1776
  *
1754
1777
  * ```js
1755
- * import { Buffer } from 'buffer';
1778
+ * import { Buffer } from 'node:buffer';
1756
1779
  *
1757
1780
  * const buf = Buffer.allocUnsafe(4);
1758
1781
  *
@@ -1780,7 +1803,7 @@ declare module 'buffer' {
1780
1803
  * `value` is interpreted and written as a two's complement signed integer.
1781
1804
  *
1782
1805
  * ```js
1783
- * import { Buffer } from 'buffer';
1806
+ * import { Buffer } from 'node:buffer';
1784
1807
  *
1785
1808
  * const buf = Buffer.allocUnsafe(2);
1786
1809
  *
@@ -1803,7 +1826,7 @@ declare module 'buffer' {
1803
1826
  * The `value` is interpreted and written as a two's complement signed integer.
1804
1827
  *
1805
1828
  * ```js
1806
- * import { Buffer } from 'buffer';
1829
+ * import { Buffer } from 'node:buffer';
1807
1830
  *
1808
1831
  * const buf = Buffer.allocUnsafe(2);
1809
1832
  *
@@ -1825,7 +1848,7 @@ declare module 'buffer' {
1825
1848
  * The `value` is interpreted and written as a two's complement signed integer.
1826
1849
  *
1827
1850
  * ```js
1828
- * import { Buffer } from 'buffer';
1851
+ * import { Buffer } from 'node:buffer';
1829
1852
  *
1830
1853
  * const buf = Buffer.allocUnsafe(2);
1831
1854
  *
@@ -1847,7 +1870,7 @@ declare module 'buffer' {
1847
1870
  * The `value` is interpreted and written as a two's complement signed integer.
1848
1871
  *
1849
1872
  * ```js
1850
- * import { Buffer } from 'buffer';
1873
+ * import { Buffer } from 'node:buffer';
1851
1874
  *
1852
1875
  * const buf = Buffer.allocUnsafe(4);
1853
1876
  *
@@ -1869,7 +1892,7 @@ declare module 'buffer' {
1869
1892
  * The `value` is interpreted and written as a two's complement signed integer.
1870
1893
  *
1871
1894
  * ```js
1872
- * import { Buffer } from 'buffer';
1895
+ * import { Buffer } from 'node:buffer';
1873
1896
  *
1874
1897
  * const buf = Buffer.allocUnsafe(4);
1875
1898
  *
@@ -1889,7 +1912,7 @@ declare module 'buffer' {
1889
1912
  * undefined when `value` is anything other than a JavaScript number.
1890
1913
  *
1891
1914
  * ```js
1892
- * import { Buffer } from 'buffer';
1915
+ * import { Buffer } from 'node:buffer';
1893
1916
  *
1894
1917
  * const buf = Buffer.allocUnsafe(4);
1895
1918
  *
@@ -1909,7 +1932,7 @@ declare module 'buffer' {
1909
1932
  * undefined when `value` is anything other than a JavaScript number.
1910
1933
  *
1911
1934
  * ```js
1912
- * import { Buffer } from 'buffer';
1935
+ * import { Buffer } from 'node:buffer';
1913
1936
  *
1914
1937
  * const buf = Buffer.allocUnsafe(4);
1915
1938
  *
@@ -1929,7 +1952,7 @@ declare module 'buffer' {
1929
1952
  * other than a JavaScript number.
1930
1953
  *
1931
1954
  * ```js
1932
- * import { Buffer } from 'buffer';
1955
+ * import { Buffer } from 'node:buffer';
1933
1956
  *
1934
1957
  * const buf = Buffer.allocUnsafe(8);
1935
1958
  *
@@ -1949,7 +1972,7 @@ declare module 'buffer' {
1949
1972
  * other than a JavaScript number.
1950
1973
  *
1951
1974
  * ```js
1952
- * import { Buffer } from 'buffer';
1975
+ * import { Buffer } from 'node:buffer';
1953
1976
  *
1954
1977
  * const buf = Buffer.allocUnsafe(8);
1955
1978
  *
@@ -1969,7 +1992,7 @@ declare module 'buffer' {
1969
1992
  * the entire `buf` will be filled:
1970
1993
  *
1971
1994
  * ```js
1972
- * import { Buffer } from 'buffer';
1995
+ * import { Buffer } from 'node:buffer';
1973
1996
  *
1974
1997
  * // Fill a `Buffer` with the ASCII character 'h'.
1975
1998
  *
@@ -1977,6 +2000,12 @@ declare module 'buffer' {
1977
2000
  *
1978
2001
  * console.log(b.toString());
1979
2002
  * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
2003
+ *
2004
+ * // Fill a buffer with empty string
2005
+ * const c = Buffer.allocUnsafe(5).fill('');
2006
+ *
2007
+ * console.log(c.fill(''));
2008
+ * // Prints: <Buffer 00 00 00 00 00>
1980
2009
  * ```
1981
2010
  *
1982
2011
  * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
@@ -1987,7 +2016,7 @@ declare module 'buffer' {
1987
2016
  * then only the bytes of that character that fit into `buf` are written:
1988
2017
  *
1989
2018
  * ```js
1990
- * import { Buffer } from 'buffer';
2019
+ * import { Buffer } from 'node:buffer';
1991
2020
  *
1992
2021
  * // Fill a `Buffer` with character that takes up two bytes in UTF-8.
1993
2022
  *
@@ -1999,7 +2028,7 @@ declare module 'buffer' {
1999
2028
  * fill data remains, an exception is thrown:
2000
2029
  *
2001
2030
  * ```js
2002
- * import { Buffer } from 'buffer';
2031
+ * import { Buffer } from 'node:buffer';
2003
2032
  *
2004
2033
  * const buf = Buffer.allocUnsafe(5);
2005
2034
  *
@@ -2011,7 +2040,7 @@ declare module 'buffer' {
2011
2040
  * // Throws an exception.
2012
2041
  * ```
2013
2042
  * @since v0.5.0
2014
- * @param value The value with which to fill `buf`.
2043
+ * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`.
2015
2044
  * @param [offset=0] Number of bytes to skip before starting to fill `buf`.
2016
2045
  * @param [end=buf.length] Where to stop filling `buf` (not inclusive).
2017
2046
  * @param [encoding='utf8'] The encoding for `value` if `value` is a string.
@@ -2028,7 +2057,7 @@ declare module 'buffer' {
2028
2057
  * value between `0` and `255`.
2029
2058
  *
2030
2059
  * ```js
2031
- * import { Buffer } from 'buffer';
2060
+ * import { Buffer } from 'node:buffer';
2032
2061
  *
2033
2062
  * const buf = Buffer.from('this is a buffer');
2034
2063
  *
@@ -2061,7 +2090,7 @@ declare module 'buffer' {
2061
2090
  * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
2062
2091
  *
2063
2092
  * ```js
2064
- * import { Buffer } from 'buffer';
2093
+ * import { Buffer } from 'node:buffer';
2065
2094
  *
2066
2095
  * const b = Buffer.from('abcdef');
2067
2096
  *
@@ -2092,7 +2121,7 @@ declare module 'buffer' {
2092
2121
  * rather than the first occurrence.
2093
2122
  *
2094
2123
  * ```js
2095
- * import { Buffer } from 'buffer';
2124
+ * import { Buffer } from 'node:buffer';
2096
2125
  *
2097
2126
  * const buf = Buffer.from('this buffer is a buffer');
2098
2127
  *
@@ -2127,7 +2156,7 @@ declare module 'buffer' {
2127
2156
  * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
2128
2157
  *
2129
2158
  * ```js
2130
- * import { Buffer } from 'buffer';
2159
+ * import { Buffer } from 'node:buffer';
2131
2160
  *
2132
2161
  * const b = Buffer.from('abcdef');
2133
2162
  *
@@ -2160,7 +2189,7 @@ declare module 'buffer' {
2160
2189
  * of `buf`.
2161
2190
  *
2162
2191
  * ```js
2163
- * import { Buffer } from 'buffer';
2192
+ * import { Buffer } from 'node:buffer';
2164
2193
  *
2165
2194
  * // Log the entire contents of a `Buffer`.
2166
2195
  *
@@ -2184,7 +2213,7 @@ declare module 'buffer' {
2184
2213
  * Equivalent to `buf.indexOf() !== -1`.
2185
2214
  *
2186
2215
  * ```js
2187
- * import { Buffer } from 'buffer';
2216
+ * import { Buffer } from 'node:buffer';
2188
2217
  *
2189
2218
  * const buf = Buffer.from('this is a buffer');
2190
2219
  *
@@ -2214,7 +2243,7 @@ declare module 'buffer' {
2214
2243
  * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
2215
2244
  *
2216
2245
  * ```js
2217
- * import { Buffer } from 'buffer';
2246
+ * import { Buffer } from 'node:buffer';
2218
2247
  *
2219
2248
  * const buf = Buffer.from('buffer');
2220
2249
  *
@@ -2237,7 +2266,7 @@ declare module 'buffer' {
2237
2266
  * called automatically when a `Buffer` is used in a `for..of` statement.
2238
2267
  *
2239
2268
  * ```js
2240
- * import { Buffer } from 'buffer';
2269
+ * import { Buffer } from 'node:buffer';
2241
2270
  *
2242
2271
  * const buf = Buffer.from('buffer');
2243
2272
  *
@@ -2300,7 +2329,6 @@ declare module 'buffer' {
2300
2329
  * @param data An ASCII (Latin1) string.
2301
2330
  */
2302
2331
  function btoa(data: string): string;
2303
-
2304
2332
  interface Blob extends __Blob {}
2305
2333
  /**
2306
2334
  * `Blob` class is a global reference for `require('node:buffer').Blob`