CoolFace
Apppublic

Pinsave/counterstrike

sourceHugging Faceupdated 3mo agoView on Hugging Face
1likes
buffer.d.ts1931 linesDownload Raw Back to node
1// If lib.dom.d.ts or lib.webworker.d.ts is loaded, then use the global types.2// Otherwise, use the types from node.3type _Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : import("buffer").Blob;4type _File = typeof globalThis extends { onmessage: any; File: any } ? {} : import("buffer").File;5 6/**7 * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many8 * Node.js APIs support `Buffer`s.9 *10 * The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and11 * extends it with methods that cover additional use cases. Node.js APIs accept12 * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.13 *14 * While the `Buffer` class is available within the global scope, it is still15 * recommended to explicitly reference it via an import or require statement.16 *17 * ```js18 * import { Buffer } from 'node:buffer';19 *20 * // Creates a zero-filled Buffer of length 10.21 * const buf1 = Buffer.alloc(10);22 *23 * // Creates a Buffer of length 10,24 * // filled with bytes which all have the value `1`.25 * const buf2 = Buffer.alloc(10, 1);26 *27 * // Creates an uninitialized buffer of length 10.28 * // This is faster than calling Buffer.alloc() but the returned29 * // Buffer instance might contain old data that needs to be30 * // overwritten using fill(), write(), or other functions that fill the Buffer's31 * // contents.32 * const buf3 = Buffer.allocUnsafe(10);33 *34 * // Creates a Buffer containing the bytes [1, 2, 3].35 * const buf4 = Buffer.from([1, 2, 3]);36 *37 * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries38 * // are all truncated using `(value &#x26; 255)` to fit into the range 0–255.39 * const buf5 = Buffer.from([257, 257.5, -255, '1']);40 *41 * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':42 * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)43 * // [116, 195, 169, 115, 116] (in decimal notation)44 * const buf6 = Buffer.from('tést');45 *46 * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].47 * const buf7 = Buffer.from('tést', 'latin1');48 * ```49 * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/buffer.js)50 */51declare module "buffer" {52    import { BinaryLike } from "node:crypto";53    import { ReadableStream as WebReadableStream } from "node:stream/web";54    /**55     * This function returns `true` if `input` contains only valid UTF-8-encoded data,56     * including the case in which `input` is empty.57     *58     * Throws if the `input` is a detached array buffer.59     * @since v19.4.0, v18.14.060     * @param input The input to validate.61     */62    export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;63    /**64     * This function returns `true` if `input` contains only valid ASCII-encoded data,65     * including the case in which `input` is empty.66     *67     * Throws if the `input` is a detached array buffer.68     * @since v19.6.0, v18.15.069     * @param input The input to validate.70     */71    export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;72    export let INSPECT_MAX_BYTES: number;73    export const kMaxLength: number;74    export const kStringMaxLength: number;75    export const constants: {76        MAX_LENGTH: number;77        MAX_STRING_LENGTH: number;78    };79    export type TranscodeEncoding =80        | "ascii"81        | "utf8"82        | "utf-8"83        | "utf16le"84        | "utf-16le"85        | "ucs2"86        | "ucs-2"87        | "latin1"88        | "binary";89    /**90     * Re-encodes the given `Buffer` or `Uint8Array` instance from one character91     * encoding to another. Returns a new `Buffer` instance.92     *93     * Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if94     * conversion from `fromEnc` to `toEnc` is not permitted.95     *96     * Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`, `'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.97     *98     * The transcoding process will use substitution characters if a given byte99     * sequence cannot be adequately represented in the target encoding. For instance:100     *101     * ```js102     * import { Buffer, transcode } from 'node:buffer';103     *104     * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');105     * console.log(newBuf.toString('ascii'));106     * // Prints: '?'107     * ```108     *109     * Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced110     * with `?` in the transcoded `Buffer`.111     * @since v7.1.0112     * @param source A `Buffer` or `Uint8Array` instance.113     * @param fromEnc The current encoding.114     * @param toEnc To target encoding.115     */116    export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;117    /**118     * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using119     * a prior call to `URL.createObjectURL()`.120     * @since v16.7.0121     * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.122     */123    export function resolveObjectURL(id: string): Blob | undefined;124    export { type AllowSharedBuffer, Buffer, type NonSharedBuffer };125    /**126     * @experimental127     */128    export interface BlobOptions {129        /**130         * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts131         * will be converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.132         */133        endings?: "transparent" | "native";134        /**135         * The Blob content-type. The intent is for `type` to convey136         * the MIME media type of the data, however no validation of the type format137         * is performed.138         */139        type?: string | undefined;140    }141    /**142     * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across143     * multiple worker threads.144     * @since v15.7.0, v14.18.0145     */146    export class Blob {147        /**148         * The total size of the `Blob` in bytes.149         * @since v15.7.0, v14.18.0150         */151        readonly size: number;152        /**153         * The content-type of the `Blob`.154         * @since v15.7.0, v14.18.0155         */156        readonly type: string;157        /**158         * Creates a new `Blob` object containing a concatenation of the given sources.159         *160         * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into161         * the 'Blob' and can therefore be safely modified after the 'Blob' is created.162         *163         * String sources are also copied into the `Blob`.164         */165        constructor(sources: Array<ArrayBuffer | BinaryLike | Blob>, options?: BlobOptions);166        /**167         * Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of168         * the `Blob` data.169         * @since v15.7.0, v14.18.0170         */171        arrayBuffer(): Promise<ArrayBuffer>;172        /**173         * The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.174         *175         * ```js176         * const blob = new Blob(['hello']);177         * blob.bytes().then((bytes) => {178         *   console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]179         * });180         * ```181         */182        bytes(): Promise<Uint8Array>;183        /**184         * Creates and returns a new `Blob` containing a subset of this `Blob` objects185         * data. The original `Blob` is not altered.186         * @since v15.7.0, v14.18.0187         * @param start The starting index.188         * @param end The ending index.189         * @param type The content-type for the new `Blob`190         */191        slice(start?: number, end?: number, type?: string): Blob;192        /**193         * Returns a promise that fulfills with the contents of the `Blob` decoded as a194         * UTF-8 string.195         * @since v15.7.0, v14.18.0196         */197        text(): Promise<string>;198        /**199         * Returns a new `ReadableStream` that allows the content of the `Blob` to be read.200         * @since v16.7.0201         */202        stream(): WebReadableStream;203    }204    export interface FileOptions {205        /**206         * One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be207         * converted to the platform native line-ending as specified by `import { EOL } from 'node:os'`.208         */209        endings?: "native" | "transparent";210        /** The File content-type. */211        type?: string;212        /** The last modified date of the file. `Default`: Date.now(). */213        lastModified?: number;214    }215    /**216     * A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.217     * @since v19.2.0, v18.13.0218     */219    export class File extends Blob {220        constructor(sources: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions);221        /**222         * The name of the `File`.223         * @since v19.2.0, v18.13.0224         */225        readonly name: string;226        /**227         * The last modified date of the `File`.228         * @since v19.2.0, v18.13.0229         */230        readonly lastModified: number;231    }232    export import atob = globalThis.atob;233    export import btoa = globalThis.btoa;234    export type WithImplicitCoercion<T> =235        | T236        | { valueOf(): T }237        | (T extends string ? { [Symbol.toPrimitive](hint: "string"): T } : never);238    global {239        namespace NodeJS {240            export { BufferEncoding };241        }242        // Buffer class243        type BufferEncoding =244            | "ascii"245            | "utf8"246            | "utf-8"247            | "utf16le"248            | "utf-16le"249            | "ucs2"250            | "ucs-2"251            | "base64"252            | "base64url"253            | "latin1"254            | "binary"255            | "hex";256        /**257         * Raw data is stored in instances of the Buffer class.258         * 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.259         * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'260         */261        interface BufferConstructor {262            // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later263            // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier264 265            /**266             * Returns `true` if `obj` is a `Buffer`, `false` otherwise.267             *268             * ```js269             * import { Buffer } from 'node:buffer';270             *271             * Buffer.isBuffer(Buffer.alloc(10)); // true272             * Buffer.isBuffer(Buffer.from('foo')); // true273             * Buffer.isBuffer('a string'); // false274             * Buffer.isBuffer([]); // false275             * Buffer.isBuffer(new Uint8Array(1024)); // false276             * ```277             * @since v0.1.101278             */279            isBuffer(obj: any): obj is Buffer;280            /**281             * Returns `true` if `encoding` is the name of a supported character encoding,282             * or `false` otherwise.283             *284             * ```js285             * import { Buffer } from 'node:buffer';286             *287             * console.log(Buffer.isEncoding('utf8'));288             * // Prints: true289             *290             * console.log(Buffer.isEncoding('hex'));291             * // Prints: true292             *293             * console.log(Buffer.isEncoding('utf/8'));294             * // Prints: false295             *296             * console.log(Buffer.isEncoding(''));297             * // Prints: false298             * ```299             * @since v0.9.1300             * @param encoding A character encoding name to check.301             */302            isEncoding(encoding: string): encoding is BufferEncoding;303            /**304             * Returns the byte length of a string when encoded using `encoding`.305             * 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 account306             * for the encoding that is used to convert the string into bytes.307             *308             * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.309             * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the310             * return value might be greater than the length of a `Buffer` created from the311             * string.312             *313             * ```js314             * import { Buffer } from 'node:buffer';315             *316             * const str = '\u00bd + \u00bc = \u00be';317             *318             * console.log(`${str}: ${str.length} characters, ` +319             *             `${Buffer.byteLength(str, 'utf8')} bytes`);320             * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes321             * ```322             *323             * When `string` is a324             * `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/-325             * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-326             * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.327             * @since v0.1.90328             * @param string A value to calculate the length of.329             * @param [encoding='utf8'] If `string` is a string, this is its encoding.330             * @return The number of bytes contained within `string`.331             */332            byteLength(333                string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,334                encoding?: BufferEncoding,335            ): number;336            /**337             * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.338             *339             * ```js340             * import { Buffer } from 'node:buffer';341             *342             * const buf1 = Buffer.from('1234');343             * const buf2 = Buffer.from('0123');344             * const arr = [buf1, buf2];345             *346             * console.log(arr.sort(Buffer.compare));347             * // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]348             * // (This result is equal to: [buf2, buf1].)349             * ```350             * @since v0.11.13351             * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.352             */353            compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;354            /**355             * This is the size (in bytes) of pre-allocated internal `Buffer` instances used356             * for pooling. This value may be modified.357             * @since v0.11.3358             */359            poolSize: number;360        }361        interface Buffer {362            // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later363            // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier364 365            /**366             * 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` did367             * not contain enough space to fit the entire string, only part of `string` will be368             * written. However, partially encoded characters will not be written.369             *370             * ```js371             * import { Buffer } from 'node:buffer';372             *373             * const buf = Buffer.alloc(256);374             *375             * const len = buf.write('\u00bd + \u00bc = \u00be', 0);376             *377             * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);378             * // Prints: 12 bytes: ½ + ¼ = ¾379             *380             * const buffer = Buffer.alloc(10);381             *382             * const length = buffer.write('abcd', 8);383             *384             * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);385             * // Prints: 2 bytes : ab386             * ```387             * @since v0.1.90388             * @param string String to write to `buf`.389             * @param [offset=0] Number of bytes to skip before starting to write `string`.390             * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).391             * @param [encoding='utf8'] The character encoding of `string`.392             * @return Number of bytes written.393             */394            write(string: string, encoding?: BufferEncoding): number;395            write(string: string, offset: number, encoding?: BufferEncoding): number;396            write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;397            /**398             * 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`.399             *400             * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,401             * then each invalid byte is replaced with the replacement character `U+FFFD`.402             *403             * The maximum length of a string instance (in UTF-16 code units) is available404             * as {@link constants.MAX_STRING_LENGTH}.405             *406             * ```js407             * import { Buffer } from 'node:buffer';408             *409             * const buf1 = Buffer.allocUnsafe(26);410             *411             * for (let i = 0; i < 26; i++) {412             *   // 97 is the decimal ASCII value for 'a'.413             *   buf1[i] = i + 97;414             * }415             *416             * console.log(buf1.toString('utf8'));417             * // Prints: abcdefghijklmnopqrstuvwxyz418             * console.log(buf1.toString('utf8', 0, 5));419             * // Prints: abcde420             *421             * const buf2 = Buffer.from('tést');422             *423             * console.log(buf2.toString('hex'));424             * // Prints: 74c3a97374425             * console.log(buf2.toString('utf8', 0, 3));426             * // Prints: té427             * console.log(buf2.toString(undefined, 0, 3));428             * // Prints: té429             * ```430             * @since v0.1.90431             * @param [encoding='utf8'] The character encoding to use.432             * @param [start=0] The byte offset to start decoding at.433             * @param [end=buf.length] The byte offset to stop decoding at (not inclusive).434             */435            toString(encoding?: BufferEncoding, start?: number, end?: number): string;436            /**437             * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls438             * this function when stringifying a `Buffer` instance.439             *440             * `Buffer.from()` accepts objects in the format returned from this method.441             * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.442             *443             * ```js444             * import { Buffer } from 'node:buffer';445             *446             * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);447             * const json = JSON.stringify(buf);448             *449             * console.log(json);450             * // Prints: {"type":"Buffer","data":[1,2,3,4,5]}451             *452             * const copy = JSON.parse(json, (key, value) => {453             *   return value &#x26;&#x26; value.type === 'Buffer' ?454             *     Buffer.from(value) :455             *     value;456             * });457             *458             * console.log(copy);459             * // Prints: <Buffer 01 02 03 04 05>460             * ```461             * @since v0.9.2462             */463            toJSON(): {464                type: "Buffer";465                data: number[];466            };467            /**468             * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.469             *470             * ```js471             * import { Buffer } from 'node:buffer';472             *473             * const buf1 = Buffer.from('ABC');474             * const buf2 = Buffer.from('414243', 'hex');475             * const buf3 = Buffer.from('ABCD');476             *477             * console.log(buf1.equals(buf2));478             * // Prints: true479             * console.log(buf1.equals(buf3));480             * // Prints: false481             * ```482             * @since v0.11.13483             * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.484             */485            equals(otherBuffer: Uint8Array): boolean;486            /**487             * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.488             * Comparison is based on the actual sequence of bytes in each `Buffer`.489             *490             * * `0` is returned if `target` is the same as `buf`491             * * `1` is returned if `target` should come _before_`buf` when sorted.492             * * `-1` is returned if `target` should come _after_`buf` when sorted.493             *494             * ```js495             * import { Buffer } from 'node:buffer';496             *497             * const buf1 = Buffer.from('ABC');498             * const buf2 = Buffer.from('BCD');499             * const buf3 = Buffer.from('ABCD');500             *501             * console.log(buf1.compare(buf1));502             * // Prints: 0503             * console.log(buf1.compare(buf2));504             * // Prints: -1505             * console.log(buf1.compare(buf3));506             * // Prints: -1507             * console.log(buf2.compare(buf1));508             * // Prints: 1509             * console.log(buf2.compare(buf3));510             * // Prints: 1511             * console.log([buf1, buf2, buf3].sort(Buffer.compare));512             * // Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]513             * // (This result is equal to: [buf1, buf3, buf2].)514             * ```515             *516             * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd` arguments can be used to limit the comparison to specific ranges within `target` and `buf` respectively.517             *518             * ```js519             * import { Buffer } from 'node:buffer';520             *521             * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);522             * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);523             *524             * console.log(buf1.compare(buf2, 5, 9, 0, 4));525             * // Prints: 0526             * console.log(buf1.compare(buf2, 0, 6, 4));527             * // Prints: -1528             * console.log(buf1.compare(buf2, 5, 6, 5));529             * // Prints: 1530             * ```531             *532             * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`, `targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.533             * @since v0.11.13534             * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.535             * @param [targetStart=0] The offset within `target` at which to begin comparison.536             * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).537             * @param [sourceStart=0] The offset within `buf` at which to begin comparison.538             * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).539             */540            compare(541                target: Uint8Array,542                targetStart?: number,543                targetEnd?: number,544                sourceStart?: number,545                sourceEnd?: number,546            ): -1 | 0 | 1;547            /**548             * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.549             *550             * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available551             * for all TypedArrays, including Node.js `Buffer`s, although it takes552             * different function arguments.553             *554             * ```js555             * import { Buffer } from 'node:buffer';556             *557             * // Create two `Buffer` instances.558             * const buf1 = Buffer.allocUnsafe(26);559             * const buf2 = Buffer.allocUnsafe(26).fill('!');560             *561             * for (let i = 0; i < 26; i++) {562             *   // 97 is the decimal ASCII value for 'a'.563             *   buf1[i] = i + 97;564             * }565             *566             * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.567             * buf1.copy(buf2, 8, 16, 20);568             * // This is equivalent to:569             * // buf2.set(buf1.subarray(16, 20), 8);570             *571             * console.log(buf2.toString('ascii', 0, 25));572             * // Prints: !!!!!!!!qrst!!!!!!!!!!!!!573             * ```574             *575             * ```js576             * import { Buffer } from 'node:buffer';577             *578             * // Create a `Buffer` and copy data from one region to an overlapping region579             * // within the same `Buffer`.580             *581             * const buf = Buffer.allocUnsafe(26);582             *583             * for (let i = 0; i < 26; i++) {584             *   // 97 is the decimal ASCII value for 'a'.585             *   buf[i] = i + 97;586             * }587             *588             * buf.copy(buf, 0, 4, 10);589             *590             * console.log(buf.toString());591             * // Prints: efghijghijklmnopqrstuvwxyz592             * ```593             * @since v0.1.90594             * @param target A `Buffer` or {@link Uint8Array} to copy into.595             * @param [targetStart=0] The offset within `target` at which to begin writing.596             * @param [sourceStart=0] The offset within `buf` from which to begin copying.597             * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).598             * @return The number of bytes copied.599             */600            copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;601            /**602             * Writes `value` to `buf` at the specified `offset` as big-endian.603             *604             * `value` is interpreted and written as a two's complement signed integer.605             *606             * ```js607             * import { Buffer } from 'node:buffer';608             *609             * const buf = Buffer.allocUnsafe(8);610             *611             * buf.writeBigInt64BE(0x0102030405060708n, 0);612             *613             * console.log(buf);614             * // Prints: <Buffer 01 02 03 04 05 06 07 08>615             * ```616             * @since v12.0.0, v10.20.0617             * @param value Number to be written to `buf`.618             * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.619             * @return `offset` plus the number of bytes written.620             */621            writeBigInt64BE(value: bigint, offset?: number): number;622            /**623             * Writes `value` to `buf` at the specified `offset` as little-endian.624             *625             * `value` is interpreted and written as a two's complement signed integer.626             *627             * ```js628             * import { Buffer } from 'node:buffer';629             *630             * const buf = Buffer.allocUnsafe(8);631             *632             * buf.writeBigInt64LE(0x0102030405060708n, 0);633             *634             * console.log(buf);635             * // Prints: <Buffer 08 07 06 05 04 03 02 01>636             * ```637             * @since v12.0.0, v10.20.0638             * @param value Number to be written to `buf`.639             * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.640             * @return `offset` plus the number of bytes written.641             */642            writeBigInt64LE(value: bigint, offset?: number): number;643            /**644             * Writes `value` to `buf` at the specified `offset` as big-endian.645             *646             * This function is also available under the `writeBigUint64BE` alias.647             *648             * ```js649             * import { Buffer } from 'node:buffer';650             *651             * const buf = Buffer.allocUnsafe(8);652             *653             * buf.writeBigUInt64BE(0xdecafafecacefaden, 0);654             *655             * console.log(buf);656             * // Prints: <Buffer de ca fa fe ca ce fa de>657             * ```658             * @since v12.0.0, v10.20.0659             * @param value Number to be written to `buf`.660             * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.661             * @return `offset` plus the number of bytes written.662             */663            writeBigUInt64BE(value: bigint, offset?: number): number;664            /**665             * @alias Buffer.writeBigUInt64BE666             * @since v14.10.0, v12.19.0667             */668            writeBigUint64BE(value: bigint, offset?: number): number;669            /**670             * Writes `value` to `buf` at the specified `offset` as little-endian671             *672             * ```js673             * import { Buffer } from 'node:buffer';674             *675             * const buf = Buffer.allocUnsafe(8);676             *677             * buf.writeBigUInt64LE(0xdecafafecacefaden, 0);678             *679             * console.log(buf);680             * // Prints: <Buffer de fa ce ca fe fa ca de>681             * ```682             *683             * This function is also available under the `writeBigUint64LE` alias.684             * @since v12.0.0, v10.20.0685             * @param value Number to be written to `buf`.686             * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.687             * @return `offset` plus the number of bytes written.688             */689            writeBigUInt64LE(value: bigint, offset?: number): number;690            /**691             * @alias Buffer.writeBigUInt64LE692             * @since v14.10.0, v12.19.0693             */694            writeBigUint64LE(value: bigint, offset?: number): number;695            /**696             * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined697             * when `value` is anything other than an unsigned integer.698             *699             * This function is also available under the `writeUintLE` alias.700             *701             * ```js702             * import { Buffer } from 'node:buffer';703             *704             * const buf = Buffer.allocUnsafe(6);705             *706             * buf.writeUIntLE(0x1234567890ab, 0, 6);707             *708             * console.log(buf);709             * // Prints: <Buffer ab 90 78 56 34 12>710             * ```711             * @since v0.5.5712             * @param value Number to be written to `buf`.713             * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.714             * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.715             * @return `offset` plus the number of bytes written.716             */717            writeUIntLE(value: number, offset: number, byteLength: number): number;718            /**719             * @alias Buffer.writeUIntLE720             * @since v14.9.0, v12.19.0721             */722            writeUintLE(value: number, offset: number, byteLength: number): number;723            /**724             * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined725             * when `value` is anything other than an unsigned integer.726             *727             * This function is also available under the `writeUintBE` alias.728             *729             * ```js730             * import { Buffer } from 'node:buffer';731             *732             * const buf = Buffer.allocUnsafe(6);733             *734             * buf.writeUIntBE(0x1234567890ab, 0, 6);735             *736             * console.log(buf);737             * // Prints: <Buffer 12 34 56 78 90 ab>738             * ```739             * @since v0.5.5740             * @param value Number to be written to `buf`.741             * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.742             * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.743             * @return `offset` plus the number of bytes written.744             */745            writeUIntBE(value: number, offset: number, byteLength: number): number;746            /**747             * @alias Buffer.writeUIntBE748             * @since v14.9.0, v12.19.0749             */750            writeUintBE(value: number, offset: number, byteLength: number): number;751            /**752             * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined753             * when `value` is anything other than a signed integer.754             *755             * ```js756             * import { Buffer } from 'node:buffer';757             *758             * const buf = Buffer.allocUnsafe(6);759             *760             * buf.writeIntLE(0x1234567890ab, 0, 6);761             *762             * console.log(buf);763             * // Prints: <Buffer ab 90 78 56 34 12>764             * ```765             * @since v0.11.15766             * @param value Number to be written to `buf`.767             * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.768             * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.769             * @return `offset` plus the number of bytes written.770             */771            writeIntLE(value: number, offset: number, byteLength: number): number;772            /**773             * 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 a774             * signed integer.775             *776             * ```js777             * import { Buffer } from 'node:buffer';778             *779             * const buf = Buffer.allocUnsafe(6);780             *781             * buf.writeIntBE(0x1234567890ab, 0, 6);782             *783             * console.log(buf);784             * // Prints: <Buffer 12 34 56 78 90 ab>785             * ```786             * @since v0.11.15787             * @param value Number to be written to `buf`.788             * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.789             * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.790             * @return `offset` plus the number of bytes written.791             */792            writeIntBE(value: number, offset: number, byteLength: number): number;793            /**794             * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.795             *796             * This function is also available under the `readBigUint64BE` alias.797             *798             * ```js799             * import { Buffer } from 'node:buffer';800             *801             * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);802             *803             * console.log(buf.readBigUInt64BE(0));804             * // Prints: 4294967295n805             * ```806             * @since v12.0.0, v10.20.0807             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.808             */809            readBigUInt64BE(offset?: number): bigint;810            /**811             * @alias Buffer.readBigUInt64BE812             * @since v14.10.0, v12.19.0813             */814            readBigUint64BE(offset?: number): bigint;815            /**816             * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.817             *818             * This function is also available under the `readBigUint64LE` alias.819             *820             * ```js821             * import { Buffer } from 'node:buffer';822             *823             * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);824             *825             * console.log(buf.readBigUInt64LE(0));826             * // Prints: 18446744069414584320n827             * ```828             * @since v12.0.0, v10.20.0829             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.830             */831            readBigUInt64LE(offset?: number): bigint;832            /**833             * @alias Buffer.readBigUInt64LE834             * @since v14.10.0, v12.19.0835             */836            readBigUint64LE(offset?: number): bigint;837            /**838             * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.839             *840             * Integers read from a `Buffer` are interpreted as two's complement signed841             * values.842             * @since v12.0.0, v10.20.0843             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.844             */845            readBigInt64BE(offset?: number): bigint;846            /**847             * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.848             *849             * Integers read from a `Buffer` are interpreted as two's complement signed850             * values.851             * @since v12.0.0, v10.20.0852             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.853             */854            readBigInt64LE(offset?: number): bigint;855            /**856             * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting857             * up to 48 bits of accuracy.858             *859             * This function is also available under the `readUintLE` alias.860             *861             * ```js862             * import { Buffer } from 'node:buffer';863             *864             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);865             *866             * console.log(buf.readUIntLE(0, 6).toString(16));867             * // Prints: ab9078563412868             * ```869             * @since v0.11.15870             * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.871             * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.872             */873            readUIntLE(offset: number, byteLength: number): number;874            /**875             * @alias Buffer.readUIntLE876             * @since v14.9.0, v12.19.0877             */878            readUintLE(offset: number, byteLength: number): number;879            /**880             * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting881             * up to 48 bits of accuracy.882             *883             * This function is also available under the `readUintBE` alias.884             *885             * ```js886             * import { Buffer } from 'node:buffer';887             *888             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);889             *890             * console.log(buf.readUIntBE(0, 6).toString(16));891             * // Prints: 1234567890ab892             * console.log(buf.readUIntBE(1, 6).toString(16));893             * // Throws ERR_OUT_OF_RANGE.894             * ```895             * @since v0.11.15896             * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.897             * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.898             */899            readUIntBE(offset: number, byteLength: number): number;900            /**901             * @alias Buffer.readUIntBE902             * @since v14.9.0, v12.19.0903             */904            readUintBE(offset: number, byteLength: number): number;905            /**906             * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value907             * supporting up to 48 bits of accuracy.908             *909             * ```js910             * import { Buffer } from 'node:buffer';911             *912             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);913             *914             * console.log(buf.readIntLE(0, 6).toString(16));915             * // Prints: -546f87a9cbee916             * ```917             * @since v0.11.15918             * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.919             * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.920             */921            readIntLE(offset: number, byteLength: number): number;922            /**923             * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value924             * supporting up to 48 bits of accuracy.925             *926             * ```js927             * import { Buffer } from 'node:buffer';928             *929             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);930             *931             * console.log(buf.readIntBE(0, 6).toString(16));932             * // Prints: 1234567890ab933             * console.log(buf.readIntBE(1, 6).toString(16));934             * // Throws ERR_OUT_OF_RANGE.935             * console.log(buf.readIntBE(1, 0).toString(16));936             * // Throws ERR_OUT_OF_RANGE.937             * ```938             * @since v0.11.15939             * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.940             * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.941             */942            readIntBE(offset: number, byteLength: number): number;943            /**944             * Reads an unsigned 8-bit integer from `buf` at the specified `offset`.945             *946             * This function is also available under the `readUint8` alias.947             *948             * ```js949             * import { Buffer } from 'node:buffer';950             *951             * const buf = Buffer.from([1, -2]);952             *953             * console.log(buf.readUInt8(0));954             * // Prints: 1955             * console.log(buf.readUInt8(1));956             * // Prints: 254957             * console.log(buf.readUInt8(2));958             * // Throws ERR_OUT_OF_RANGE.959             * ```960             * @since v0.5.0961             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.962             */963            readUInt8(offset?: number): number;964            /**965             * @alias Buffer.readUInt8966             * @since v14.9.0, v12.19.0967             */968            readUint8(offset?: number): number;969            /**970             * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.971             *972             * This function is also available under the `readUint16LE` alias.973             *974             * ```js975             * import { Buffer } from 'node:buffer';976             *977             * const buf = Buffer.from([0x12, 0x34, 0x56]);978             *979             * console.log(buf.readUInt16LE(0).toString(16));980             * // Prints: 3412981             * console.log(buf.readUInt16LE(1).toString(16));982             * // Prints: 5634983             * console.log(buf.readUInt16LE(2).toString(16));984             * // Throws ERR_OUT_OF_RANGE.985             * ```986             * @since v0.5.5987             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.988             */989            readUInt16LE(offset?: number): number;990            /**991             * @alias Buffer.readUInt16LE992             * @since v14.9.0, v12.19.0993             */994            readUint16LE(offset?: number): number;995            /**996             * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.997             *998             * This function is also available under the `readUint16BE` alias.999             *1000             * ```js1001             * import { Buffer } from 'node:buffer';1002             *1003             * const buf = Buffer.from([0x12, 0x34, 0x56]);1004             *1005             * console.log(buf.readUInt16BE(0).toString(16));1006             * // Prints: 12341007             * console.log(buf.readUInt16BE(1).toString(16));1008             * // Prints: 34561009             * ```1010             * @since v0.5.51011             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.1012             */1013            readUInt16BE(offset?: number): number;1014            /**1015             * @alias Buffer.readUInt16BE1016             * @since v14.9.0, v12.19.01017             */1018            readUint16BE(offset?: number): number;1019            /**1020             * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.1021             *1022             * This function is also available under the `readUint32LE` alias.1023             *1024             * ```js1025             * import { Buffer } from 'node:buffer';1026             *1027             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);1028             *1029             * console.log(buf.readUInt32LE(0).toString(16));1030             * // Prints: 785634121031             * console.log(buf.readUInt32LE(1).toString(16));1032             * // Throws ERR_OUT_OF_RANGE.1033             * ```1034             * @since v0.5.51035             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1036             */1037            readUInt32LE(offset?: number): number;1038            /**1039             * @alias Buffer.readUInt32LE1040             * @since v14.9.0, v12.19.01041             */1042            readUint32LE(offset?: number): number;1043            /**1044             * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.1045             *1046             * This function is also available under the `readUint32BE` alias.1047             *1048             * ```js1049             * import { Buffer } from 'node:buffer';1050             *1051             * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);1052             *1053             * console.log(buf.readUInt32BE(0).toString(16));1054             * // Prints: 123456781055             * ```1056             * @since v0.5.51057             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1058             */1059            readUInt32BE(offset?: number): number;1060            /**1061             * @alias Buffer.readUInt32BE1062             * @since v14.9.0, v12.19.01063             */1064            readUint32BE(offset?: number): number;1065            /**1066             * Reads a signed 8-bit integer from `buf` at the specified `offset`.1067             *1068             * Integers read from a `Buffer` are interpreted as two's complement signed values.1069             *1070             * ```js1071             * import { Buffer } from 'node:buffer';1072             *1073             * const buf = Buffer.from([-1, 5]);1074             *1075             * console.log(buf.readInt8(0));1076             * // Prints: -11077             * console.log(buf.readInt8(1));1078             * // Prints: 51079             * console.log(buf.readInt8(2));1080             * // Throws ERR_OUT_OF_RANGE.1081             * ```1082             * @since v0.5.01083             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.1084             */1085            readInt8(offset?: number): number;1086            /**1087             * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.1088             *1089             * Integers read from a `Buffer` are interpreted as two's complement signed values.1090             *1091             * ```js1092             * import { Buffer } from 'node:buffer';1093             *1094             * const buf = Buffer.from([0, 5]);1095             *1096             * console.log(buf.readInt16LE(0));1097             * // Prints: 12801098             * console.log(buf.readInt16LE(1));1099             * // Throws ERR_OUT_OF_RANGE.1100             * ```1101             * @since v0.5.51102             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.1103             */1104            readInt16LE(offset?: number): number;1105            /**1106             * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.1107             *1108             * Integers read from a `Buffer` are interpreted as two's complement signed values.1109             *1110             * ```js1111             * import { Buffer } from 'node:buffer';1112             *1113             * const buf = Buffer.from([0, 5]);1114             *1115             * console.log(buf.readInt16BE(0));1116             * // Prints: 51117             * ```1118             * @since v0.5.51119             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.1120             */1121            readInt16BE(offset?: number): number;1122            /**1123             * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.1124             *1125             * Integers read from a `Buffer` are interpreted as two's complement signed values.1126             *1127             * ```js1128             * import { Buffer } from 'node:buffer';1129             *1130             * const buf = Buffer.from([0, 0, 0, 5]);1131             *1132             * console.log(buf.readInt32LE(0));1133             * // Prints: 838860801134             * console.log(buf.readInt32LE(1));1135             * // Throws ERR_OUT_OF_RANGE.1136             * ```1137             * @since v0.5.51138             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1139             */1140            readInt32LE(offset?: number): number;1141            /**1142             * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.1143             *1144             * Integers read from a `Buffer` are interpreted as two's complement signed values.1145             *1146             * ```js1147             * import { Buffer } from 'node:buffer';1148             *1149             * const buf = Buffer.from([0, 0, 0, 5]);1150             *1151             * console.log(buf.readInt32BE(0));1152             * // Prints: 51153             * ```1154             * @since v0.5.51155             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1156             */1157            readInt32BE(offset?: number): number;1158            /**1159             * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.1160             *1161             * ```js1162             * import { Buffer } from 'node:buffer';1163             *1164             * const buf = Buffer.from([1, 2, 3, 4]);1165             *1166             * console.log(buf.readFloatLE(0));1167             * // Prints: 1.539989614439558e-361168             * console.log(buf.readFloatLE(1));1169             * // Throws ERR_OUT_OF_RANGE.1170             * ```1171             * @since v0.11.151172             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1173             */1174            readFloatLE(offset?: number): number;1175            /**1176             * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.1177             *1178             * ```js1179             * import { Buffer } from 'node:buffer';1180             *1181             * const buf = Buffer.from([1, 2, 3, 4]);1182             *1183             * console.log(buf.readFloatBE(0));1184             * // Prints: 2.387939260590663e-381185             * ```1186             * @since v0.11.151187             * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.1188             */1189            readFloatBE(offset?: number): number;1190            /**1191             * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.1192             *1193             * ```js1194             * import { Buffer } from 'node:buffer';1195             *1196             * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);1197             *1198             * console.log(buf.readDoubleLE(0));1199             * // Prints: 5.447603722011605e-2701200             * console.log(buf.readDoubleLE(1));

Showing the first 1,200 of 1931 lines. Download the file for the rest.