@types/node 16.4.14 → 16.7.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.
node/buffer.d.ts CHANGED
@@ -6,10 +6,12 @@
6
6
  * extends it with methods that cover additional use cases. Node.js APIs accept
7
7
  * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)s wherever `Buffer`s are supported as well.
8
8
  *
9
- * The `Buffer` class is within the global scope, making it unlikely that one
10
- * would need to ever use `require('buffer').Buffer`.
9
+ * While the `Buffer` class is available within the global scope, it is still
10
+ * recommended to explicitly reference it via an import or require statement.
11
11
  *
12
12
  * ```js
13
+ * import { Buffer } from 'buffer';
14
+ *
13
15
  * // Creates a zero-filled Buffer of length 10.
14
16
  * const buf1 = Buffer.alloc(10);
15
17
  *
@@ -39,7 +41,7 @@
39
41
  * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
40
42
  * const buf7 = Buffer.from('tést', 'latin1');
41
43
  * ```
42
- * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/buffer.js)
44
+ * @see [source](https://github.com/nodejs/node/blob/v16.7.0/lib/buffer.js)
43
45
  */
44
46
  declare module 'buffer' {
45
47
  import { BinaryLike } from 'node:crypto';
@@ -64,9 +66,9 @@ declare module 'buffer' {
64
66
  * sequence cannot be adequately represented in the target encoding. For instance:
65
67
  *
66
68
  * ```js
67
- * const buffer = require('buffer');
69
+ * import { Buffer, transcode } from 'buffer';
68
70
  *
69
- * const newBuf = buffer.transcode(Buffer.from('€'), 'utf8', 'ascii');
71
+ * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
70
72
  * console.log(newBuf.toString('ascii'));
71
73
  * // Prints: '?'
72
74
  * ```
@@ -84,6 +86,14 @@ declare module 'buffer' {
84
86
  new (size: number): Buffer;
85
87
  prototype: Buffer;
86
88
  };
89
+ /**
90
+ * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
91
+ * a prior call to `URL.createObjectURL()`.
92
+ * @since v16.7.0
93
+ * @experimental
94
+ * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
95
+ */
96
+ export function resolveObjectURL(id: string): Blob | undefined;
87
97
  export { Buffer };
88
98
  /**
89
99
  * @experimental
@@ -142,11 +152,16 @@ declare module 'buffer' {
142
152
  */
143
153
  slice(start?: number, end?: number, type?: string): Blob;
144
154
  /**
145
- * Returns a promise that resolves the contents of the `Blob` decoded as a UTF-8
146
- * string.
155
+ * Returns a promise that fulfills with the contents of the `Blob` decoded as a
156
+ * UTF-8 string.
147
157
  * @since v15.7.0
148
158
  */
149
159
  text(): Promise<string>;
160
+ /**
161
+ * Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
162
+ * @since v16.7.0
163
+ */
164
+ stream(): unknown; // pending web streams types
150
165
  }
151
166
  export import atob = globalThis.atob;
152
167
  export import btoa = globalThis.btoa;
@@ -210,12 +225,21 @@ declare module 'buffer' {
210
225
  */
211
226
  new (buffer: Buffer): Buffer;
212
227
  /**
213
- * When passed a reference to the .buffer property of a TypedArray instance,
214
- * the newly created Buffer will share the same allocated memory as the TypedArray.
215
- * The optional {byteOffset} and {length} arguments specify a memory range
216
- * within the {arrayBuffer} that will be shared by the Buffer.
228
+ * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
229
+ * Array entries outside that range will be truncated to fit into it.
230
+ *
231
+ * ```js
232
+ * import { Buffer } from 'buffer';
233
+ *
234
+ * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
235
+ * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
236
+ * ```
237
+ *
238
+ * A `TypeError` will be thrown if `array` is not an `Array` or another type
239
+ * appropriate for `Buffer.from()` variants.
217
240
  *
218
- * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
241
+ * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
242
+ * @since v5.10.0
219
243
  */
220
244
  from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
221
245
  /**
@@ -243,67 +267,264 @@ declare module 'buffer' {
243
267
  */
244
268
  of(...items: number[]): Buffer;
245
269
  /**
246
- * Returns true if {obj} is a Buffer
270
+ * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
271
+ *
272
+ * ```js
273
+ * import { Buffer } from 'buffer';
247
274
  *
248
- * @param obj object to test.
275
+ * Buffer.isBuffer(Buffer.alloc(10)); // true
276
+ * Buffer.isBuffer(Buffer.from('foo')); // true
277
+ * Buffer.isBuffer('a string'); // false
278
+ * Buffer.isBuffer([]); // false
279
+ * Buffer.isBuffer(new Uint8Array(1024)); // false
280
+ * ```
281
+ * @since v0.1.101
249
282
  */
250
283
  isBuffer(obj: any): obj is Buffer;
251
284
  /**
252
- * Returns true if {encoding} is a valid encoding argument.
253
- * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
285
+ * Returns `true` if `encoding` is the name of a supported character encoding,
286
+ * or `false` otherwise.
287
+ *
288
+ * ```js
289
+ * import { Buffer } from 'buffer';
290
+ *
291
+ * console.log(Buffer.isEncoding('utf8'));
292
+ * // Prints: true
293
+ *
294
+ * console.log(Buffer.isEncoding('hex'));
295
+ * // Prints: true
254
296
  *
255
- * @param encoding string to test.
297
+ * console.log(Buffer.isEncoding('utf/8'));
298
+ * // Prints: false
299
+ *
300
+ * console.log(Buffer.isEncoding(''));
301
+ * // Prints: false
302
+ * ```
303
+ * @since v0.9.1
304
+ * @param encoding A character encoding name to check.
256
305
  */
257
306
  isEncoding(encoding: string): encoding is BufferEncoding;
258
307
  /**
259
- * Gives the actual byte length of a string. encoding defaults to 'utf8'.
260
- * This is not the same as String.prototype.length since that returns the number of characters in a string.
308
+ * Returns the byte length of a string when encoded using `encoding`.
309
+ * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
310
+ * for the encoding that is used to convert the string into bytes.
311
+ *
312
+ * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.
313
+ * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
314
+ * return value might be greater than the length of a `Buffer` created from the
315
+ * string.
261
316
  *
262
- * @param string string to test.
263
- * @param encoding encoding used to evaluate (defaults to 'utf8')
317
+ * ```js
318
+ * import { Buffer } from 'buffer';
319
+ *
320
+ * const str = '\u00bd + \u00bc = \u00be';
321
+ *
322
+ * console.log(`${str}: ${str.length} characters, ` +
323
+ * `${Buffer.byteLength(str, 'utf8')} bytes`);
324
+ * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
325
+ * ```
326
+ *
327
+ * When `string` is a
328
+ * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
329
+ * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
330
+ * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
331
+ * @since v0.1.90
332
+ * @param string A value to calculate the length of.
333
+ * @param [encoding='utf8'] If `string` is a string, this is its encoding.
334
+ * @return The number of bytes contained within `string`.
264
335
  */
265
336
  byteLength(string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number;
266
337
  /**
267
- * Returns a buffer which is the result of concatenating all the buffers in the list together.
338
+ * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
268
339
  *
269
- * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
270
- * If the list has exactly one item, then the first item of the list is returned.
271
- * If the list has more than one item, then a new Buffer is created.
340
+ * If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned.
341
+ *
342
+ * If `totalLength` is not provided, it is calculated from the `Buffer` instances
343
+ * in `list` by adding their lengths.
344
+ *
345
+ * If `totalLength` is provided, it is coerced to an unsigned integer. If the
346
+ * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
347
+ * truncated to `totalLength`.
348
+ *
349
+ * ```js
350
+ * import { Buffer } from 'buffer';
351
+ *
352
+ * // Create a single `Buffer` from a list of three `Buffer` instances.
353
+ *
354
+ * const buf1 = Buffer.alloc(10);
355
+ * const buf2 = Buffer.alloc(14);
356
+ * const buf3 = Buffer.alloc(18);
357
+ * const totalLength = buf1.length + buf2.length + buf3.length;
358
+ *
359
+ * console.log(totalLength);
360
+ * // Prints: 42
361
+ *
362
+ * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
363
+ *
364
+ * console.log(bufA);
365
+ * // Prints: <Buffer 00 00 00 00 ...>
366
+ * console.log(bufA.length);
367
+ * // Prints: 42
368
+ * ```
272
369
  *
273
- * @param list An array of Buffer objects to concatenate
274
- * @param totalLength Total length of the buffers when concatenated.
275
- * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
370
+ * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
371
+ * @since v0.7.11
372
+ * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
373
+ * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
276
374
  */
277
375
  concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
278
376
  /**
279
- * The same as buf1.compare(buf2).
377
+ * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
378
+ *
379
+ * ```js
380
+ * import { Buffer } from 'buffer';
381
+ *
382
+ * const buf1 = Buffer.from('1234');
383
+ * const buf2 = Buffer.from('0123');
384
+ * const arr = [buf1, buf2];
385
+ *
386
+ * console.log(arr.sort(Buffer.compare));
387
+ * // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]
388
+ * // (This result is equal to: [buf2, buf1].)
389
+ * ```
390
+ * @since v0.11.13
391
+ * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
280
392
  */
281
393
  compare(buf1: Uint8Array, buf2: Uint8Array): number;
282
394
  /**
283
- * Allocates a new buffer of {size} octets.
395
+ * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
284
396
  *
285
- * @param size count of octets to allocate.
286
- * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
287
- * If parameter is omitted, buffer will be filled with zeros.
288
- * @param encoding encoding used for call to buf.fill while initalizing
397
+ * ```js
398
+ * import { Buffer } from 'buffer';
399
+ *
400
+ * const buf = Buffer.alloc(5);
401
+ *
402
+ * console.log(buf);
403
+ * // Prints: <Buffer 00 00 00 00 00>
404
+ * ```
405
+ *
406
+ * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
407
+ *
408
+ * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
409
+ *
410
+ * ```js
411
+ * import { Buffer } from 'buffer';
412
+ *
413
+ * const buf = Buffer.alloc(5, 'a');
414
+ *
415
+ * console.log(buf);
416
+ * // Prints: <Buffer 61 61 61 61 61>
417
+ * ```
418
+ *
419
+ * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
420
+ * initialized by calling `buf.fill(fill, encoding)`.
421
+ *
422
+ * ```js
423
+ * import { Buffer } from 'buffer';
424
+ *
425
+ * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
426
+ *
427
+ * console.log(buf);
428
+ * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
429
+ * ```
430
+ *
431
+ * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
432
+ * contents will never contain sensitive data from previous allocations, including
433
+ * data that might not have been allocated for `Buffer`s.
434
+ *
435
+ * A `TypeError` will be thrown if `size` is not a number.
436
+ * @since v5.10.0
437
+ * @param size The desired length of the new `Buffer`.
438
+ * @param [fill=0] A value to pre-fill the new `Buffer` with.
439
+ * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
289
440
  */
290
441
  alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
291
442
  /**
292
- * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
293
- * of the newly created Buffer are unknown and may contain sensitive data.
443
+ * 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.
444
+ *
445
+ * The underlying memory for `Buffer` instances created in this way is _not_
446
+ * _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.
447
+ *
448
+ * ```js
449
+ * import { Buffer } from 'buffer';
450
+ *
451
+ * const buf = Buffer.allocUnsafe(10);
452
+ *
453
+ * console.log(buf);
454
+ * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
455
+ *
456
+ * buf.fill(0);
457
+ *
458
+ * console.log(buf);
459
+ * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
460
+ * ```
461
+ *
462
+ * A `TypeError` will be thrown if `size` is not a number.
463
+ *
464
+ * The `Buffer` module pre-allocates an internal `Buffer` instance of
465
+ * 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
466
+ * deprecated`new Buffer(size)` constructor only when `size` is less than or equal
467
+ * to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
294
468
  *
295
- * @param size count of octets to allocate
469
+ * Use of this pre-allocated internal memory pool is a key difference between
470
+ * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
471
+ * 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
472
+ * than or equal to half `Buffer.poolSize`. The
473
+ * difference is subtle but can be important when an application requires the
474
+ * additional performance that `Buffer.allocUnsafe()` provides.
475
+ * @since v5.10.0
476
+ * @param size The desired length of the new `Buffer`.
296
477
  */
297
478
  allocUnsafe(size: number): Buffer;
298
479
  /**
299
- * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
300
- * of the newly created Buffer are unknown and may contain sensitive data.
480
+ * 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
481
+ * if `size` is 0.
482
+ *
483
+ * The underlying memory for `Buffer` instances created in this way is _not_
484
+ * _initialized_. The contents of the newly created `Buffer` are unknown and_may contain sensitive data_. Use `buf.fill(0)` to initialize
485
+ * such `Buffer` instances with zeroes.
486
+ *
487
+ * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
488
+ * allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This
489
+ * allows applications to avoid the garbage collection overhead of creating many
490
+ * individually allocated `Buffer` instances. This approach improves both
491
+ * performance and memory usage by eliminating the need to track and clean up as
492
+ * many individual `ArrayBuffer` objects.
493
+ *
494
+ * However, in the case where a developer may need to retain a small chunk of
495
+ * memory from a pool for an indeterminate amount of time, it may be appropriate
496
+ * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
497
+ * then copying out the relevant bits.
498
+ *
499
+ * ```js
500
+ * import { Buffer } from 'buffer';
501
+ *
502
+ * // Need to keep around a few small chunks of memory.
503
+ * const store = [];
504
+ *
505
+ * socket.on('readable', () => {
506
+ * let data;
507
+ * while (null !== (data = readable.read())) {
508
+ * // Allocate for retained data.
509
+ * const sb = Buffer.allocUnsafeSlow(10);
301
510
  *
302
- * @param size count of octets to allocate
511
+ * // Copy the data into the new allocation.
512
+ * data.copy(sb, 0, 0, 10);
513
+ *
514
+ * store.push(sb);
515
+ * }
516
+ * });
517
+ * ```
518
+ *
519
+ * A `TypeError` will be thrown if `size` is not a number.
520
+ * @since v5.12.0
521
+ * @param size The desired length of the new `Buffer`.
303
522
  */
304
523
  allocUnsafeSlow(size: number): Buffer;
305
524
  /**
306
- * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
525
+ * This is the size (in bytes) of pre-allocated internal `Buffer` instances used
526
+ * for pooling. This value may be modified.
527
+ * @since v0.11.3
307
528
  */
308
529
  poolSize: number;
309
530
  }
@@ -314,6 +535,8 @@ declare module 'buffer' {
314
535
  * written. However, partially encoded characters will not be written.
315
536
  *
316
537
  * ```js
538
+ * import { Buffer } from 'buffer';
539
+ *
317
540
  * const buf = Buffer.alloc(256);
318
541
  *
319
542
  * const len = buf.write('\u00bd + \u00bc = \u00be', 0);
@@ -348,6 +571,8 @@ declare module 'buffer' {
348
571
  * as {@link constants.MAX_STRING_LENGTH}.
349
572
  *
350
573
  * ```js
574
+ * import { Buffer } from 'buffer';
575
+ *
351
576
  * const buf1 = Buffer.allocUnsafe(26);
352
577
  *
353
578
  * for (let i = 0; i < 26; i++) {
@@ -383,6 +608,8 @@ declare module 'buffer' {
383
608
  * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
384
609
  *
385
610
  * ```js
611
+ * import { Buffer } from 'buffer';
612
+ *
386
613
  * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
387
614
  * const json = JSON.stringify(buf);
388
615
  *
@@ -408,6 +635,8 @@ declare module 'buffer' {
408
635
  * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
409
636
  *
410
637
  * ```js
638
+ * import { Buffer } from 'buffer';
639
+ *
411
640
  * const buf1 = Buffer.from('ABC');
412
641
  * const buf2 = Buffer.from('414243', 'hex');
413
642
  * const buf3 = Buffer.from('ABCD');
@@ -430,6 +659,8 @@ declare module 'buffer' {
430
659
  * * `-1` is returned if `target` should come _after_`buf` when sorted.
431
660
  *
432
661
  * ```js
662
+ * import { Buffer } from 'buffer';
663
+ *
433
664
  * const buf1 = Buffer.from('ABC');
434
665
  * const buf2 = Buffer.from('BCD');
435
666
  * const buf3 = Buffer.from('ABCD');
@@ -452,6 +683,8 @@ declare module 'buffer' {
452
683
  * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
453
684
  *
454
685
  * ```js
686
+ * import { Buffer } from 'buffer';
687
+ *
455
688
  * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
456
689
  * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
457
690
  *
@@ -480,6 +713,8 @@ declare module 'buffer' {
480
713
  * different function arguments.
481
714
  *
482
715
  * ```js
716
+ * import { Buffer } from 'buffer';
717
+ *
483
718
  * // Create two `Buffer` instances.
484
719
  * const buf1 = Buffer.allocUnsafe(26);
485
720
  * const buf2 = Buffer.allocUnsafe(26).fill('!');
@@ -499,6 +734,8 @@ declare module 'buffer' {
499
734
  * ```
500
735
  *
501
736
  * ```js
737
+ * import { Buffer } from 'buffer';
738
+ *
502
739
  * // Create a `Buffer` and copy data from one region to an overlapping region
503
740
  * // within the same `Buffer`.
504
741
  *
@@ -532,6 +769,8 @@ declare module 'buffer' {
532
769
  * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
533
770
  *
534
771
  * ```js
772
+ * import { Buffer } from 'buffer';
773
+ *
535
774
  * const buf = Buffer.from('buffer');
536
775
  *
537
776
  * const copiedBuf = Uint8Array.prototype.slice.call(buf);
@@ -559,6 +798,8 @@ declare module 'buffer' {
559
798
  * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
560
799
  *
561
800
  * ```js
801
+ * import { Buffer } from 'buffer';
802
+ *
562
803
  * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
563
804
  * // from the original `Buffer`.
564
805
  *
@@ -584,6 +825,8 @@ declare module 'buffer' {
584
825
  * end of `buf` rather than the beginning.
585
826
  *
586
827
  * ```js
828
+ * import { Buffer } from 'buffer';
829
+ *
587
830
  * const buf = Buffer.from('buffer');
588
831
  *
589
832
  * console.log(buf.subarray(-6, -1).toString());
@@ -609,6 +852,8 @@ declare module 'buffer' {
609
852
  * `value` is interpreted and written as a two's complement signed integer.
610
853
  *
611
854
  * ```js
855
+ * import { Buffer } from 'buffer';
856
+ *
612
857
  * const buf = Buffer.allocUnsafe(8);
613
858
  *
614
859
  * buf.writeBigInt64BE(0x0102030405060708n, 0);
@@ -628,6 +873,8 @@ declare module 'buffer' {
628
873
  * `value` is interpreted and written as a two's complement signed integer.
629
874
  *
630
875
  * ```js
876
+ * import { Buffer } from 'buffer';
877
+ *
631
878
  * const buf = Buffer.allocUnsafe(8);
632
879
  *
633
880
  * buf.writeBigInt64LE(0x0102030405060708n, 0);
@@ -647,6 +894,8 @@ declare module 'buffer' {
647
894
  * This function is also available under the `writeBigUint64BE` alias.
648
895
  *
649
896
  * ```js
897
+ * import { Buffer } from 'buffer';
898
+ *
650
899
  * const buf = Buffer.allocUnsafe(8);
651
900
  *
652
901
  * buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
@@ -664,6 +913,8 @@ declare module 'buffer' {
664
913
  * Writes `value` to `buf` at the specified `offset` as little-endian
665
914
  *
666
915
  * ```js
916
+ * import { Buffer } from 'buffer';
917
+ *
667
918
  * const buf = Buffer.allocUnsafe(8);
668
919
  *
669
920
  * buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
@@ -686,6 +937,8 @@ declare module 'buffer' {
686
937
  * This function is also available under the `writeUintLE` alias.
687
938
  *
688
939
  * ```js
940
+ * import { Buffer } from 'buffer';
941
+ *
689
942
  * const buf = Buffer.allocUnsafe(6);
690
943
  *
691
944
  * buf.writeUIntLE(0x1234567890ab, 0, 6);
@@ -707,6 +960,8 @@ declare module 'buffer' {
707
960
  * This function is also available under the `writeUintBE` alias.
708
961
  *
709
962
  * ```js
963
+ * import { Buffer } from 'buffer';
964
+ *
710
965
  * const buf = Buffer.allocUnsafe(6);
711
966
  *
712
967
  * buf.writeUIntBE(0x1234567890ab, 0, 6);
@@ -726,6 +981,8 @@ declare module 'buffer' {
726
981
  * when `value` is anything other than a signed integer.
727
982
  *
728
983
  * ```js
984
+ * import { Buffer } from 'buffer';
985
+ *
729
986
  * const buf = Buffer.allocUnsafe(6);
730
987
  *
731
988
  * buf.writeIntLE(0x1234567890ab, 0, 6);
@@ -745,6 +1002,8 @@ declare module 'buffer' {
745
1002
  * signed integer.
746
1003
  *
747
1004
  * ```js
1005
+ * import { Buffer } from 'buffer';
1006
+ *
748
1007
  * const buf = Buffer.allocUnsafe(6);
749
1008
  *
750
1009
  * buf.writeIntBE(0x1234567890ab, 0, 6);
@@ -765,6 +1024,8 @@ declare module 'buffer' {
765
1024
  * This function is also available under the `readBigUint64BE` alias.
766
1025
  *
767
1026
  * ```js
1027
+ * import { Buffer } from 'buffer';
1028
+ *
768
1029
  * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
769
1030
  *
770
1031
  * console.log(buf.readBigUInt64BE(0));
@@ -780,6 +1041,8 @@ declare module 'buffer' {
780
1041
  * This function is also available under the `readBigUint64LE` alias.
781
1042
  *
782
1043
  * ```js
1044
+ * import { Buffer } from 'buffer';
1045
+ *
783
1046
  * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
784
1047
  *
785
1048
  * console.log(buf.readBigUInt64LE(0));
@@ -814,6 +1077,8 @@ declare module 'buffer' {
814
1077
  * This function is also available under the `readUintLE` alias.
815
1078
  *
816
1079
  * ```js
1080
+ * import { Buffer } from 'buffer';
1081
+ *
817
1082
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
818
1083
  *
819
1084
  * console.log(buf.readUIntLE(0, 6).toString(16));
@@ -831,6 +1096,8 @@ declare module 'buffer' {
831
1096
  * This function is also available under the `readUintBE` alias.
832
1097
  *
833
1098
  * ```js
1099
+ * import { Buffer } from 'buffer';
1100
+ *
834
1101
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
835
1102
  *
836
1103
  * console.log(buf.readUIntBE(0, 6).toString(16));
@@ -848,6 +1115,8 @@ declare module 'buffer' {
848
1115
  * supporting up to 48 bits of accuracy.
849
1116
  *
850
1117
  * ```js
1118
+ * import { Buffer } from 'buffer';
1119
+ *
851
1120
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
852
1121
  *
853
1122
  * console.log(buf.readIntLE(0, 6).toString(16));
@@ -863,6 +1132,8 @@ declare module 'buffer' {
863
1132
  * supporting up to 48 bits of accuracy.
864
1133
  *
865
1134
  * ```js
1135
+ * import { Buffer } from 'buffer';
1136
+ *
866
1137
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
867
1138
  *
868
1139
  * console.log(buf.readIntBE(0, 6).toString(16));
@@ -883,6 +1154,8 @@ declare module 'buffer' {
883
1154
  * This function is also available under the `readUint8` alias.
884
1155
  *
885
1156
  * ```js
1157
+ * import { Buffer } from 'buffer';
1158
+ *
886
1159
  * const buf = Buffer.from([1, -2]);
887
1160
  *
888
1161
  * console.log(buf.readUInt8(0));
@@ -902,6 +1175,8 @@ declare module 'buffer' {
902
1175
  * This function is also available under the `readUint16LE` alias.
903
1176
  *
904
1177
  * ```js
1178
+ * import { Buffer } from 'buffer';
1179
+ *
905
1180
  * const buf = Buffer.from([0x12, 0x34, 0x56]);
906
1181
  *
907
1182
  * console.log(buf.readUInt16LE(0).toString(16));
@@ -921,6 +1196,8 @@ declare module 'buffer' {
921
1196
  * This function is also available under the `readUint16BE` alias.
922
1197
  *
923
1198
  * ```js
1199
+ * import { Buffer } from 'buffer';
1200
+ *
924
1201
  * const buf = Buffer.from([0x12, 0x34, 0x56]);
925
1202
  *
926
1203
  * console.log(buf.readUInt16BE(0).toString(16));
@@ -938,6 +1215,8 @@ declare module 'buffer' {
938
1215
  * This function is also available under the `readUint32LE` alias.
939
1216
  *
940
1217
  * ```js
1218
+ * import { Buffer } from 'buffer';
1219
+ *
941
1220
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
942
1221
  *
943
1222
  * console.log(buf.readUInt32LE(0).toString(16));
@@ -955,6 +1234,8 @@ declare module 'buffer' {
955
1234
  * This function is also available under the `readUint32BE` alias.
956
1235
  *
957
1236
  * ```js
1237
+ * import { Buffer } from 'buffer';
1238
+ *
958
1239
  * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
959
1240
  *
960
1241
  * console.log(buf.readUInt32BE(0).toString(16));
@@ -970,6 +1251,8 @@ declare module 'buffer' {
970
1251
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
971
1252
  *
972
1253
  * ```js
1254
+ * import { Buffer } from 'buffer';
1255
+ *
973
1256
  * const buf = Buffer.from([-1, 5]);
974
1257
  *
975
1258
  * console.log(buf.readInt8(0));
@@ -989,6 +1272,8 @@ declare module 'buffer' {
989
1272
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
990
1273
  *
991
1274
  * ```js
1275
+ * import { Buffer } from 'buffer';
1276
+ *
992
1277
  * const buf = Buffer.from([0, 5]);
993
1278
  *
994
1279
  * console.log(buf.readInt16LE(0));
@@ -1006,6 +1291,8 @@ declare module 'buffer' {
1006
1291
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1007
1292
  *
1008
1293
  * ```js
1294
+ * import { Buffer } from 'buffer';
1295
+ *
1009
1296
  * const buf = Buffer.from([0, 5]);
1010
1297
  *
1011
1298
  * console.log(buf.readInt16BE(0));
@@ -1021,6 +1308,8 @@ declare module 'buffer' {
1021
1308
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1022
1309
  *
1023
1310
  * ```js
1311
+ * import { Buffer } from 'buffer';
1312
+ *
1024
1313
  * const buf = Buffer.from([0, 0, 0, 5]);
1025
1314
  *
1026
1315
  * console.log(buf.readInt32LE(0));
@@ -1038,6 +1327,8 @@ declare module 'buffer' {
1038
1327
  * Integers read from a `Buffer` are interpreted as two's complement signed values.
1039
1328
  *
1040
1329
  * ```js
1330
+ * import { Buffer } from 'buffer';
1331
+ *
1041
1332
  * const buf = Buffer.from([0, 0, 0, 5]);
1042
1333
  *
1043
1334
  * console.log(buf.readInt32BE(0));
@@ -1051,6 +1342,8 @@ declare module 'buffer' {
1051
1342
  * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
1052
1343
  *
1053
1344
  * ```js
1345
+ * import { Buffer } from 'buffer';
1346
+ *
1054
1347
  * const buf = Buffer.from([1, 2, 3, 4]);
1055
1348
  *
1056
1349
  * console.log(buf.readFloatLE(0));
@@ -1066,6 +1359,8 @@ declare module 'buffer' {
1066
1359
  * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
1067
1360
  *
1068
1361
  * ```js
1362
+ * import { Buffer } from 'buffer';
1363
+ *
1069
1364
  * const buf = Buffer.from([1, 2, 3, 4]);
1070
1365
  *
1071
1366
  * console.log(buf.readFloatBE(0));
@@ -1079,6 +1374,8 @@ declare module 'buffer' {
1079
1374
  * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
1080
1375
  *
1081
1376
  * ```js
1377
+ * import { Buffer } from 'buffer';
1378
+ *
1082
1379
  * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1083
1380
  *
1084
1381
  * console.log(buf.readDoubleLE(0));
@@ -1094,6 +1391,8 @@ declare module 'buffer' {
1094
1391
  * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
1095
1392
  *
1096
1393
  * ```js
1394
+ * import { Buffer } from 'buffer';
1395
+ *
1097
1396
  * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1098
1397
  *
1099
1398
  * console.log(buf.readDoubleBE(0));
@@ -1109,6 +1408,8 @@ declare module 'buffer' {
1109
1408
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
1110
1409
  *
1111
1410
  * ```js
1411
+ * import { Buffer } from 'buffer';
1412
+ *
1112
1413
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1113
1414
  *
1114
1415
  * console.log(buf1);
@@ -1129,6 +1430,8 @@ declare module 'buffer' {
1129
1430
  * between UTF-16 little-endian and UTF-16 big-endian:
1130
1431
  *
1131
1432
  * ```js
1433
+ * import { Buffer } from 'buffer';
1434
+ *
1132
1435
  * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1133
1436
  * buf.swap16(); // Convert to big-endian UTF-16 text.
1134
1437
  * ```
@@ -1141,6 +1444,8 @@ declare module 'buffer' {
1141
1444
  * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
1142
1445
  *
1143
1446
  * ```js
1447
+ * import { Buffer } from 'buffer';
1448
+ *
1144
1449
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1145
1450
  *
1146
1451
  * console.log(buf1);
@@ -1165,6 +1470,8 @@ declare module 'buffer' {
1165
1470
  * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
1166
1471
  *
1167
1472
  * ```js
1473
+ * import { Buffer } from 'buffer';
1474
+ *
1168
1475
  * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1169
1476
  *
1170
1477
  * console.log(buf1);
@@ -1192,6 +1499,8 @@ declare module 'buffer' {
1192
1499
  * This function is also available under the `writeUint8` alias.
1193
1500
  *
1194
1501
  * ```js
1502
+ * import { Buffer } from 'buffer';
1503
+ *
1195
1504
  * const buf = Buffer.allocUnsafe(4);
1196
1505
  *
1197
1506
  * buf.writeUInt8(0x3, 0);
@@ -1215,6 +1524,8 @@ declare module 'buffer' {
1215
1524
  * This function is also available under the `writeUint16LE` alias.
1216
1525
  *
1217
1526
  * ```js
1527
+ * import { Buffer } from 'buffer';
1528
+ *
1218
1529
  * const buf = Buffer.allocUnsafe(4);
1219
1530
  *
1220
1531
  * buf.writeUInt16LE(0xdead, 0);
@@ -1236,6 +1547,8 @@ declare module 'buffer' {
1236
1547
  * This function is also available under the `writeUint16BE` alias.
1237
1548
  *
1238
1549
  * ```js
1550
+ * import { Buffer } from 'buffer';
1551
+ *
1239
1552
  * const buf = Buffer.allocUnsafe(4);
1240
1553
  *
1241
1554
  * buf.writeUInt16BE(0xdead, 0);
@@ -1257,6 +1570,8 @@ declare module 'buffer' {
1257
1570
  * This function is also available under the `writeUint32LE` alias.
1258
1571
  *
1259
1572
  * ```js
1573
+ * import { Buffer } from 'buffer';
1574
+ *
1260
1575
  * const buf = Buffer.allocUnsafe(4);
1261
1576
  *
1262
1577
  * buf.writeUInt32LE(0xfeedface, 0);
@@ -1277,6 +1592,8 @@ declare module 'buffer' {
1277
1592
  * This function is also available under the `writeUint32BE` alias.
1278
1593
  *
1279
1594
  * ```js
1595
+ * import { Buffer } from 'buffer';
1596
+ *
1280
1597
  * const buf = Buffer.allocUnsafe(4);
1281
1598
  *
1282
1599
  * buf.writeUInt32BE(0xfeedface, 0);
@@ -1298,6 +1615,8 @@ declare module 'buffer' {
1298
1615
  * `value` is interpreted and written as a two's complement signed integer.
1299
1616
  *
1300
1617
  * ```js
1618
+ * import { Buffer } from 'buffer';
1619
+ *
1301
1620
  * const buf = Buffer.allocUnsafe(2);
1302
1621
  *
1303
1622
  * buf.writeInt8(2, 0);
@@ -1319,6 +1638,8 @@ declare module 'buffer' {
1319
1638
  * The `value` is interpreted and written as a two's complement signed integer.
1320
1639
  *
1321
1640
  * ```js
1641
+ * import { Buffer } from 'buffer';
1642
+ *
1322
1643
  * const buf = Buffer.allocUnsafe(2);
1323
1644
  *
1324
1645
  * buf.writeInt16LE(0x0304, 0);
@@ -1339,6 +1660,8 @@ declare module 'buffer' {
1339
1660
  * The `value` is interpreted and written as a two's complement signed integer.
1340
1661
  *
1341
1662
  * ```js
1663
+ * import { Buffer } from 'buffer';
1664
+ *
1342
1665
  * const buf = Buffer.allocUnsafe(2);
1343
1666
  *
1344
1667
  * buf.writeInt16BE(0x0102, 0);
@@ -1359,6 +1682,8 @@ declare module 'buffer' {
1359
1682
  * The `value` is interpreted and written as a two's complement signed integer.
1360
1683
  *
1361
1684
  * ```js
1685
+ * import { Buffer } from 'buffer';
1686
+ *
1362
1687
  * const buf = Buffer.allocUnsafe(4);
1363
1688
  *
1364
1689
  * buf.writeInt32LE(0x05060708, 0);
@@ -1379,6 +1704,8 @@ declare module 'buffer' {
1379
1704
  * The `value` is interpreted and written as a two's complement signed integer.
1380
1705
  *
1381
1706
  * ```js
1707
+ * import { Buffer } from 'buffer';
1708
+ *
1382
1709
  * const buf = Buffer.allocUnsafe(4);
1383
1710
  *
1384
1711
  * buf.writeInt32BE(0x01020304, 0);
@@ -1397,6 +1724,8 @@ declare module 'buffer' {
1397
1724
  * undefined when `value` is anything other than a JavaScript number.
1398
1725
  *
1399
1726
  * ```js
1727
+ * import { Buffer } from 'buffer';
1728
+ *
1400
1729
  * const buf = Buffer.allocUnsafe(4);
1401
1730
  *
1402
1731
  * buf.writeFloatLE(0xcafebabe, 0);
@@ -1415,6 +1744,8 @@ declare module 'buffer' {
1415
1744
  * undefined when `value` is anything other than a JavaScript number.
1416
1745
  *
1417
1746
  * ```js
1747
+ * import { Buffer } from 'buffer';
1748
+ *
1418
1749
  * const buf = Buffer.allocUnsafe(4);
1419
1750
  *
1420
1751
  * buf.writeFloatBE(0xcafebabe, 0);
@@ -1433,6 +1764,8 @@ declare module 'buffer' {
1433
1764
  * other than a JavaScript number.
1434
1765
  *
1435
1766
  * ```js
1767
+ * import { Buffer } from 'buffer';
1768
+ *
1436
1769
  * const buf = Buffer.allocUnsafe(8);
1437
1770
  *
1438
1771
  * buf.writeDoubleLE(123.456, 0);
@@ -1451,6 +1784,8 @@ declare module 'buffer' {
1451
1784
  * other than a JavaScript number.
1452
1785
  *
1453
1786
  * ```js
1787
+ * import { Buffer } from 'buffer';
1788
+ *
1454
1789
  * const buf = Buffer.allocUnsafe(8);
1455
1790
  *
1456
1791
  * buf.writeDoubleBE(123.456, 0);
@@ -1469,6 +1804,8 @@ declare module 'buffer' {
1469
1804
  * the entire `buf` will be filled:
1470
1805
  *
1471
1806
  * ```js
1807
+ * import { Buffer } from 'buffer';
1808
+ *
1472
1809
  * // Fill a `Buffer` with the ASCII character 'h'.
1473
1810
  *
1474
1811
  * const b = Buffer.allocUnsafe(50).fill('h');
@@ -1485,6 +1822,8 @@ declare module 'buffer' {
1485
1822
  * then only the bytes of that character that fit into `buf` are written:
1486
1823
  *
1487
1824
  * ```js
1825
+ * import { Buffer } from 'buffer';
1826
+ *
1488
1827
  * // Fill a `Buffer` with character that takes up two bytes in UTF-8.
1489
1828
  *
1490
1829
  * console.log(Buffer.allocUnsafe(5).fill('\u0222'));
@@ -1495,6 +1834,8 @@ declare module 'buffer' {
1495
1834
  * fill data remains, an exception is thrown:
1496
1835
  *
1497
1836
  * ```js
1837
+ * import { Buffer } from 'buffer';
1838
+ *
1498
1839
  * const buf = Buffer.allocUnsafe(5);
1499
1840
  *
1500
1841
  * console.log(buf.fill('a'));
@@ -1522,6 +1863,8 @@ declare module 'buffer' {
1522
1863
  * value between `0` and `255`.
1523
1864
  *
1524
1865
  * ```js
1866
+ * import { Buffer } from 'buffer';
1867
+ *
1525
1868
  * const buf = Buffer.from('this is a buffer');
1526
1869
  *
1527
1870
  * console.log(buf.indexOf('this'));
@@ -1553,6 +1896,8 @@ declare module 'buffer' {
1553
1896
  * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
1554
1897
  *
1555
1898
  * ```js
1899
+ * import { Buffer } from 'buffer';
1900
+ *
1556
1901
  * const b = Buffer.from('abcdef');
1557
1902
  *
1558
1903
  * // Passing a value that's a number, but not a valid byte.
@@ -1582,6 +1927,8 @@ declare module 'buffer' {
1582
1927
  * rather than the first occurrence.
1583
1928
  *
1584
1929
  * ```js
1930
+ * import { Buffer } from 'buffer';
1931
+ *
1585
1932
  * const buf = Buffer.from('this buffer is a buffer');
1586
1933
  *
1587
1934
  * console.log(buf.lastIndexOf('this'));
@@ -1615,6 +1962,8 @@ declare module 'buffer' {
1615
1962
  * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
1616
1963
  *
1617
1964
  * ```js
1965
+ * import { Buffer } from 'buffer';
1966
+ *
1618
1967
  * const b = Buffer.from('abcdef');
1619
1968
  *
1620
1969
  * // Passing a value that's a number, but not a valid byte.
@@ -1646,6 +1995,8 @@ declare module 'buffer' {
1646
1995
  * of `buf`.
1647
1996
  *
1648
1997
  * ```js
1998
+ * import { Buffer } from 'buffer';
1999
+ *
1649
2000
  * // Log the entire contents of a `Buffer`.
1650
2001
  *
1651
2002
  * const buf = Buffer.from('buffer');
@@ -1668,6 +2019,8 @@ declare module 'buffer' {
1668
2019
  * Equivalent to `buf.indexOf() !== -1`.
1669
2020
  *
1670
2021
  * ```js
2022
+ * import { Buffer } from 'buffer';
2023
+ *
1671
2024
  * const buf = Buffer.from('this is a buffer');
1672
2025
  *
1673
2026
  * console.log(buf.includes('this'));
@@ -1696,6 +2049,8 @@ declare module 'buffer' {
1696
2049
  * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
1697
2050
  *
1698
2051
  * ```js
2052
+ * import { Buffer } from 'buffer';
2053
+ *
1699
2054
  * const buf = Buffer.from('buffer');
1700
2055
  *
1701
2056
  * for (const key of buf.keys()) {
@@ -1717,6 +2072,8 @@ declare module 'buffer' {
1717
2072
  * called automatically when a `Buffer` is used in a `for..of` statement.
1718
2073
  *
1719
2074
  * ```js
2075
+ * import { Buffer } from 'buffer';
2076
+ *
1720
2077
  * const buf = Buffer.from('buffer');
1721
2078
  *
1722
2079
  * for (const value of buf.values()) {