UNPKG

83.8 kBTypeScriptView Raw
1/**
2 * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
3 * Node.js APIs support `Buffer`s.
4 *
5 * The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and
6 * extends it with methods that cover additional use cases. Node.js APIs accept
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 *
9 * The `Buffer` class is within the global scope, making it unlikely that one
10 * would need to ever use `require('buffer').Buffer`.
11 *
12 * ```js
13 * // Creates a zero-filled Buffer of length 10.
14 * const buf1 = Buffer.alloc(10);
15 *
16 * // Creates a Buffer of length 10,
17 * // filled with bytes which all have the value `1`.
18 * const buf2 = Buffer.alloc(10, 1);
19 *
20 * // Creates an uninitialized buffer of length 10.
21 * // This is faster than calling Buffer.alloc() but the returned
22 * // Buffer instance might contain old data that needs to be
23 * // overwritten using fill(), write(), or other functions that fill the Buffer's
24 * // contents.
25 * const buf3 = Buffer.allocUnsafe(10);
26 *
27 * // Creates a Buffer containing the bytes [1, 2, 3].
28 * const buf4 = Buffer.from([1, 2, 3]);
29 *
30 * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
31 * // are all truncated using `(value & 255)` to fit into the range 0–255.
32 * const buf5 = Buffer.from([257, 257.5, -255, '1']);
33 *
34 * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
35 * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
36 * // [116, 195, 169, 115, 116] (in decimal notation)
37 * const buf6 = Buffer.from('tést');
38 *
39 * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
40 * const buf7 = Buffer.from('tést', 'latin1');
41 * ```
42 * @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/buffer.js)
43 */
44declare module 'buffer' {
45 import { BinaryLike } from 'node:crypto';
46 export const INSPECT_MAX_BYTES: number;
47 export const kMaxLength: number;
48 export const kStringMaxLength: number;
49 export const constants: {
50 MAX_LENGTH: number;
51 MAX_STRING_LENGTH: number;
52 };
53 export type TranscodeEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'latin1' | 'binary';
54 /**
55 * Re-encodes the given `Buffer` or `Uint8Array` instance from one character
56 * encoding to another. Returns a new `Buffer` instance.
57 *
58 * Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if
59 * conversion from `fromEnc` to `toEnc` is not permitted.
60 *
61 * Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
62 *
63 * The transcoding process will use substitution characters if a given byte
64 * sequence cannot be adequately represented in the target encoding. For instance:
65 *
66 * ```js
67 * const buffer = require('buffer');
68 *
69 * const newBuf = buffer.transcode(Buffer.from('€'), 'utf8', 'ascii');
70 * console.log(newBuf.toString('ascii'));
71 * // Prints: '?'
72 * ```
73 *
74 * Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced
75 * with `?` in the transcoded `Buffer`.
76 * @since v7.1.0
77 * @param source A `Buffer` or `Uint8Array` instance.
78 * @param fromEnc The current encoding.
79 * @param toEnc To target encoding.
80 */
81 export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
82 export const SlowBuffer: {
83 /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
84 new (size: number): Buffer;
85 prototype: Buffer;
86 };
87 export { Buffer };
88 /**
89 * @experimental
90 */
91 export interface BlobOptions {
92 /**
93 * @default 'utf8'
94 */
95 encoding?: BufferEncoding | undefined;
96 /**
97 * The Blob content-type. The intent is for `type` to convey
98 * the MIME media type of the data, however no validation of the type format
99 * is performed.
100 */
101 type?: string | undefined;
102 }
103 /**
104 * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
105 * multiple worker threads.
106 * @since v15.7.0
107 * @experimental
108 */
109 export class Blob {
110 /**
111 * The total size of the `Blob` in bytes.
112 * @since v15.7.0
113 */
114 readonly size: number;
115 /**
116 * The content-type of the `Blob`.
117 * @since v15.7.0
118 */
119 readonly type: string;
120 /**
121 * Creates a new `Blob` object containing a concatenation of the given sources.
122 *
123 * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into
124 * the 'Blob' and can therefore be safely modified after the 'Blob' is created.
125 *
126 * String sources are also copied into the `Blob`.
127 */
128 constructor(sources: Array<BinaryLike | Blob>, options?: BlobOptions);
129 /**
130 * Returns a promise that fulfills with an [&lt;ArrayBuffer&gt;](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of
131 * the `Blob` data.
132 * @since v15.7.0
133 */
134 arrayBuffer(): Promise<ArrayBuffer>;
135 /**
136 * Creates and returns a new `Blob` containing a subset of this `Blob` objects
137 * data. The original `Blob` is not altered.
138 * @since v15.7.0
139 * @param start The starting index.
140 * @param end The ending index.
141 * @param type The content-type for the new `Blob`
142 */
143 slice(start?: number, end?: number, type?: string): Blob;
144 /**
145 * Returns a promise that resolves the contents of the `Blob` decoded as a UTF-8
146 * string.
147 * @since v15.7.0
148 */
149 text(): Promise<string>;
150 }
151 export import atob = globalThis.atob;
152 export import btoa = globalThis.btoa;
153 global {
154 // Buffer class
155 type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
156 type WithImplicitCoercion<T> =
157 | T
158 | {
159 valueOf(): T;
160 };
161 /**
162 * Raw data is stored in instances of the Buffer class.
163 * 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.
164 * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
165 */
166 interface BufferConstructor {
167 /**
168 * Allocates a new buffer containing the given {str}.
169 *
170 * @param str String to store in buffer.
171 * @param encoding encoding to use, optional. Default is 'utf8'
172 * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
173 */
174 new (str: string, encoding?: BufferEncoding): Buffer;
175 /**
176 * Allocates a new buffer of {size} octets.
177 *
178 * @param size count of octets to allocate.
179 * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
180 */
181 new (size: number): Buffer;
182 /**
183 * Allocates a new buffer containing the given {array} of octets.
184 *
185 * @param array The octets to store.
186 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
187 */
188 new (array: Uint8Array): Buffer;
189 /**
190 * Produces a Buffer backed by the same allocated memory as
191 * the given {ArrayBuffer}/{SharedArrayBuffer}.
192 *
193 *
194 * @param arrayBuffer The ArrayBuffer with which to share memory.
195 * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
196 */
197 new (arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
198 /**
199 * Allocates a new buffer containing the given {array} of octets.
200 *
201 * @param array The octets to store.
202 * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
203 */
204 new (array: ReadonlyArray<any>): Buffer;
205 /**
206 * Copies the passed {buffer} data onto a new {Buffer} instance.
207 *
208 * @param buffer The buffer to copy.
209 * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
210 */
211 new (buffer: Buffer): Buffer;
212 /**
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.
217 *
218 * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
219 */
220 from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
221 /**
222 * Creates a new Buffer using the passed {data}
223 * @param data data to create a new Buffer
224 */
225 from(data: Uint8Array | ReadonlyArray<number>): Buffer;
226 from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
227 /**
228 * Creates a new Buffer containing the given JavaScript string {str}.
229 * If provided, the {encoding} parameter identifies the character encoding.
230 * If not provided, {encoding} defaults to 'utf8'.
231 */
232 from(
233 str:
234 | WithImplicitCoercion<string>
235 | {
236 [Symbol.toPrimitive](hint: 'string'): string;
237 },
238 encoding?: BufferEncoding
239 ): Buffer;
240 /**
241 * Creates a new Buffer using the passed {data}
242 * @param values to create a new Buffer
243 */
244 of(...items: number[]): Buffer;
245 /**
246 * Returns true if {obj} is a Buffer
247 *
248 * @param obj object to test.
249 */
250 isBuffer(obj: any): obj is Buffer;
251 /**
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'
254 *
255 * @param encoding string to test.
256 */
257 isEncoding(encoding: string): encoding is BufferEncoding;
258 /**
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.
261 *
262 * @param string string to test.
263 * @param encoding encoding used to evaluate (defaults to 'utf8')
264 */
265 byteLength(string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer, encoding?: BufferEncoding): number;
266 /**
267 * Returns a buffer which is the result of concatenating all the buffers in the list together.
268 *
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.
272 *
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.
276 */
277 concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
278 /**
279 * The same as buf1.compare(buf2).
280 */
281 compare(buf1: Uint8Array, buf2: Uint8Array): number;
282 /**
283 * Allocates a new buffer of {size} octets.
284 *
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
289 */
290 alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
291 /**
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.
294 *
295 * @param size count of octets to allocate
296 */
297 allocUnsafe(size: number): Buffer;
298 /**
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.
301 *
302 * @param size count of octets to allocate
303 */
304 allocUnsafeSlow(size: number): Buffer;
305 /**
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.
307 */
308 poolSize: number;
309 }
310 interface Buffer extends Uint8Array {
311 /**
312 * 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
313 * not contain enough space to fit the entire string, only part of `string` will be
314 * written. However, partially encoded characters will not be written.
315 *
316 * ```js
317 * const buf = Buffer.alloc(256);
318 *
319 * const len = buf.write('\u00bd + \u00bc = \u00be', 0);
320 *
321 * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
322 * // Prints: 12 bytes: ½ + ¼ = ¾
323 *
324 * const buffer = Buffer.alloc(10);
325 *
326 * const length = buffer.write('abcd', 8);
327 *
328 * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
329 * // Prints: 2 bytes : ab
330 * ```
331 * @since v0.1.90
332 * @param string String to write to `buf`.
333 * @param [offset=0] Number of bytes to skip before starting to write `string`.
334 * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
335 * @param [encoding='utf8'] The character encoding of `string`.
336 * @return Number of bytes written.
337 */
338 write(string: string, encoding?: BufferEncoding): number;
339 write(string: string, offset: number, encoding?: BufferEncoding): number;
340 write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
341 /**
342 * Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.
343 *
344 * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
345 * then each invalid byte is replaced with the replacement character `U+FFFD`.
346 *
347 * The maximum length of a string instance (in UTF-16 code units) is available
348 * as {@link constants.MAX_STRING_LENGTH}.
349 *
350 * ```js
351 * const buf1 = Buffer.allocUnsafe(26);
352 *
353 * for (let i = 0; i < 26; i++) {
354 * // 97 is the decimal ASCII value for 'a'.
355 * buf1[i] = i + 97;
356 * }
357 *
358 * console.log(buf1.toString('utf8'));
359 * // Prints: abcdefghijklmnopqrstuvwxyz
360 * console.log(buf1.toString('utf8', 0, 5));
361 * // Prints: abcde
362 *
363 * const buf2 = Buffer.from('tést');
364 *
365 * console.log(buf2.toString('hex'));
366 * // Prints: 74c3a97374
367 * console.log(buf2.toString('utf8', 0, 3));
368 * // Prints: té
369 * console.log(buf2.toString(undefined, 0, 3));
370 * // Prints: té
371 * ```
372 * @since v0.1.90
373 * @param [encoding='utf8'] The character encoding to use.
374 * @param [start=0] The byte offset to start decoding at.
375 * @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
376 */
377 toString(encoding?: BufferEncoding, start?: number, end?: number): string;
378 /**
379 * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls
380 * this function when stringifying a `Buffer` instance.
381 *
382 * `Buffer.from()` accepts objects in the format returned from this method.
383 * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
384 *
385 * ```js
386 * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
387 * const json = JSON.stringify(buf);
388 *
389 * console.log(json);
390 * // Prints: {"type":"Buffer","data":[1,2,3,4,5]}
391 *
392 * const copy = JSON.parse(json, (key, value) => {
393 * return value &#x26;&#x26; value.type === 'Buffer' ?
394 * Buffer.from(value) :
395 * value;
396 * });
397 *
398 * console.log(copy);
399 * // Prints: <Buffer 01 02 03 04 05>
400 * ```
401 * @since v0.9.2
402 */
403 toJSON(): {
404 type: 'Buffer';
405 data: number[];
406 };
407 /**
408 * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
409 *
410 * ```js
411 * const buf1 = Buffer.from('ABC');
412 * const buf2 = Buffer.from('414243', 'hex');
413 * const buf3 = Buffer.from('ABCD');
414 *
415 * console.log(buf1.equals(buf2));
416 * // Prints: true
417 * console.log(buf1.equals(buf3));
418 * // Prints: false
419 * ```
420 * @since v0.11.13
421 * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.
422 */
423 equals(otherBuffer: Uint8Array): boolean;
424 /**
425 * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.
426 * Comparison is based on the actual sequence of bytes in each `Buffer`.
427 *
428 * * `0` is returned if `target` is the same as `buf`
429 * * `1` is returned if `target` should come _before_`buf` when sorted.
430 * * `-1` is returned if `target` should come _after_`buf` when sorted.
431 *
432 * ```js
433 * const buf1 = Buffer.from('ABC');
434 * const buf2 = Buffer.from('BCD');
435 * const buf3 = Buffer.from('ABCD');
436 *
437 * console.log(buf1.compare(buf1));
438 * // Prints: 0
439 * console.log(buf1.compare(buf2));
440 * // Prints: -1
441 * console.log(buf1.compare(buf3));
442 * // Prints: -1
443 * console.log(buf2.compare(buf1));
444 * // Prints: 1
445 * console.log(buf2.compare(buf3));
446 * // Prints: 1
447 * console.log([buf1, buf2, buf3].sort(Buffer.compare));
448 * // Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]
449 * // (This result is equal to: [buf1, buf3, buf2].)
450 * ```
451 *
452 * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
453 *
454 * ```js
455 * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
456 * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
457 *
458 * console.log(buf1.compare(buf2, 5, 9, 0, 4));
459 * // Prints: 0
460 * console.log(buf1.compare(buf2, 0, 6, 4));
461 * // Prints: -1
462 * console.log(buf1.compare(buf2, 5, 6, 5));
463 * // Prints: 1
464 * ```
465 *
466 * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
467 * @since v0.11.13
468 * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
469 * @param [targetStart=0] The offset within `target` at which to begin comparison.
470 * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).
471 * @param [sourceStart=0] The offset within `buf` at which to begin comparison.
472 * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
473 */
474 compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
475 /**
476 * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
477 *
478 * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
479 * for all TypedArrays, including Node.js `Buffer`s, although it takes
480 * different function arguments.
481 *
482 * ```js
483 * // Create two `Buffer` instances.
484 * const buf1 = Buffer.allocUnsafe(26);
485 * const buf2 = Buffer.allocUnsafe(26).fill('!');
486 *
487 * for (let i = 0; i < 26; i++) {
488 * // 97 is the decimal ASCII value for 'a'.
489 * buf1[i] = i + 97;
490 * }
491 *
492 * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
493 * buf1.copy(buf2, 8, 16, 20);
494 * // This is equivalent to:
495 * // buf2.set(buf1.subarray(16, 20), 8);
496 *
497 * console.log(buf2.toString('ascii', 0, 25));
498 * // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
499 * ```
500 *
501 * ```js
502 * // Create a `Buffer` and copy data from one region to an overlapping region
503 * // within the same `Buffer`.
504 *
505 * const buf = Buffer.allocUnsafe(26);
506 *
507 * for (let i = 0; i < 26; i++) {
508 * // 97 is the decimal ASCII value for 'a'.
509 * buf[i] = i + 97;
510 * }
511 *
512 * buf.copy(buf, 0, 4, 10);
513 *
514 * console.log(buf.toString());
515 * // Prints: efghijghijklmnopqrstuvwxyz
516 * ```
517 * @since v0.1.90
518 * @param target A `Buffer` or {@link Uint8Array} to copy into.
519 * @param [targetStart=0] The offset within `target` at which to begin writing.
520 * @param [sourceStart=0] The offset within `buf` from which to begin copying.
521 * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
522 * @return The number of bytes copied.
523 */
524 copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
525 /**
526 * Returns a new `Buffer` that references the same memory as the original, but
527 * offset and cropped by the `start` and `end` indices.
528 *
529 * This is the same behavior as `buf.subarray()`.
530 *
531 * This method is not compatible with the `Uint8Array.prototype.slice()`,
532 * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
533 *
534 * ```js
535 * const buf = Buffer.from('buffer');
536 *
537 * const copiedBuf = Uint8Array.prototype.slice.call(buf);
538 * copiedBuf[0]++;
539 * console.log(copiedBuf.toString());
540 * // Prints: cuffer
541 *
542 * console.log(buf.toString());
543 * // Prints: buffer
544 * ```
545 * @since v0.3.0
546 * @param [start=0] Where the new `Buffer` will start.
547 * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
548 */
549 slice(start?: number, end?: number): Buffer;
550 /**
551 * Returns a new `Buffer` that references the same memory as the original, but
552 * offset and cropped by the `start` and `end` indices.
553 *
554 * Specifying `end` greater than `buf.length` will return the same result as
555 * that of `end` equal to `buf.length`.
556 *
557 * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
558 *
559 * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
560 *
561 * ```js
562 * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
563 * // from the original `Buffer`.
564 *
565 * const buf1 = Buffer.allocUnsafe(26);
566 *
567 * for (let i = 0; i < 26; i++) {
568 * // 97 is the decimal ASCII value for 'a'.
569 * buf1[i] = i + 97;
570 * }
571 *
572 * const buf2 = buf1.subarray(0, 3);
573 *
574 * console.log(buf2.toString('ascii', 0, buf2.length));
575 * // Prints: abc
576 *
577 * buf1[0] = 33;
578 *
579 * console.log(buf2.toString('ascii', 0, buf2.length));
580 * // Prints: !bc
581 * ```
582 *
583 * Specifying negative indexes causes the slice to be generated relative to the
584 * end of `buf` rather than the beginning.
585 *
586 * ```js
587 * const buf = Buffer.from('buffer');
588 *
589 * console.log(buf.subarray(-6, -1).toString());
590 * // Prints: buffe
591 * // (Equivalent to buf.subarray(0, 5).)
592 *
593 * console.log(buf.subarray(-6, -2).toString());
594 * // Prints: buff
595 * // (Equivalent to buf.subarray(0, 4).)
596 *
597 * console.log(buf.subarray(-5, -2).toString());
598 * // Prints: uff
599 * // (Equivalent to buf.subarray(1, 4).)
600 * ```
601 * @since v3.0.0
602 * @param [start=0] Where the new `Buffer` will start.
603 * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
604 */
605 subarray(start?: number, end?: number): Buffer;
606 /**
607 * Writes `value` to `buf` at the specified `offset` as big-endian.
608 *
609 * `value` is interpreted and written as a two's complement signed integer.
610 *
611 * ```js
612 * const buf = Buffer.allocUnsafe(8);
613 *
614 * buf.writeBigInt64BE(0x0102030405060708n, 0);
615 *
616 * console.log(buf);
617 * // Prints: <Buffer 01 02 03 04 05 06 07 08>
618 * ```
619 * @since v12.0.0, v10.20.0
620 * @param value Number to be written to `buf`.
621 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
622 * @return `offset` plus the number of bytes written.
623 */
624 writeBigInt64BE(value: bigint, offset?: number): number;
625 /**
626 * Writes `value` to `buf` at the specified `offset` as little-endian.
627 *
628 * `value` is interpreted and written as a two's complement signed integer.
629 *
630 * ```js
631 * const buf = Buffer.allocUnsafe(8);
632 *
633 * buf.writeBigInt64LE(0x0102030405060708n, 0);
634 *
635 * console.log(buf);
636 * // Prints: <Buffer 08 07 06 05 04 03 02 01>
637 * ```
638 * @since v12.0.0, v10.20.0
639 * @param value Number to be written to `buf`.
640 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
641 * @return `offset` plus the number of bytes written.
642 */
643 writeBigInt64LE(value: bigint, offset?: number): number;
644 /**
645 * Writes `value` to `buf` at the specified `offset` as big-endian.
646 *
647 * This function is also available under the `writeBigUint64BE` alias.
648 *
649 * ```js
650 * const buf = Buffer.allocUnsafe(8);
651 *
652 * buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
653 *
654 * console.log(buf);
655 * // Prints: <Buffer de ca fa fe ca ce fa de>
656 * ```
657 * @since v12.0.0, v10.20.0
658 * @param value Number to be written to `buf`.
659 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
660 * @return `offset` plus the number of bytes written.
661 */
662 writeBigUInt64BE(value: bigint, offset?: number): number;
663 /**
664 * Writes `value` to `buf` at the specified `offset` as little-endian
665 *
666 * ```js
667 * const buf = Buffer.allocUnsafe(8);
668 *
669 * buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
670 *
671 * console.log(buf);
672 * // Prints: <Buffer de fa ce ca fe fa ca de>
673 * ```
674 *
675 * This function is also available under the `writeBigUint64LE` alias.
676 * @since v12.0.0, v10.20.0
677 * @param value Number to be written to `buf`.
678 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
679 * @return `offset` plus the number of bytes written.
680 */
681 writeBigUInt64LE(value: bigint, offset?: number): number;
682 /**
683 * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
684 * when `value` is anything other than an unsigned integer.
685 *
686 * This function is also available under the `writeUintLE` alias.
687 *
688 * ```js
689 * const buf = Buffer.allocUnsafe(6);
690 *
691 * buf.writeUIntLE(0x1234567890ab, 0, 6);
692 *
693 * console.log(buf);
694 * // Prints: <Buffer ab 90 78 56 34 12>
695 * ```
696 * @since v0.5.5
697 * @param value Number to be written to `buf`.
698 * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
699 * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
700 * @return `offset` plus the number of bytes written.
701 */
702 writeUIntLE(value: number, offset: number, byteLength: number): number;
703 /**
704 * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
705 * when `value` is anything other than an unsigned integer.
706 *
707 * This function is also available under the `writeUintBE` alias.
708 *
709 * ```js
710 * const buf = Buffer.allocUnsafe(6);
711 *
712 * buf.writeUIntBE(0x1234567890ab, 0, 6);
713 *
714 * console.log(buf);
715 * // Prints: <Buffer 12 34 56 78 90 ab>
716 * ```
717 * @since v0.5.5
718 * @param value Number to be written to `buf`.
719 * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
720 * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
721 * @return `offset` plus the number of bytes written.
722 */
723 writeUIntBE(value: number, offset: number, byteLength: number): number;
724 /**
725 * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
726 * when `value` is anything other than a signed integer.
727 *
728 * ```js
729 * const buf = Buffer.allocUnsafe(6);
730 *
731 * buf.writeIntLE(0x1234567890ab, 0, 6);
732 *
733 * console.log(buf);
734 * // Prints: <Buffer ab 90 78 56 34 12>
735 * ```
736 * @since v0.11.15
737 * @param value Number to be written to `buf`.
738 * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
739 * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
740 * @return `offset` plus the number of bytes written.
741 */
742 writeIntLE(value: number, offset: number, byteLength: number): number;
743 /**
744 * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a
745 * signed integer.
746 *
747 * ```js
748 * const buf = Buffer.allocUnsafe(6);
749 *
750 * buf.writeIntBE(0x1234567890ab, 0, 6);
751 *
752 * console.log(buf);
753 * // Prints: <Buffer 12 34 56 78 90 ab>
754 * ```
755 * @since v0.11.15
756 * @param value Number to be written to `buf`.
757 * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
758 * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
759 * @return `offset` plus the number of bytes written.
760 */
761 writeIntBE(value: number, offset: number, byteLength: number): number;
762 /**
763 * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
764 *
765 * This function is also available under the `readBigUint64BE` alias.
766 *
767 * ```js
768 * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
769 *
770 * console.log(buf.readBigUInt64BE(0));
771 * // Prints: 4294967295n
772 * ```
773 * @since v12.0.0, v10.20.0
774 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
775 */
776 readBigUInt64BE(offset?: number): bigint;
777 /**
778 * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
779 *
780 * This function is also available under the `readBigUint64LE` alias.
781 *
782 * ```js
783 * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
784 *
785 * console.log(buf.readBigUInt64LE(0));
786 * // Prints: 18446744069414584320n
787 * ```
788 * @since v12.0.0, v10.20.0
789 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
790 */
791 readBigUInt64LE(offset?: number): bigint;
792 /**
793 * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
794 *
795 * Integers read from a `Buffer` are interpreted as two's complement signed
796 * values.
797 * @since v12.0.0, v10.20.0
798 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
799 */
800 readBigInt64BE(offset?: number): bigint;
801 /**
802 * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
803 *
804 * Integers read from a `Buffer` are interpreted as two's complement signed
805 * values.
806 * @since v12.0.0, v10.20.0
807 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
808 */
809 readBigInt64LE(offset?: number): bigint;
810 /**
811 * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting
812 * up to 48 bits of accuracy.
813 *
814 * This function is also available under the `readUintLE` alias.
815 *
816 * ```js
817 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
818 *
819 * console.log(buf.readUIntLE(0, 6).toString(16));
820 * // Prints: ab9078563412
821 * ```
822 * @since v0.11.15
823 * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
824 * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
825 */
826 readUIntLE(offset: number, byteLength: number): number;
827 /**
828 * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting
829 * up to 48 bits of accuracy.
830 *
831 * This function is also available under the `readUintBE` alias.
832 *
833 * ```js
834 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
835 *
836 * console.log(buf.readUIntBE(0, 6).toString(16));
837 * // Prints: 1234567890ab
838 * console.log(buf.readUIntBE(1, 6).toString(16));
839 * // Throws ERR_OUT_OF_RANGE.
840 * ```
841 * @since v0.11.15
842 * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
843 * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
844 */
845 readUIntBE(offset: number, byteLength: number): number;
846 /**
847 * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value
848 * supporting up to 48 bits of accuracy.
849 *
850 * ```js
851 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
852 *
853 * console.log(buf.readIntLE(0, 6).toString(16));
854 * // Prints: -546f87a9cbee
855 * ```
856 * @since v0.11.15
857 * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
858 * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
859 */
860 readIntLE(offset: number, byteLength: number): number;
861 /**
862 * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value
863 * supporting up to 48 bits of accuracy.
864 *
865 * ```js
866 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
867 *
868 * console.log(buf.readIntBE(0, 6).toString(16));
869 * // Prints: 1234567890ab
870 * console.log(buf.readIntBE(1, 6).toString(16));
871 * // Throws ERR_OUT_OF_RANGE.
872 * console.log(buf.readIntBE(1, 0).toString(16));
873 * // Throws ERR_OUT_OF_RANGE.
874 * ```
875 * @since v0.11.15
876 * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
877 * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
878 */
879 readIntBE(offset: number, byteLength: number): number;
880 /**
881 * Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
882 *
883 * This function is also available under the `readUint8` alias.
884 *
885 * ```js
886 * const buf = Buffer.from([1, -2]);
887 *
888 * console.log(buf.readUInt8(0));
889 * // Prints: 1
890 * console.log(buf.readUInt8(1));
891 * // Prints: 254
892 * console.log(buf.readUInt8(2));
893 * // Throws ERR_OUT_OF_RANGE.
894 * ```
895 * @since v0.5.0
896 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
897 */
898 readUInt8(offset?: number): number;
899 /**
900 * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`.
901 *
902 * This function is also available under the `readUint16LE` alias.
903 *
904 * ```js
905 * const buf = Buffer.from([0x12, 0x34, 0x56]);
906 *
907 * console.log(buf.readUInt16LE(0).toString(16));
908 * // Prints: 3412
909 * console.log(buf.readUInt16LE(1).toString(16));
910 * // Prints: 5634
911 * console.log(buf.readUInt16LE(2).toString(16));
912 * // Throws ERR_OUT_OF_RANGE.
913 * ```
914 * @since v0.5.5
915 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
916 */
917 readUInt16LE(offset?: number): number;
918 /**
919 * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
920 *
921 * This function is also available under the `readUint16BE` alias.
922 *
923 * ```js
924 * const buf = Buffer.from([0x12, 0x34, 0x56]);
925 *
926 * console.log(buf.readUInt16BE(0).toString(16));
927 * // Prints: 1234
928 * console.log(buf.readUInt16BE(1).toString(16));
929 * // Prints: 3456
930 * ```
931 * @since v0.5.5
932 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
933 */
934 readUInt16BE(offset?: number): number;
935 /**
936 * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
937 *
938 * This function is also available under the `readUint32LE` alias.
939 *
940 * ```js
941 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
942 *
943 * console.log(buf.readUInt32LE(0).toString(16));
944 * // Prints: 78563412
945 * console.log(buf.readUInt32LE(1).toString(16));
946 * // Throws ERR_OUT_OF_RANGE.
947 * ```
948 * @since v0.5.5
949 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
950 */
951 readUInt32LE(offset?: number): number;
952 /**
953 * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.
954 *
955 * This function is also available under the `readUint32BE` alias.
956 *
957 * ```js
958 * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
959 *
960 * console.log(buf.readUInt32BE(0).toString(16));
961 * // Prints: 12345678
962 * ```
963 * @since v0.5.5
964 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
965 */
966 readUInt32BE(offset?: number): number;
967 /**
968 * Reads a signed 8-bit integer from `buf` at the specified `offset`.
969 *
970 * Integers read from a `Buffer` are interpreted as two's complement signed values.
971 *
972 * ```js
973 * const buf = Buffer.from([-1, 5]);
974 *
975 * console.log(buf.readInt8(0));
976 * // Prints: -1
977 * console.log(buf.readInt8(1));
978 * // Prints: 5
979 * console.log(buf.readInt8(2));
980 * // Throws ERR_OUT_OF_RANGE.
981 * ```
982 * @since v0.5.0
983 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
984 */
985 readInt8(offset?: number): number;
986 /**
987 * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
988 *
989 * Integers read from a `Buffer` are interpreted as two's complement signed values.
990 *
991 * ```js
992 * const buf = Buffer.from([0, 5]);
993 *
994 * console.log(buf.readInt16LE(0));
995 * // Prints: 1280
996 * console.log(buf.readInt16LE(1));
997 * // Throws ERR_OUT_OF_RANGE.
998 * ```
999 * @since v0.5.5
1000 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1001 */
1002 readInt16LE(offset?: number): number;
1003 /**
1004 * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
1005 *
1006 * Integers read from a `Buffer` are interpreted as two's complement signed values.
1007 *
1008 * ```js
1009 * const buf = Buffer.from([0, 5]);
1010 *
1011 * console.log(buf.readInt16BE(0));
1012 * // Prints: 5
1013 * ```
1014 * @since v0.5.5
1015 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1016 */
1017 readInt16BE(offset?: number): number;
1018 /**
1019 * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
1020 *
1021 * Integers read from a `Buffer` are interpreted as two's complement signed values.
1022 *
1023 * ```js
1024 * const buf = Buffer.from([0, 0, 0, 5]);
1025 *
1026 * console.log(buf.readInt32LE(0));
1027 * // Prints: 83886080
1028 * console.log(buf.readInt32LE(1));
1029 * // Throws ERR_OUT_OF_RANGE.
1030 * ```
1031 * @since v0.5.5
1032 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1033 */
1034 readInt32LE(offset?: number): number;
1035 /**
1036 * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
1037 *
1038 * Integers read from a `Buffer` are interpreted as two's complement signed values.
1039 *
1040 * ```js
1041 * const buf = Buffer.from([0, 0, 0, 5]);
1042 *
1043 * console.log(buf.readInt32BE(0));
1044 * // Prints: 5
1045 * ```
1046 * @since v0.5.5
1047 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1048 */
1049 readInt32BE(offset?: number): number;
1050 /**
1051 * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
1052 *
1053 * ```js
1054 * const buf = Buffer.from([1, 2, 3, 4]);
1055 *
1056 * console.log(buf.readFloatLE(0));
1057 * // Prints: 1.539989614439558e-36
1058 * console.log(buf.readFloatLE(1));
1059 * // Throws ERR_OUT_OF_RANGE.
1060 * ```
1061 * @since v0.11.15
1062 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1063 */
1064 readFloatLE(offset?: number): number;
1065 /**
1066 * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
1067 *
1068 * ```js
1069 * const buf = Buffer.from([1, 2, 3, 4]);
1070 *
1071 * console.log(buf.readFloatBE(0));
1072 * // Prints: 2.387939260590663e-38
1073 * ```
1074 * @since v0.11.15
1075 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1076 */
1077 readFloatBE(offset?: number): number;
1078 /**
1079 * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
1080 *
1081 * ```js
1082 * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1083 *
1084 * console.log(buf.readDoubleLE(0));
1085 * // Prints: 5.447603722011605e-270
1086 * console.log(buf.readDoubleLE(1));
1087 * // Throws ERR_OUT_OF_RANGE.
1088 * ```
1089 * @since v0.11.15
1090 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
1091 */
1092 readDoubleLE(offset?: number): number;
1093 /**
1094 * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
1095 *
1096 * ```js
1097 * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1098 *
1099 * console.log(buf.readDoubleBE(0));
1100 * // Prints: 8.20788039913184e-304
1101 * ```
1102 * @since v0.11.15
1103 * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
1104 */
1105 readDoubleBE(offset?: number): number;
1106 reverse(): this;
1107 /**
1108 * Interprets `buf` as an array of unsigned 16-bit integers and swaps the
1109 * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
1110 *
1111 * ```js
1112 * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1113 *
1114 * console.log(buf1);
1115 * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1116 *
1117 * buf1.swap16();
1118 *
1119 * console.log(buf1);
1120 * // Prints: <Buffer 02 01 04 03 06 05 08 07>
1121 *
1122 * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1123 *
1124 * buf2.swap16();
1125 * // Throws ERR_INVALID_BUFFER_SIZE.
1126 * ```
1127 *
1128 * One convenient use of `buf.swap16()` is to perform a fast in-place conversion
1129 * between UTF-16 little-endian and UTF-16 big-endian:
1130 *
1131 * ```js
1132 * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1133 * buf.swap16(); // Convert to big-endian UTF-16 text.
1134 * ```
1135 * @since v5.10.0
1136 * @return A reference to `buf`.
1137 */
1138 swap16(): Buffer;
1139 /**
1140 * Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1141 * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
1142 *
1143 * ```js
1144 * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1145 *
1146 * console.log(buf1);
1147 * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1148 *
1149 * buf1.swap32();
1150 *
1151 * console.log(buf1);
1152 * // Prints: <Buffer 04 03 02 01 08 07 06 05>
1153 *
1154 * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1155 *
1156 * buf2.swap32();
1157 * // Throws ERR_INVALID_BUFFER_SIZE.
1158 * ```
1159 * @since v5.10.0
1160 * @return A reference to `buf`.
1161 */
1162 swap32(): Buffer;
1163 /**
1164 * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
1165 * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
1166 *
1167 * ```js
1168 * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1169 *
1170 * console.log(buf1);
1171 * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1172 *
1173 * buf1.swap64();
1174 *
1175 * console.log(buf1);
1176 * // Prints: <Buffer 08 07 06 05 04 03 02 01>
1177 *
1178 * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1179 *
1180 * buf2.swap64();
1181 * // Throws ERR_INVALID_BUFFER_SIZE.
1182 * ```
1183 * @since v6.3.0
1184 * @return A reference to `buf`.
1185 */
1186 swap64(): Buffer;
1187 /**
1188 * Writes `value` to `buf` at the specified `offset`. `value` must be a
1189 * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
1190 * other than an unsigned 8-bit integer.
1191 *
1192 * This function is also available under the `writeUint8` alias.
1193 *
1194 * ```js
1195 * const buf = Buffer.allocUnsafe(4);
1196 *
1197 * buf.writeUInt8(0x3, 0);
1198 * buf.writeUInt8(0x4, 1);
1199 * buf.writeUInt8(0x23, 2);
1200 * buf.writeUInt8(0x42, 3);
1201 *
1202 * console.log(buf);
1203 * // Prints: <Buffer 03 04 23 42>
1204 * ```
1205 * @since v0.5.0
1206 * @param value Number to be written to `buf`.
1207 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
1208 * @return `offset` plus the number of bytes written.
1209 */
1210 writeUInt8(value: number, offset?: number): number;
1211 /**
1212 * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
1213 * anything other than an unsigned 16-bit integer.
1214 *
1215 * This function is also available under the `writeUint16LE` alias.
1216 *
1217 * ```js
1218 * const buf = Buffer.allocUnsafe(4);
1219 *
1220 * buf.writeUInt16LE(0xdead, 0);
1221 * buf.writeUInt16LE(0xbeef, 2);
1222 *
1223 * console.log(buf);
1224 * // Prints: <Buffer ad de ef be>
1225 * ```
1226 * @since v0.5.5
1227 * @param value Number to be written to `buf`.
1228 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1229 * @return `offset` plus the number of bytes written.
1230 */
1231 writeUInt16LE(value: number, offset?: number): number;
1232 /**
1233 * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
1234 * unsigned 16-bit integer.
1235 *
1236 * This function is also available under the `writeUint16BE` alias.
1237 *
1238 * ```js
1239 * const buf = Buffer.allocUnsafe(4);
1240 *
1241 * buf.writeUInt16BE(0xdead, 0);
1242 * buf.writeUInt16BE(0xbeef, 2);
1243 *
1244 * console.log(buf);
1245 * // Prints: <Buffer de ad be ef>
1246 * ```
1247 * @since v0.5.5
1248 * @param value Number to be written to `buf`.
1249 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1250 * @return `offset` plus the number of bytes written.
1251 */
1252 writeUInt16BE(value: number, offset?: number): number;
1253 /**
1254 * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
1255 * anything other than an unsigned 32-bit integer.
1256 *
1257 * This function is also available under the `writeUint32LE` alias.
1258 *
1259 * ```js
1260 * const buf = Buffer.allocUnsafe(4);
1261 *
1262 * buf.writeUInt32LE(0xfeedface, 0);
1263 *
1264 * console.log(buf);
1265 * // Prints: <Buffer ce fa ed fe>
1266 * ```
1267 * @since v0.5.5
1268 * @param value Number to be written to `buf`.
1269 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1270 * @return `offset` plus the number of bytes written.
1271 */
1272 writeUInt32LE(value: number, offset?: number): number;
1273 /**
1274 * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
1275 * unsigned 32-bit integer.
1276 *
1277 * This function is also available under the `writeUint32BE` alias.
1278 *
1279 * ```js
1280 * const buf = Buffer.allocUnsafe(4);
1281 *
1282 * buf.writeUInt32BE(0xfeedface, 0);
1283 *
1284 * console.log(buf);
1285 * // Prints: <Buffer fe ed fa ce>
1286 * ```
1287 * @since v0.5.5
1288 * @param value Number to be written to `buf`.
1289 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1290 * @return `offset` plus the number of bytes written.
1291 */
1292 writeUInt32BE(value: number, offset?: number): number;
1293 /**
1294 * Writes `value` to `buf` at the specified `offset`. `value` must be a valid
1295 * signed 8-bit integer. Behavior is undefined when `value` is anything other than
1296 * a signed 8-bit integer.
1297 *
1298 * `value` is interpreted and written as a two's complement signed integer.
1299 *
1300 * ```js
1301 * const buf = Buffer.allocUnsafe(2);
1302 *
1303 * buf.writeInt8(2, 0);
1304 * buf.writeInt8(-2, 1);
1305 *
1306 * console.log(buf);
1307 * // Prints: <Buffer 02 fe>
1308 * ```
1309 * @since v0.5.0
1310 * @param value Number to be written to `buf`.
1311 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
1312 * @return `offset` plus the number of bytes written.
1313 */
1314 writeInt8(value: number, offset?: number): number;
1315 /**
1316 * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
1317 * anything other than a signed 16-bit integer.
1318 *
1319 * The `value` is interpreted and written as a two's complement signed integer.
1320 *
1321 * ```js
1322 * const buf = Buffer.allocUnsafe(2);
1323 *
1324 * buf.writeInt16LE(0x0304, 0);
1325 *
1326 * console.log(buf);
1327 * // Prints: <Buffer 04 03>
1328 * ```
1329 * @since v0.5.5
1330 * @param value Number to be written to `buf`.
1331 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1332 * @return `offset` plus the number of bytes written.
1333 */
1334 writeInt16LE(value: number, offset?: number): number;
1335 /**
1336 * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 16-bit integer. Behavior is undefined when `value` is
1337 * anything other than a signed 16-bit integer.
1338 *
1339 * The `value` is interpreted and written as a two's complement signed integer.
1340 *
1341 * ```js
1342 * const buf = Buffer.allocUnsafe(2);
1343 *
1344 * buf.writeInt16BE(0x0102, 0);
1345 *
1346 * console.log(buf);
1347 * // Prints: <Buffer 01 02>
1348 * ```
1349 * @since v0.5.5
1350 * @param value Number to be written to `buf`.
1351 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1352 * @return `offset` plus the number of bytes written.
1353 */
1354 writeInt16BE(value: number, offset?: number): number;
1355 /**
1356 * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
1357 * anything other than a signed 32-bit integer.
1358 *
1359 * The `value` is interpreted and written as a two's complement signed integer.
1360 *
1361 * ```js
1362 * const buf = Buffer.allocUnsafe(4);
1363 *
1364 * buf.writeInt32LE(0x05060708, 0);
1365 *
1366 * console.log(buf);
1367 * // Prints: <Buffer 08 07 06 05>
1368 * ```
1369 * @since v0.5.5
1370 * @param value Number to be written to `buf`.
1371 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1372 * @return `offset` plus the number of bytes written.
1373 */
1374 writeInt32LE(value: number, offset?: number): number;
1375 /**
1376 * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a valid signed 32-bit integer. Behavior is undefined when `value` is
1377 * anything other than a signed 32-bit integer.
1378 *
1379 * The `value` is interpreted and written as a two's complement signed integer.
1380 *
1381 * ```js
1382 * const buf = Buffer.allocUnsafe(4);
1383 *
1384 * buf.writeInt32BE(0x01020304, 0);
1385 *
1386 * console.log(buf);
1387 * // Prints: <Buffer 01 02 03 04>
1388 * ```
1389 * @since v0.5.5
1390 * @param value Number to be written to `buf`.
1391 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1392 * @return `offset` plus the number of bytes written.
1393 */
1394 writeInt32BE(value: number, offset?: number): number;
1395 /**
1396 * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
1397 * undefined when `value` is anything other than a JavaScript number.
1398 *
1399 * ```js
1400 * const buf = Buffer.allocUnsafe(4);
1401 *
1402 * buf.writeFloatLE(0xcafebabe, 0);
1403 *
1404 * console.log(buf);
1405 * // Prints: <Buffer bb fe 4a 4f>
1406 * ```
1407 * @since v0.11.15
1408 * @param value Number to be written to `buf`.
1409 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1410 * @return `offset` plus the number of bytes written.
1411 */
1412 writeFloatLE(value: number, offset?: number): number;
1413 /**
1414 * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
1415 * undefined when `value` is anything other than a JavaScript number.
1416 *
1417 * ```js
1418 * const buf = Buffer.allocUnsafe(4);
1419 *
1420 * buf.writeFloatBE(0xcafebabe, 0);
1421 *
1422 * console.log(buf);
1423 * // Prints: <Buffer 4f 4a fe bb>
1424 * ```
1425 * @since v0.11.15
1426 * @param value Number to be written to `buf`.
1427 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1428 * @return `offset` plus the number of bytes written.
1429 */
1430 writeFloatBE(value: number, offset?: number): number;
1431 /**
1432 * Writes `value` to `buf` at the specified `offset` as little-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
1433 * other than a JavaScript number.
1434 *
1435 * ```js
1436 * const buf = Buffer.allocUnsafe(8);
1437 *
1438 * buf.writeDoubleLE(123.456, 0);
1439 *
1440 * console.log(buf);
1441 * // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
1442 * ```
1443 * @since v0.11.15
1444 * @param value Number to be written to `buf`.
1445 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1446 * @return `offset` plus the number of bytes written.
1447 */
1448 writeDoubleLE(value: number, offset?: number): number;
1449 /**
1450 * Writes `value` to `buf` at the specified `offset` as big-endian. The `value`must be a JavaScript number. Behavior is undefined when `value` is anything
1451 * other than a JavaScript number.
1452 *
1453 * ```js
1454 * const buf = Buffer.allocUnsafe(8);
1455 *
1456 * buf.writeDoubleBE(123.456, 0);
1457 *
1458 * console.log(buf);
1459 * // Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
1460 * ```
1461 * @since v0.11.15
1462 * @param value Number to be written to `buf`.
1463 * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1464 * @return `offset` plus the number of bytes written.
1465 */
1466 writeDoubleBE(value: number, offset?: number): number;
1467 /**
1468 * Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
1469 * the entire `buf` will be filled:
1470 *
1471 * ```js
1472 * // Fill a `Buffer` with the ASCII character 'h'.
1473 *
1474 * const b = Buffer.allocUnsafe(50).fill('h');
1475 *
1476 * console.log(b.toString());
1477 * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1478 * ```
1479 *
1480 * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
1481 * integer. If the resulting integer is greater than `255` (decimal), `buf` will be
1482 * filled with `value &#x26; 255`.
1483 *
1484 * If the final write of a `fill()` operation falls on a multi-byte character,
1485 * then only the bytes of that character that fit into `buf` are written:
1486 *
1487 * ```js
1488 * // Fill a `Buffer` with character that takes up two bytes in UTF-8.
1489 *
1490 * console.log(Buffer.allocUnsafe(5).fill('\u0222'));
1491 * // Prints: <Buffer c8 a2 c8 a2 c8>
1492 * ```
1493 *
1494 * If `value` contains invalid characters, it is truncated; if no valid
1495 * fill data remains, an exception is thrown:
1496 *
1497 * ```js
1498 * const buf = Buffer.allocUnsafe(5);
1499 *
1500 * console.log(buf.fill('a'));
1501 * // Prints: <Buffer 61 61 61 61 61>
1502 * console.log(buf.fill('aazz', 'hex'));
1503 * // Prints: <Buffer aa aa aa aa aa>
1504 * console.log(buf.fill('zz', 'hex'));
1505 * // Throws an exception.
1506 * ```
1507 * @since v0.5.0
1508 * @param value The value with which to fill `buf`.
1509 * @param [offset=0] Number of bytes to skip before starting to fill `buf`.
1510 * @param [end=buf.length] Where to stop filling `buf` (not inclusive).
1511 * @param [encoding='utf8'] The encoding for `value` if `value` is a string.
1512 * @return A reference to `buf`.
1513 */
1514 fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
1515 /**
1516 * If `value` is:
1517 *
1518 * * a string, `value` is interpreted according to the character encoding in`encoding`.
1519 * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
1520 * To compare a partial `Buffer`, use `buf.slice()`.
1521 * * a number, `value` will be interpreted as an unsigned 8-bit integer
1522 * value between `0` and `255`.
1523 *
1524 * ```js
1525 * const buf = Buffer.from('this is a buffer');
1526 *
1527 * console.log(buf.indexOf('this'));
1528 * // Prints: 0
1529 * console.log(buf.indexOf('is'));
1530 * // Prints: 2
1531 * console.log(buf.indexOf(Buffer.from('a buffer')));
1532 * // Prints: 8
1533 * console.log(buf.indexOf(97));
1534 * // Prints: 8 (97 is the decimal ASCII value for 'a')
1535 * console.log(buf.indexOf(Buffer.from('a buffer example')));
1536 * // Prints: -1
1537 * console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
1538 * // Prints: 8
1539 *
1540 * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
1541 *
1542 * console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
1543 * // Prints: 4
1544 * console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
1545 * // Prints: 6
1546 * ```
1547 *
1548 * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1549 * an integer between 0 and 255.
1550 *
1551 * If `byteOffset` is not a number, it will be coerced to a number. If the result
1552 * of coercion is `NaN` or `0`, then the entire buffer will be searched. This
1553 * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
1554 *
1555 * ```js
1556 * const b = Buffer.from('abcdef');
1557 *
1558 * // Passing a value that's a number, but not a valid byte.
1559 * // Prints: 2, equivalent to searching for 99 or 'c'.
1560 * console.log(b.indexOf(99.9));
1561 * console.log(b.indexOf(256 + 99));
1562 *
1563 * // Passing a byteOffset that coerces to NaN or 0.
1564 * // Prints: 1, searching the whole buffer.
1565 * console.log(b.indexOf('b', undefined));
1566 * console.log(b.indexOf('b', {}));
1567 * console.log(b.indexOf('b', null));
1568 * console.log(b.indexOf('b', []));
1569 * ```
1570 *
1571 * If `value` is an empty string or empty `Buffer` and `byteOffset` is less
1572 * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
1573 * @since v1.5.0
1574 * @param value What to search for.
1575 * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1576 * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1577 * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1578 */
1579 indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
1580 /**
1581 * Identical to `buf.indexOf()`, except the last occurrence of `value` is found
1582 * rather than the first occurrence.
1583 *
1584 * ```js
1585 * const buf = Buffer.from('this buffer is a buffer');
1586 *
1587 * console.log(buf.lastIndexOf('this'));
1588 * // Prints: 0
1589 * console.log(buf.lastIndexOf('buffer'));
1590 * // Prints: 17
1591 * console.log(buf.lastIndexOf(Buffer.from('buffer')));
1592 * // Prints: 17
1593 * console.log(buf.lastIndexOf(97));
1594 * // Prints: 15 (97 is the decimal ASCII value for 'a')
1595 * console.log(buf.lastIndexOf(Buffer.from('yolo')));
1596 * // Prints: -1
1597 * console.log(buf.lastIndexOf('buffer', 5));
1598 * // Prints: 5
1599 * console.log(buf.lastIndexOf('buffer', 4));
1600 * // Prints: -1
1601 *
1602 * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
1603 *
1604 * console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
1605 * // Prints: 6
1606 * console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
1607 * // Prints: 4
1608 * ```
1609 *
1610 * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1611 * an integer between 0 and 255.
1612 *
1613 * If `byteOffset` is not a number, it will be coerced to a number. Any arguments
1614 * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
1615 * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
1616 *
1617 * ```js
1618 * const b = Buffer.from('abcdef');
1619 *
1620 * // Passing a value that's a number, but not a valid byte.
1621 * // Prints: 2, equivalent to searching for 99 or 'c'.
1622 * console.log(b.lastIndexOf(99.9));
1623 * console.log(b.lastIndexOf(256 + 99));
1624 *
1625 * // Passing a byteOffset that coerces to NaN.
1626 * // Prints: 1, searching the whole buffer.
1627 * console.log(b.lastIndexOf('b', undefined));
1628 * console.log(b.lastIndexOf('b', {}));
1629 *
1630 * // Passing a byteOffset that coerces to 0.
1631 * // Prints: -1, equivalent to passing 0.
1632 * console.log(b.lastIndexOf('b', null));
1633 * console.log(b.lastIndexOf('b', []));
1634 * ```
1635 *
1636 * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
1637 * @since v6.0.0
1638 * @param value What to search for.
1639 * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1640 * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1641 * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1642 */
1643 lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
1644 /**
1645 * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents
1646 * of `buf`.
1647 *
1648 * ```js
1649 * // Log the entire contents of a `Buffer`.
1650 *
1651 * const buf = Buffer.from('buffer');
1652 *
1653 * for (const pair of buf.entries()) {
1654 * console.log(pair);
1655 * }
1656 * // Prints:
1657 * // [0, 98]
1658 * // [1, 117]
1659 * // [2, 102]
1660 * // [3, 102]
1661 * // [4, 101]
1662 * // [5, 114]
1663 * ```
1664 * @since v1.1.0
1665 */
1666 entries(): IterableIterator<[number, number]>;
1667 /**
1668 * Equivalent to `buf.indexOf() !== -1`.
1669 *
1670 * ```js
1671 * const buf = Buffer.from('this is a buffer');
1672 *
1673 * console.log(buf.includes('this'));
1674 * // Prints: true
1675 * console.log(buf.includes('is'));
1676 * // Prints: true
1677 * console.log(buf.includes(Buffer.from('a buffer')));
1678 * // Prints: true
1679 * console.log(buf.includes(97));
1680 * // Prints: true (97 is the decimal ASCII value for 'a')
1681 * console.log(buf.includes(Buffer.from('a buffer example')));
1682 * // Prints: false
1683 * console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1684 * // Prints: true
1685 * console.log(buf.includes('this', 4));
1686 * // Prints: false
1687 * ```
1688 * @since v5.3.0
1689 * @param value What to search for.
1690 * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1691 * @param [encoding='utf8'] If `value` is a string, this is its encoding.
1692 * @return `true` if `value` was found in `buf`, `false` otherwise.
1693 */
1694 includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
1695 /**
1696 * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
1697 *
1698 * ```js
1699 * const buf = Buffer.from('buffer');
1700 *
1701 * for (const key of buf.keys()) {
1702 * console.log(key);
1703 * }
1704 * // Prints:
1705 * // 0
1706 * // 1
1707 * // 2
1708 * // 3
1709 * // 4
1710 * // 5
1711 * ```
1712 * @since v1.1.0
1713 */
1714 keys(): IterableIterator<number>;
1715 /**
1716 * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is
1717 * called automatically when a `Buffer` is used in a `for..of` statement.
1718 *
1719 * ```js
1720 * const buf = Buffer.from('buffer');
1721 *
1722 * for (const value of buf.values()) {
1723 * console.log(value);
1724 * }
1725 * // Prints:
1726 * // 98
1727 * // 117
1728 * // 102
1729 * // 102
1730 * // 101
1731 * // 114
1732 *
1733 * for (const value of buf) {
1734 * console.log(value);
1735 * }
1736 * // Prints:
1737 * // 98
1738 * // 117
1739 * // 102
1740 * // 102
1741 * // 101
1742 * // 114
1743 * ```
1744 * @since v1.1.0
1745 */
1746 values(): IterableIterator<number>;
1747 }
1748 var Buffer: BufferConstructor;
1749 /**
1750 * Decodes a string of Base64-encoded data into bytes, and encodes those bytes
1751 * into a string using Latin-1 (ISO-8859-1).
1752 *
1753 * The `data` may be any JavaScript-value that can be coerced into a string.
1754 *
1755 * **This function is only provided for compatibility with legacy web platform APIs**
1756 * **and should never be used in new code, because they use strings to represent**
1757 * **binary data and predate the introduction of typed arrays in JavaScript.**
1758 * **For code running using Node.js APIs, converting between base64-encoded strings**
1759 * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
1760 * @since v15.13.0
1761 * @deprecated Use `Buffer.from(data, 'base64')` instead.
1762 * @param data The Base64-encoded input string.
1763 */
1764 function atob(data: string): string;
1765 /**
1766 * Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes
1767 * into a string using Base64.
1768 *
1769 * The `data` may be any JavaScript-value that can be coerced into a string.
1770 *
1771 * **This function is only provided for compatibility with legacy web platform APIs**
1772 * **and should never be used in new code, because they use strings to represent**
1773 * **binary data and predate the introduction of typed arrays in JavaScript.**
1774 * **For code running using Node.js APIs, converting between base64-encoded strings**
1775 * **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
1776 * @since v15.13.0
1777 * @deprecated Use `buf.toString('base64')` instead.
1778 * @param data An ASCII (Latin1) string.
1779 */
1780 function btoa(data: string): string;
1781 }
1782}
1783declare module 'node:buffer' {
1784 export * from 'buffer';
1785}
1786
\No newline at end of file