githrun

A CLI tool to run Python scrip...
Log | Files | Refs | README | LICENSE

buffer.d.ts (84175B)


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