| 1 | /// <reference types="@dop251/types-goja_nodejs-global" /> |
| 2 | /// <reference path="buffer.buffer.d.ts" /> |
| 3 | declare module 'buffer' { |
| 4 | export type WithImplicitCoercion<T> = |
| 5 | | T |
| 6 | | { valueOf(): T } |
| 7 | | (T extends string ? { [Symbol.toPrimitive](hint: "string"): T } : never); |
| 8 | |
| 9 | export { Buffer }; |
| 10 | |
| 11 | global { |
| 12 | type BufferEncoding = |
| 13 | // | "ascii" |
| 14 | | "utf8" |
| 15 | | "utf-8" |
| 16 | // | "utf16le" |
| 17 | // | "utf-16le" |
| 18 | // | "ucs2" |
| 19 | // | "ucs-2" |
| 20 | | "base64" |
| 21 | | "base64url" |
| 22 | // | "latin1" |
| 23 | // | "binary" |
| 24 | | "hex"; |
| 25 | |
| 26 | /** |
| 27 | * Raw data is stored in instances of the Buffer class. |
| 28 | * 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. |
| 29 | * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex' |
| 30 | */ |
| 31 | interface BufferConstructor { |
| 32 | // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later |
| 33 | // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier |
| 34 | |
| 35 | /** |
| 36 | * Returns `true` if `obj` is a `Buffer`, `false` otherwise. |
| 37 | * |
| 38 | * ```js |
| 39 | * import { Buffer } from 'node:buffer'; |
| 40 | * |
| 41 | * Buffer.isBuffer(Buffer.alloc(10)); // true |
| 42 | * Buffer.isBuffer(Buffer.from('foo')); // true |
| 43 | * Buffer.isBuffer('a string'); // false |
| 44 | * Buffer.isBuffer([]); // false |
| 45 | * Buffer.isBuffer(new Uint8Array(1024)); // false |
| 46 | * ``` |
| 47 | * @since v0.1.101 |
| 48 | */ |
| 49 | isBuffer(obj: any): obj is Buffer; |
| 50 | |
| 51 | /** |
| 52 | * Returns `true` if `encoding` is the name of a supported character encoding, |
| 53 | * or `false` otherwise. |
| 54 | * |
| 55 | * ```js |
| 56 | * import { Buffer } from 'node:buffer'; |
| 57 | * |
| 58 | * console.log(Buffer.isEncoding('utf8')); |
| 59 | * // Prints: true |
| 60 | * |
| 61 | * console.log(Buffer.isEncoding('hex')); |
| 62 | * // Prints: true |
| 63 | * |
| 64 | * console.log(Buffer.isEncoding('utf/8')); |
| 65 | * // Prints: false |
| 66 | * |
| 67 | * console.log(Buffer.isEncoding('')); |
| 68 | * // Prints: false |
| 69 | * ``` |
| 70 | * @since v0.9.1 |
| 71 | * @param encoding A character encoding name to check. |
| 72 | */ |
| 73 | isEncoding(encoding: string): encoding is BufferEncoding; |
| 74 | |
| 75 | /** |
| 76 | * Returns the byte length of a string when encoded using `encoding`. |
| 77 | * 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 |
| 78 | * for the encoding that is used to convert the string into bytes. |
| 79 | * |
| 80 | * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input. |
| 81 | * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the |
| 82 | * return value might be greater than the length of a `Buffer` created from the |
| 83 | * string. |
| 84 | * |
| 85 | * ```js |
| 86 | * import { Buffer } from 'node:buffer'; |
| 87 | * |
| 88 | * const str = '\u00bd + \u00bc = \u00be'; |
| 89 | * |
| 90 | * console.log(`${str}: ${str.length} characters, ` + |
| 91 | * `${Buffer.byteLength(str, 'utf8')} bytes`); |
| 92 | * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes |
| 93 | * ``` |
| 94 | * |
| 95 | * When `string` is a |
| 96 | * `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/- |
| 97 | * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop- |
| 98 | * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned. |
| 99 | * @since v0.1.90 |
| 100 | * @param string A value to calculate the length of. |
| 101 | * @param [encoding='utf8'] If `string` is a string, this is its encoding. |
| 102 | * @return The number of bytes contained within `string`. |
| 103 | */ |
| 104 | byteLength( |
| 105 | string: string | Buffer | ArrayBuffer, |
| 106 | encoding?: BufferEncoding, |
| 107 | ): number; |
| 108 | |
| 109 | /** |
| 110 | * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`. |
| 111 | * |
| 112 | * ```js |
| 113 | * import { Buffer } from 'node:buffer'; |
| 114 | * |
| 115 | * const buf1 = Buffer.from('1234'); |
| 116 | * const buf2 = Buffer.from('0123'); |
| 117 | * const arr = [buf1, buf2]; |
| 118 | * |
| 119 | * console.log(arr.sort(Buffer.compare)); |
| 120 | * // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ] |
| 121 | * // (This result is equal to: [buf2, buf1].) |
| 122 | * ``` |
| 123 | * @since v0.11.13 |
| 124 | * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details. |
| 125 | */ |
| 126 | compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1; |
| 127 | |
| 128 | /** |
| 129 | * This is the size (in bytes) of pre-allocated internal `Buffer` instances used |
| 130 | * for pooling. This value may be modified. |
| 131 | * @since v0.11.3 |
| 132 | */ |
| 133 | poolSize: number; |
| 134 | } |
| 135 | |
| 136 | interface Buffer { |
| 137 | /** |
| 138 | * 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 |
| 139 | * not contain enough space to fit the entire string, only part of `string` will be |
| 140 | * written. However, partially encoded characters will not be written. |
| 141 | * |
| 142 | * ```js |
| 143 | * import { Buffer } from 'node:buffer'; |
| 144 | * |
| 145 | * const buf = Buffer.alloc(256); |
| 146 | * |
| 147 | * const len = buf.write('\u00bd + \u00bc = \u00be', 0); |
| 148 | * |
| 149 | * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); |
| 150 | * // Prints: 12 bytes: ½ + ¼ = ¾ |
| 151 | * |
| 152 | * const buffer = Buffer.alloc(10); |
| 153 | * |
| 154 | * const length = buffer.write('abcd', 8); |
| 155 | * |
| 156 | * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`); |
| 157 | * // Prints: 2 bytes : ab |
| 158 | * ``` |
| 159 | * @since v0.1.90 |
| 160 | * @param string String to write to `buf`. |
| 161 | * @param [offset=0] Number of bytes to skip before starting to write `string`. |
| 162 | * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`). |
| 163 | * @param [encoding='utf8'] The character encoding of `string`. |
| 164 | * @return Number of bytes written. |
| 165 | */ |
| 166 | write(string: string, encoding?: BufferEncoding): number; |
| 167 | |
| 168 | write(string: string, offset: number, encoding?: BufferEncoding): number; |
| 169 | |
| 170 | write(string: string, offset: number, length: number, encoding?: BufferEncoding): number; |
| 171 | |
| 172 | /** |
| 173 | * 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`. |
| 174 | * |
| 175 | * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8, |
| 176 | * then each invalid byte is replaced with the replacement character `U+FFFD`. |
| 177 | * |
| 178 | * The maximum length of a string instance (in UTF-16 code units) is available |
| 179 | * as {@link constants.MAX_STRING_LENGTH}. |
| 180 | * |
| 181 | * ```js |
| 182 | * import { Buffer } from 'node:buffer'; |
| 183 | * |
| 184 | * const buf1 = Buffer.allocUnsafe(26); |
| 185 | * |
| 186 | * for (let i = 0; i < 26; i++) { |
| 187 | * // 97 is the decimal ASCII value for 'a'. |
| 188 | * buf1[i] = i + 97; |
| 189 | * } |
| 190 | * |
| 191 | * console.log(buf1.toString('utf8')); |
| 192 | * // Prints: abcdefghijklmnopqrstuvwxyz |
| 193 | * console.log(buf1.toString('utf8', 0, 5)); |
| 194 | * // Prints: abcde |
| 195 | * |
| 196 | * const buf2 = Buffer.from('tést'); |
| 197 | * |
| 198 | * console.log(buf2.toString('hex')); |
| 199 | * // Prints: 74c3a97374 |
| 200 | * console.log(buf2.toString('utf8', 0, 3)); |
| 201 | * // Prints: té |
| 202 | * console.log(buf2.toString(undefined, 0, 3)); |
| 203 | * // Prints: té |
| 204 | * ``` |
| 205 | * @since v0.1.90 |
| 206 | * @param [encoding='utf8'] The character encoding to use. |
| 207 | * @param [start=0] The byte offset to start decoding at. |
| 208 | * @param [end=buf.length] The byte offset to stop decoding at (not inclusive). |
| 209 | */ |
| 210 | toString(encoding?: BufferEncoding, start?: number, end?: number): string; |
| 211 | |
| 212 | /** |
| 213 | * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls |
| 214 | * this function when stringifying a `Buffer` instance. |
| 215 | * |
| 216 | * `Buffer.from()` accepts objects in the format returned from this method. |
| 217 | * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`. |
| 218 | * |
| 219 | * ```js |
| 220 | * import { Buffer } from 'node:buffer'; |
| 221 | * |
| 222 | * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]); |
| 223 | * const json = JSON.stringify(buf); |
| 224 | * |
| 225 | * console.log(json); |
| 226 | * // Prints: {"type":"Buffer","data":[1,2,3,4,5]} |
| 227 | * |
| 228 | * const copy = JSON.parse(json, (key, value) => { |
| 229 | * return value && value.type === 'Buffer' ? |
| 230 | * Buffer.from(value) : |
| 231 | * value; |
| 232 | * }); |
| 233 | * |
| 234 | * console.log(copy); |
| 235 | * // Prints: <Buffer 01 02 03 04 05> |
| 236 | * ``` |
| 237 | * @since v0.9.2 |
| 238 | */ |
| 239 | // NOT IMPLEMENTED |
| 240 | // toJSON(): { |
| 241 | // type: "Buffer"; |
| 242 | // data: number[]; |
| 243 | // }; |
| 244 | |
| 245 | /** |
| 246 | * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`. |
| 247 | * |
| 248 | * ```js |
| 249 | * import { Buffer } from 'node:buffer'; |
| 250 | * |
| 251 | * const buf1 = Buffer.from('ABC'); |
| 252 | * const buf2 = Buffer.from('414243', 'hex'); |
| 253 | * const buf3 = Buffer.from('ABCD'); |
| 254 | * |
| 255 | * console.log(buf1.equals(buf2)); |
| 256 | * // Prints: true |
| 257 | * console.log(buf1.equals(buf3)); |
| 258 | * // Prints: false |
| 259 | * ``` |
| 260 | * @since v0.11.13 |
| 261 | * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`. |
| 262 | */ |
| 263 | equals(otherBuffer: Uint8Array): boolean; |
| 264 | |
| 265 | /** |
| 266 | * Writes `value` to `buf` at the specified `offset` as big-endian. |
| 267 | * |
| 268 | * `value` is interpreted and written as a two's complement signed integer. |
| 269 | * |
| 270 | * ```js |
| 271 | * import { Buffer } from 'node:buffer'; |
| 272 | * |
| 273 | * const buf = Buffer.allocUnsafe(8); |
| 274 | * |
| 275 | * buf.writeBigInt64BE(0x0102030405060708n, 0); |
| 276 | * |
| 277 | * console.log(buf); |
| 278 | * // Prints: <Buffer 01 02 03 04 05 06 07 08> |
| 279 | * ``` |
| 280 | * @since v12.0.0, v10.20.0 |
| 281 | * @param value Number to be written to `buf`. |
| 282 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 283 | * @return `offset` plus the number of bytes written. |
| 284 | */ |
| 285 | writeBigInt64BE(value: bigint, offset?: number): number; |
| 286 | /** |
| 287 | * Writes `value` to `buf` at the specified `offset` as little-endian. |
| 288 | * |
| 289 | * `value` is interpreted and written as a two's complement signed integer. |
| 290 | * |
| 291 | * ```js |
| 292 | * import { Buffer } from 'node:buffer'; |
| 293 | * |
| 294 | * const buf = Buffer.allocUnsafe(8); |
| 295 | * |
| 296 | * buf.writeBigInt64LE(0x0102030405060708n, 0); |
| 297 | * |
| 298 | * console.log(buf); |
| 299 | * // Prints: <Buffer 08 07 06 05 04 03 02 01> |
| 300 | * ``` |
| 301 | * @since v12.0.0, v10.20.0 |
| 302 | * @param value Number to be written to `buf`. |
| 303 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 304 | * @return `offset` plus the number of bytes written. |
| 305 | */ |
| 306 | writeBigInt64LE(value: bigint, offset?: number): number; |
| 307 | /** |
| 308 | * Writes `value` to `buf` at the specified `offset` as big-endian. |
| 309 | * |
| 310 | * This function is also available under the `writeBigUint64BE` alias. |
| 311 | * |
| 312 | * ```js |
| 313 | * import { Buffer } from 'node:buffer'; |
| 314 | * |
| 315 | * const buf = Buffer.allocUnsafe(8); |
| 316 | * |
| 317 | * buf.writeBigUInt64BE(0xdecafafecacefaden, 0); |
| 318 | * |
| 319 | * console.log(buf); |
| 320 | * // Prints: <Buffer de ca fa fe ca ce fa de> |
| 321 | * ``` |
| 322 | * @since v12.0.0, v10.20.0 |
| 323 | * @param value Number to be written to `buf`. |
| 324 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 325 | * @return `offset` plus the number of bytes written. |
| 326 | */ |
| 327 | writeBigUInt64BE(value: bigint, offset?: number): number; |
| 328 | /** |
| 329 | * @alias Buffer.writeBigUInt64BE |
| 330 | * @since v14.10.0, v12.19.0 |
| 331 | */ |
| 332 | writeBigUint64BE(value: bigint, offset?: number): number; |
| 333 | /** |
| 334 | * Writes `value` to `buf` at the specified `offset` as little-endian |
| 335 | * |
| 336 | * ```js |
| 337 | * import { Buffer } from 'node:buffer'; |
| 338 | * |
| 339 | * const buf = Buffer.allocUnsafe(8); |
| 340 | * |
| 341 | * buf.writeBigUInt64LE(0xdecafafecacefaden, 0); |
| 342 | * |
| 343 | * console.log(buf); |
| 344 | * // Prints: <Buffer de fa ce ca fe fa ca de> |
| 345 | * ``` |
| 346 | * |
| 347 | * This function is also available under the `writeBigUint64LE` alias. |
| 348 | * @since v12.0.0, v10.20.0 |
| 349 | * @param value Number to be written to `buf`. |
| 350 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 351 | * @return `offset` plus the number of bytes written. |
| 352 | */ |
| 353 | writeBigUInt64LE(value: bigint, offset?: number): number; |
| 354 | /** |
| 355 | * @alias Buffer.writeBigUInt64LE |
| 356 | * @since v14.10.0, v12.19.0 |
| 357 | */ |
| 358 | writeBigUint64LE(value: bigint, offset?: number): number; |
| 359 | /** |
| 360 | * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined |
| 361 | * when `value` is anything other than an unsigned integer. |
| 362 | * |
| 363 | * This function is also available under the `writeUintLE` alias. |
| 364 | * |
| 365 | * ```js |
| 366 | * import { Buffer } from 'node:buffer'; |
| 367 | * |
| 368 | * const buf = Buffer.allocUnsafe(6); |
| 369 | * |
| 370 | * buf.writeUIntLE(0x1234567890ab, 0, 6); |
| 371 | * |
| 372 | * console.log(buf); |
| 373 | * // Prints: <Buffer ab 90 78 56 34 12> |
| 374 | * ``` |
| 375 | * @since v0.5.5 |
| 376 | * @param value Number to be written to `buf`. |
| 377 | * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 378 | * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. |
| 379 | * @return `offset` plus the number of bytes written. |
| 380 | */ |
| 381 | writeUIntLE(value: number, offset: number, byteLength: number): number; |
| 382 | /** |
| 383 | * @alias Buffer.writeUIntLE |
| 384 | * @since v14.9.0, v12.19.0 |
| 385 | */ |
| 386 | writeUintLE(value: number, offset: number, byteLength: number): number; |
| 387 | /** |
| 388 | * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined |
| 389 | * when `value` is anything other than an unsigned integer. |
| 390 | * |
| 391 | * This function is also available under the `writeUintBE` alias. |
| 392 | * |
| 393 | * ```js |
| 394 | * import { Buffer } from 'node:buffer'; |
| 395 | * |
| 396 | * const buf = Buffer.allocUnsafe(6); |
| 397 | * |
| 398 | * buf.writeUIntBE(0x1234567890ab, 0, 6); |
| 399 | * |
| 400 | * console.log(buf); |
| 401 | * // Prints: <Buffer 12 34 56 78 90 ab> |
| 402 | * ``` |
| 403 | * @since v0.5.5 |
| 404 | * @param value Number to be written to `buf`. |
| 405 | * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 406 | * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. |
| 407 | * @return `offset` plus the number of bytes written. |
| 408 | */ |
| 409 | writeUIntBE(value: number, offset: number, byteLength: number): number; |
| 410 | /** |
| 411 | * @alias Buffer.writeUIntBE |
| 412 | * @since v14.9.0, v12.19.0 |
| 413 | */ |
| 414 | writeUintBE(value: number, offset: number, byteLength: number): number; |
| 415 | /** |
| 416 | * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined |
| 417 | * when `value` is anything other than a signed integer. |
| 418 | * |
| 419 | * ```js |
| 420 | * import { Buffer } from 'node:buffer'; |
| 421 | * |
| 422 | * const buf = Buffer.allocUnsafe(6); |
| 423 | * |
| 424 | * buf.writeIntLE(0x1234567890ab, 0, 6); |
| 425 | * |
| 426 | * console.log(buf); |
| 427 | * // Prints: <Buffer ab 90 78 56 34 12> |
| 428 | * ``` |
| 429 | * @since v0.11.15 |
| 430 | * @param value Number to be written to `buf`. |
| 431 | * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 432 | * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. |
| 433 | * @return `offset` plus the number of bytes written. |
| 434 | */ |
| 435 | writeIntLE(value: number, offset: number, byteLength: number): number; |
| 436 | /** |
| 437 | * 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 |
| 438 | * signed integer. |
| 439 | * |
| 440 | * ```js |
| 441 | * import { Buffer } from 'node:buffer'; |
| 442 | * |
| 443 | * const buf = Buffer.allocUnsafe(6); |
| 444 | * |
| 445 | * buf.writeIntBE(0x1234567890ab, 0, 6); |
| 446 | * |
| 447 | * console.log(buf); |
| 448 | * // Prints: <Buffer 12 34 56 78 90 ab> |
| 449 | * ``` |
| 450 | * @since v0.11.15 |
| 451 | * @param value Number to be written to `buf`. |
| 452 | * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 453 | * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`. |
| 454 | * @return `offset` plus the number of bytes written. |
| 455 | */ |
| 456 | writeIntBE(value: number, offset: number, byteLength: number): number; |
| 457 | /** |
| 458 | * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`. |
| 459 | * |
| 460 | * This function is also available under the `readBigUint64BE` alias. |
| 461 | * |
| 462 | * ```js |
| 463 | * import { Buffer } from 'node:buffer'; |
| 464 | * |
| 465 | * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); |
| 466 | * |
| 467 | * console.log(buf.readBigUInt64BE(0)); |
| 468 | * // Prints: 4294967295n |
| 469 | * ``` |
| 470 | * @since v12.0.0, v10.20.0 |
| 471 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 472 | */ |
| 473 | readBigUInt64BE(offset?: number): bigint; |
| 474 | |
| 475 | /** |
| 476 | * @alias Buffer.readBigUInt64BE |
| 477 | * @since v14.10.0, v12.19.0 |
| 478 | */ |
| 479 | readBigUint64BE(offset?: number): bigint; |
| 480 | |
| 481 | /** |
| 482 | * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`. |
| 483 | * |
| 484 | * This function is also available under the `readBigUint64LE` alias. |
| 485 | * |
| 486 | * ```js |
| 487 | * import { Buffer } from 'node:buffer'; |
| 488 | * |
| 489 | * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]); |
| 490 | * |
| 491 | * console.log(buf.readBigUInt64LE(0)); |
| 492 | * // Prints: 18446744069414584320n |
| 493 | * ``` |
| 494 | * @since v12.0.0, v10.20.0 |
| 495 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 496 | */ |
| 497 | readBigUInt64LE(offset?: number): bigint; |
| 498 | |
| 499 | /** |
| 500 | * @alias Buffer.readBigUInt64LE |
| 501 | * @since v14.10.0, v12.19.0 |
| 502 | */ |
| 503 | readBigUint64LE(offset?: number): bigint; |
| 504 | |
| 505 | /** |
| 506 | * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`. |
| 507 | * |
| 508 | * Integers read from a `Buffer` are interpreted as two's complement signed |
| 509 | * values. |
| 510 | * @since v12.0.0, v10.20.0 |
| 511 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 512 | */ |
| 513 | readBigInt64BE(offset?: number): bigint; |
| 514 | |
| 515 | /** |
| 516 | * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`. |
| 517 | * |
| 518 | * Integers read from a `Buffer` are interpreted as two's complement signed |
| 519 | * values. |
| 520 | * @since v12.0.0, v10.20.0 |
| 521 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`. |
| 522 | */ |
| 523 | readBigInt64LE(offset?: number): bigint; |
| 524 | |
| 525 | /** |
| 526 | * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting |
| 527 | * up to 48 bits of accuracy. |
| 528 | * |
| 529 | * This function is also available under the `readUintLE` alias. |
| 530 | * |
| 531 | * ```js |
| 532 | * import { Buffer } from 'node:buffer'; |
| 533 | * |
| 534 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); |
| 535 | * |
| 536 | * console.log(buf.readUIntLE(0, 6).toString(16)); |
| 537 | * // Prints: ab9078563412 |
| 538 | * ``` |
| 539 | * @since v0.11.15 |
| 540 | * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 541 | * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. |
| 542 | */ |
| 543 | readUIntLE(offset: number, byteLength: number): number; |
| 544 | |
| 545 | /** |
| 546 | * @alias Buffer.readUIntLE |
| 547 | * @since v14.9.0, v12.19.0 |
| 548 | */ |
| 549 | readUintLE(offset: number, byteLength: number): number; |
| 550 | |
| 551 | /** |
| 552 | * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting |
| 553 | * up to 48 bits of accuracy. |
| 554 | * |
| 555 | * This function is also available under the `readUintBE` alias. |
| 556 | * |
| 557 | * ```js |
| 558 | * import { Buffer } from 'node:buffer'; |
| 559 | * |
| 560 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); |
| 561 | * |
| 562 | * console.log(buf.readUIntBE(0, 6).toString(16)); |
| 563 | * // Prints: 1234567890ab |
| 564 | * console.log(buf.readUIntBE(1, 6).toString(16)); |
| 565 | * // Throws ERR_OUT_OF_RANGE. |
| 566 | * ``` |
| 567 | * @since v0.11.15 |
| 568 | * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 569 | * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. |
| 570 | */ |
| 571 | readUIntBE(offset: number, byteLength: number): number; |
| 572 | |
| 573 | /** |
| 574 | * @alias Buffer.readUIntBE |
| 575 | * @since v14.9.0, v12.19.0 |
| 576 | */ |
| 577 | readUintBE(offset: number, byteLength: number): number; |
| 578 | |
| 579 | /** |
| 580 | * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value |
| 581 | * supporting up to 48 bits of accuracy. |
| 582 | * |
| 583 | * ```js |
| 584 | * import { Buffer } from 'node:buffer'; |
| 585 | * |
| 586 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); |
| 587 | * |
| 588 | * console.log(buf.readIntLE(0, 6).toString(16)); |
| 589 | * // Prints: -546f87a9cbee |
| 590 | * ``` |
| 591 | * @since v0.11.15 |
| 592 | * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 593 | * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. |
| 594 | */ |
| 595 | readIntLE(offset: number, byteLength: number): number; |
| 596 | |
| 597 | /** |
| 598 | * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value |
| 599 | * supporting up to 48 bits of accuracy. |
| 600 | * |
| 601 | * ```js |
| 602 | * import { Buffer } from 'node:buffer'; |
| 603 | * |
| 604 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]); |
| 605 | * |
| 606 | * console.log(buf.readIntBE(0, 6).toString(16)); |
| 607 | * // Prints: 1234567890ab |
| 608 | * console.log(buf.readIntBE(1, 6).toString(16)); |
| 609 | * // Throws ERR_OUT_OF_RANGE. |
| 610 | * console.log(buf.readIntBE(1, 0).toString(16)); |
| 611 | * // Throws ERR_OUT_OF_RANGE. |
| 612 | * ``` |
| 613 | * @since v0.11.15 |
| 614 | * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`. |
| 615 | * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`. |
| 616 | */ |
| 617 | readIntBE(offset: number, byteLength: number): number; |
| 618 | |
| 619 | /** |
| 620 | * Reads an unsigned 8-bit integer from `buf` at the specified `offset`. |
| 621 | * |
| 622 | * This function is also available under the `readUint8` alias. |
| 623 | * |
| 624 | * ```js |
| 625 | * import { Buffer } from 'node:buffer'; |
| 626 | * |
| 627 | * const buf = Buffer.from([1, -2]); |
| 628 | * |
| 629 | * console.log(buf.readUInt8(0)); |
| 630 | * // Prints: 1 |
| 631 | * console.log(buf.readUInt8(1)); |
| 632 | * // Prints: 254 |
| 633 | * console.log(buf.readUInt8(2)); |
| 634 | * // Throws ERR_OUT_OF_RANGE. |
| 635 | * ``` |
| 636 | * @since v0.5.0 |
| 637 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. |
| 638 | */ |
| 639 | readUInt8(offset?: number): number; |
| 640 | |
| 641 | /** |
| 642 | * @alias Buffer.readUInt8 |
| 643 | * @since v14.9.0, v12.19.0 |
| 644 | */ |
| 645 | readUint8(offset?: number): number; |
| 646 | |
| 647 | /** |
| 648 | * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`. |
| 649 | * |
| 650 | * This function is also available under the `readUint16LE` alias. |
| 651 | * |
| 652 | * ```js |
| 653 | * import { Buffer } from 'node:buffer'; |
| 654 | * |
| 655 | * const buf = Buffer.from([0x12, 0x34, 0x56]); |
| 656 | * |
| 657 | * console.log(buf.readUInt16LE(0).toString(16)); |
| 658 | * // Prints: 3412 |
| 659 | * console.log(buf.readUInt16LE(1).toString(16)); |
| 660 | * // Prints: 5634 |
| 661 | * console.log(buf.readUInt16LE(2).toString(16)); |
| 662 | * // Throws ERR_OUT_OF_RANGE. |
| 663 | * ``` |
| 664 | * @since v0.5.5 |
| 665 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. |
| 666 | */ |
| 667 | readUInt16LE(offset?: number): number; |
| 668 | |
| 669 | /** |
| 670 | * @alias Buffer.readUInt16LE |
| 671 | * @since v14.9.0, v12.19.0 |
| 672 | */ |
| 673 | readUint16LE(offset?: number): number; |
| 674 | |
| 675 | /** |
| 676 | * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`. |
| 677 | * |
| 678 | * This function is also available under the `readUint16BE` alias. |
| 679 | * |
| 680 | * ```js |
| 681 | * import { Buffer } from 'node:buffer'; |
| 682 | * |
| 683 | * const buf = Buffer.from([0x12, 0x34, 0x56]); |
| 684 | * |
| 685 | * console.log(buf.readUInt16BE(0).toString(16)); |
| 686 | * // Prints: 1234 |
| 687 | * console.log(buf.readUInt16BE(1).toString(16)); |
| 688 | * // Prints: 3456 |
| 689 | * ``` |
| 690 | * @since v0.5.5 |
| 691 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. |
| 692 | */ |
| 693 | readUInt16BE(offset?: number): number; |
| 694 | |
| 695 | /** |
| 696 | * @alias Buffer.readUInt16BE |
| 697 | * @since v14.9.0, v12.19.0 |
| 698 | */ |
| 699 | readUint16BE(offset?: number): number; |
| 700 | |
| 701 | /** |
| 702 | * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`. |
| 703 | * |
| 704 | * This function is also available under the `readUint32LE` alias. |
| 705 | * |
| 706 | * ```js |
| 707 | * import { Buffer } from 'node:buffer'; |
| 708 | * |
| 709 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); |
| 710 | * |
| 711 | * console.log(buf.readUInt32LE(0).toString(16)); |
| 712 | * // Prints: 78563412 |
| 713 | * console.log(buf.readUInt32LE(1).toString(16)); |
| 714 | * // Throws ERR_OUT_OF_RANGE. |
| 715 | * ``` |
| 716 | * @since v0.5.5 |
| 717 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 718 | */ |
| 719 | readUInt32LE(offset?: number): number; |
| 720 | |
| 721 | /** |
| 722 | * @alias Buffer.readUInt32LE |
| 723 | * @since v14.9.0, v12.19.0 |
| 724 | */ |
| 725 | readUint32LE(offset?: number): number; |
| 726 | |
| 727 | /** |
| 728 | * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`. |
| 729 | * |
| 730 | * This function is also available under the `readUint32BE` alias. |
| 731 | * |
| 732 | * ```js |
| 733 | * import { Buffer } from 'node:buffer'; |
| 734 | * |
| 735 | * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]); |
| 736 | * |
| 737 | * console.log(buf.readUInt32BE(0).toString(16)); |
| 738 | * // Prints: 12345678 |
| 739 | * ``` |
| 740 | * @since v0.5.5 |
| 741 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 742 | */ |
| 743 | readUInt32BE(offset?: number): number; |
| 744 | |
| 745 | /** |
| 746 | * @alias Buffer.readUInt32BE |
| 747 | * @since v14.9.0, v12.19.0 |
| 748 | */ |
| 749 | readUint32BE(offset?: number): number; |
| 750 | |
| 751 | /** |
| 752 | * Reads a signed 8-bit integer from `buf` at the specified `offset`. |
| 753 | * |
| 754 | * Integers read from a `Buffer` are interpreted as two's complement signed values. |
| 755 | * |
| 756 | * ```js |
| 757 | * import { Buffer } from 'node:buffer'; |
| 758 | * |
| 759 | * const buf = Buffer.from([-1, 5]); |
| 760 | * |
| 761 | * console.log(buf.readInt8(0)); |
| 762 | * // Prints: -1 |
| 763 | * console.log(buf.readInt8(1)); |
| 764 | * // Prints: 5 |
| 765 | * console.log(buf.readInt8(2)); |
| 766 | * // Throws ERR_OUT_OF_RANGE. |
| 767 | * ``` |
| 768 | * @since v0.5.0 |
| 769 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`. |
| 770 | */ |
| 771 | readInt8(offset?: number): number; |
| 772 | |
| 773 | /** |
| 774 | * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`. |
| 775 | * |
| 776 | * Integers read from a `Buffer` are interpreted as two's complement signed values. |
| 777 | * |
| 778 | * ```js |
| 779 | * import { Buffer } from 'node:buffer'; |
| 780 | * |
| 781 | * const buf = Buffer.from([0, 5]); |
| 782 | * |
| 783 | * console.log(buf.readInt16LE(0)); |
| 784 | * // Prints: 1280 |
| 785 | * console.log(buf.readInt16LE(1)); |
| 786 | * // Throws ERR_OUT_OF_RANGE. |
| 787 | * ``` |
| 788 | * @since v0.5.5 |
| 789 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. |
| 790 | */ |
| 791 | readInt16LE(offset?: number): number; |
| 792 | |
| 793 | /** |
| 794 | * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`. |
| 795 | * |
| 796 | * Integers read from a `Buffer` are interpreted as two's complement signed values. |
| 797 | * |
| 798 | * ```js |
| 799 | * import { Buffer } from 'node:buffer'; |
| 800 | * |
| 801 | * const buf = Buffer.from([0, 5]); |
| 802 | * |
| 803 | * console.log(buf.readInt16BE(0)); |
| 804 | * // Prints: 5 |
| 805 | * ``` |
| 806 | * @since v0.5.5 |
| 807 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`. |
| 808 | */ |
| 809 | readInt16BE(offset?: number): number; |
| 810 | |
| 811 | /** |
| 812 | * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`. |
| 813 | * |
| 814 | * Integers read from a `Buffer` are interpreted as two's complement signed values. |
| 815 | * |
| 816 | * ```js |
| 817 | * import { Buffer } from 'node:buffer'; |
| 818 | * |
| 819 | * const buf = Buffer.from([0, 0, 0, 5]); |
| 820 | * |
| 821 | * console.log(buf.readInt32LE(0)); |
| 822 | * // Prints: 83886080 |
| 823 | * console.log(buf.readInt32LE(1)); |
| 824 | * // Throws ERR_OUT_OF_RANGE. |
| 825 | * ``` |
| 826 | * @since v0.5.5 |
| 827 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 828 | */ |
| 829 | readInt32LE(offset?: number): number; |
| 830 | |
| 831 | /** |
| 832 | * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`. |
| 833 | * |
| 834 | * Integers read from a `Buffer` are interpreted as two's complement signed values. |
| 835 | * |
| 836 | * ```js |
| 837 | * import { Buffer } from 'node:buffer'; |
| 838 | * |
| 839 | * const buf = Buffer.from([0, 0, 0, 5]); |
| 840 | * |
| 841 | * console.log(buf.readInt32BE(0)); |
| 842 | * // Prints: 5 |
| 843 | * ``` |
| 844 | * @since v0.5.5 |
| 845 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 846 | */ |
| 847 | readInt32BE(offset?: number): number; |
| 848 | |
| 849 | /** |
| 850 | * Reads a 32-bit, little-endian float from `buf` at the specified `offset`. |
| 851 | * |
| 852 | * ```js |
| 853 | * import { Buffer } from 'node:buffer'; |
| 854 | * |
| 855 | * const buf = Buffer.from([1, 2, 3, 4]); |
| 856 | * |
| 857 | * console.log(buf.readFloatLE(0)); |
| 858 | * // Prints: 1.539989614439558e-36 |
| 859 | * console.log(buf.readFloatLE(1)); |
| 860 | * // Throws ERR_OUT_OF_RANGE. |
| 861 | * ``` |
| 862 | * @since v0.11.15 |
| 863 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 864 | */ |
| 865 | readFloatLE(offset?: number): number; |
| 866 | |
| 867 | /** |
| 868 | * Reads a 32-bit, big-endian float from `buf` at the specified `offset`. |
| 869 | * |
| 870 | * ```js |
| 871 | * import { Buffer } from 'node:buffer'; |
| 872 | * |
| 873 | * const buf = Buffer.from([1, 2, 3, 4]); |
| 874 | * |
| 875 | * console.log(buf.readFloatBE(0)); |
| 876 | * // Prints: 2.387939260590663e-38 |
| 877 | * ``` |
| 878 | * @since v0.11.15 |
| 879 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`. |
| 880 | */ |
| 881 | readFloatBE(offset?: number): number; |
| 882 | |
| 883 | /** |
| 884 | * Reads a 64-bit, little-endian double from `buf` at the specified `offset`. |
| 885 | * |
| 886 | * ```js |
| 887 | * import { Buffer } from 'node:buffer'; |
| 888 | * |
| 889 | * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); |
| 890 | * |
| 891 | * console.log(buf.readDoubleLE(0)); |
| 892 | * // Prints: 5.447603722011605e-270 |
| 893 | * console.log(buf.readDoubleLE(1)); |
| 894 | * // Throws ERR_OUT_OF_RANGE. |
| 895 | * ``` |
| 896 | * @since v0.11.15 |
| 897 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. |
| 898 | */ |
| 899 | readDoubleLE(offset?: number): number; |
| 900 | |
| 901 | /** |
| 902 | * Reads a 64-bit, big-endian double from `buf` at the specified `offset`. |
| 903 | * |
| 904 | * ```js |
| 905 | * import { Buffer } from 'node:buffer'; |
| 906 | * |
| 907 | * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); |
| 908 | * |
| 909 | * console.log(buf.readDoubleBE(0)); |
| 910 | * // Prints: 8.20788039913184e-304 |
| 911 | * ``` |
| 912 | * @since v0.11.15 |
| 913 | * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`. |
| 914 | */ |
| 915 | readDoubleBE(offset?: number): number; |
| 916 | |
| 917 | /** |
| 918 | * Writes `value` to `buf` at the specified `offset`. `value` must be a |
| 919 | * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything |
| 920 | * other than an unsigned 8-bit integer. |
| 921 | * |
| 922 | * This function is also available under the `writeUint8` alias. |
| 923 | * |
| 924 | * ```js |
| 925 | * import { Buffer } from 'node:buffer'; |
| 926 | * |
| 927 | * const buf = Buffer.allocUnsafe(4); |
| 928 | * |
| 929 | * buf.writeUInt8(0x3, 0); |
| 930 | * buf.writeUInt8(0x4, 1); |
| 931 | * buf.writeUInt8(0x23, 2); |
| 932 | * buf.writeUInt8(0x42, 3); |
| 933 | * |
| 934 | * console.log(buf); |
| 935 | * // Prints: <Buffer 03 04 23 42> |
| 936 | * ``` |
| 937 | * @since v0.5.0 |
| 938 | * @param value Number to be written to `buf`. |
| 939 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. |
| 940 | * @return `offset` plus the number of bytes written. |
| 941 | */ |
| 942 | writeUInt8(value: number, offset?: number): number; |
| 943 | /** |
| 944 | * @alias Buffer.writeUInt8 |
| 945 | * @since v14.9.0, v12.19.0 |
| 946 | */ |
| 947 | writeUint8(value: number, offset?: number): number; |
| 948 | /** |
| 949 | * 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 |
| 950 | * anything other than an unsigned 16-bit integer. |
| 951 | * |
| 952 | * This function is also available under the `writeUint16LE` alias. |
| 953 | * |
| 954 | * ```js |
| 955 | * import { Buffer } from 'node:buffer'; |
| 956 | * |
| 957 | * const buf = Buffer.allocUnsafe(4); |
| 958 | * |
| 959 | * buf.writeUInt16LE(0xdead, 0); |
| 960 | * buf.writeUInt16LE(0xbeef, 2); |
| 961 | * |
| 962 | * console.log(buf); |
| 963 | * // Prints: <Buffer ad de ef be> |
| 964 | * ``` |
| 965 | * @since v0.5.5 |
| 966 | * @param value Number to be written to `buf`. |
| 967 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. |
| 968 | * @return `offset` plus the number of bytes written. |
| 969 | */ |
| 970 | writeUInt16LE(value: number, offset?: number): number; |
| 971 | /** |
| 972 | * @alias Buffer.writeUInt16LE |
| 973 | * @since v14.9.0, v12.19.0 |
| 974 | */ |
| 975 | writeUint16LE(value: number, offset?: number): number; |
| 976 | /** |
| 977 | * 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 |
| 978 | * unsigned 16-bit integer. |
| 979 | * |
| 980 | * This function is also available under the `writeUint16BE` alias. |
| 981 | * |
| 982 | * ```js |
| 983 | * import { Buffer } from 'node:buffer'; |
| 984 | * |
| 985 | * const buf = Buffer.allocUnsafe(4); |
| 986 | * |
| 987 | * buf.writeUInt16BE(0xdead, 0); |
| 988 | * buf.writeUInt16BE(0xbeef, 2); |
| 989 | * |
| 990 | * console.log(buf); |
| 991 | * // Prints: <Buffer de ad be ef> |
| 992 | * ``` |
| 993 | * @since v0.5.5 |
| 994 | * @param value Number to be written to `buf`. |
| 995 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. |
| 996 | * @return `offset` plus the number of bytes written. |
| 997 | */ |
| 998 | writeUInt16BE(value: number, offset?: number): number; |
| 999 | /** |
| 1000 | * @alias Buffer.writeUInt16BE |
| 1001 | * @since v14.9.0, v12.19.0 |
| 1002 | */ |
| 1003 | writeUint16BE(value: number, offset?: number): number; |
| 1004 | /** |
| 1005 | * 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 |
| 1006 | * anything other than an unsigned 32-bit integer. |
| 1007 | * |
| 1008 | * This function is also available under the `writeUint32LE` alias. |
| 1009 | * |
| 1010 | * ```js |
| 1011 | * import { Buffer } from 'node:buffer'; |
| 1012 | * |
| 1013 | * const buf = Buffer.allocUnsafe(4); |
| 1014 | * |
| 1015 | * buf.writeUInt32LE(0xfeedface, 0); |
| 1016 | * |
| 1017 | * console.log(buf); |
| 1018 | * // Prints: <Buffer ce fa ed fe> |
| 1019 | * ``` |
| 1020 | * @since v0.5.5 |
| 1021 | * @param value Number to be written to `buf`. |
| 1022 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1023 | * @return `offset` plus the number of bytes written. |
| 1024 | */ |
| 1025 | writeUInt32LE(value: number, offset?: number): number; |
| 1026 | /** |
| 1027 | * @alias Buffer.writeUInt32LE |
| 1028 | * @since v14.9.0, v12.19.0 |
| 1029 | */ |
| 1030 | writeUint32LE(value: number, offset?: number): number; |
| 1031 | /** |
| 1032 | * 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 |
| 1033 | * unsigned 32-bit integer. |
| 1034 | * |
| 1035 | * This function is also available under the `writeUint32BE` alias. |
| 1036 | * |
| 1037 | * ```js |
| 1038 | * import { Buffer } from 'node:buffer'; |
| 1039 | * |
| 1040 | * const buf = Buffer.allocUnsafe(4); |
| 1041 | * |
| 1042 | * buf.writeUInt32BE(0xfeedface, 0); |
| 1043 | * |
| 1044 | * console.log(buf); |
| 1045 | * // Prints: <Buffer fe ed fa ce> |
| 1046 | * ``` |
| 1047 | * @since v0.5.5 |
| 1048 | * @param value Number to be written to `buf`. |
| 1049 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1050 | * @return `offset` plus the number of bytes written. |
| 1051 | */ |
| 1052 | writeUInt32BE(value: number, offset?: number): number; |
| 1053 | /** |
| 1054 | * @alias Buffer.writeUInt32BE |
| 1055 | * @since v14.9.0, v12.19.0 |
| 1056 | */ |
| 1057 | writeUint32BE(value: number, offset?: number): number; |
| 1058 | /** |
| 1059 | * Writes `value` to `buf` at the specified `offset`. `value` must be a valid |
| 1060 | * signed 8-bit integer. Behavior is undefined when `value` is anything other than |
| 1061 | * a signed 8-bit integer. |
| 1062 | * |
| 1063 | * `value` is interpreted and written as a two's complement signed integer. |
| 1064 | * |
| 1065 | * ```js |
| 1066 | * import { Buffer } from 'node:buffer'; |
| 1067 | * |
| 1068 | * const buf = Buffer.allocUnsafe(2); |
| 1069 | * |
| 1070 | * buf.writeInt8(2, 0); |
| 1071 | * buf.writeInt8(-2, 1); |
| 1072 | * |
| 1073 | * console.log(buf); |
| 1074 | * // Prints: <Buffer 02 fe> |
| 1075 | * ``` |
| 1076 | * @since v0.5.0 |
| 1077 | * @param value Number to be written to `buf`. |
| 1078 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`. |
| 1079 | * @return `offset` plus the number of bytes written. |
| 1080 | */ |
| 1081 | writeInt8(value: number, offset?: number): number; |
| 1082 | /** |
| 1083 | * 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 |
| 1084 | * anything other than a signed 16-bit integer. |
| 1085 | * |
| 1086 | * The `value` is interpreted and written as a two's complement signed integer. |
| 1087 | * |
| 1088 | * ```js |
| 1089 | * import { Buffer } from 'node:buffer'; |
| 1090 | * |
| 1091 | * const buf = Buffer.allocUnsafe(2); |
| 1092 | * |
| 1093 | * buf.writeInt16LE(0x0304, 0); |
| 1094 | * |
| 1095 | * console.log(buf); |
| 1096 | * // Prints: <Buffer 04 03> |
| 1097 | * ``` |
| 1098 | * @since v0.5.5 |
| 1099 | * @param value Number to be written to `buf`. |
| 1100 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. |
| 1101 | * @return `offset` plus the number of bytes written. |
| 1102 | */ |
| 1103 | writeInt16LE(value: number, offset?: number): number; |
| 1104 | /** |
| 1105 | * 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 |
| 1106 | * anything other than a signed 16-bit integer. |
| 1107 | * |
| 1108 | * The `value` is interpreted and written as a two's complement signed integer. |
| 1109 | * |
| 1110 | * ```js |
| 1111 | * import { Buffer } from 'node:buffer'; |
| 1112 | * |
| 1113 | * const buf = Buffer.allocUnsafe(2); |
| 1114 | * |
| 1115 | * buf.writeInt16BE(0x0102, 0); |
| 1116 | * |
| 1117 | * console.log(buf); |
| 1118 | * // Prints: <Buffer 01 02> |
| 1119 | * ``` |
| 1120 | * @since v0.5.5 |
| 1121 | * @param value Number to be written to `buf`. |
| 1122 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`. |
| 1123 | * @return `offset` plus the number of bytes written. |
| 1124 | */ |
| 1125 | writeInt16BE(value: number, offset?: number): number; |
| 1126 | /** |
| 1127 | * 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 |
| 1128 | * anything other than a signed 32-bit integer. |
| 1129 | * |
| 1130 | * The `value` is interpreted and written as a two's complement signed integer. |
| 1131 | * |
| 1132 | * ```js |
| 1133 | * import { Buffer } from 'node:buffer'; |
| 1134 | * |
| 1135 | * const buf = Buffer.allocUnsafe(4); |
| 1136 | * |
| 1137 | * buf.writeInt32LE(0x05060708, 0); |
| 1138 | * |
| 1139 | * console.log(buf); |
| 1140 | * // Prints: <Buffer 08 07 06 05> |
| 1141 | * ``` |
| 1142 | * @since v0.5.5 |
| 1143 | * @param value Number to be written to `buf`. |
| 1144 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1145 | * @return `offset` plus the number of bytes written. |
| 1146 | */ |
| 1147 | writeInt32LE(value: number, offset?: number): number; |
| 1148 | /** |
| 1149 | * 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 |
| 1150 | * anything other than a signed 32-bit integer. |
| 1151 | * |
| 1152 | * The `value` is interpreted and written as a two's complement signed integer. |
| 1153 | * |
| 1154 | * ```js |
| 1155 | * import { Buffer } from 'node:buffer'; |
| 1156 | * |
| 1157 | * const buf = Buffer.allocUnsafe(4); |
| 1158 | * |
| 1159 | * buf.writeInt32BE(0x01020304, 0); |
| 1160 | * |
| 1161 | * console.log(buf); |
| 1162 | * // Prints: <Buffer 01 02 03 04> |
| 1163 | * ``` |
| 1164 | * @since v0.5.5 |
| 1165 | * @param value Number to be written to `buf`. |
| 1166 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1167 | * @return `offset` plus the number of bytes written. |
| 1168 | */ |
| 1169 | writeInt32BE(value: number, offset?: number): number; |
| 1170 | /** |
| 1171 | * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is |
| 1172 | * undefined when `value` is anything other than a JavaScript number. |
| 1173 | * |
| 1174 | * ```js |
| 1175 | * import { Buffer } from 'node:buffer'; |
| 1176 | * |
| 1177 | * const buf = Buffer.allocUnsafe(4); |
| 1178 | * |
| 1179 | * buf.writeFloatLE(0xcafebabe, 0); |
| 1180 | * |
| 1181 | * console.log(buf); |
| 1182 | * // Prints: <Buffer bb fe 4a 4f> |
| 1183 | * ``` |
| 1184 | * @since v0.11.15 |
| 1185 | * @param value Number to be written to `buf`. |
| 1186 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1187 | * @return `offset` plus the number of bytes written. |
| 1188 | */ |
| 1189 | writeFloatLE(value: number, offset?: number): number; |
| 1190 | /** |
| 1191 | * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is |
| 1192 | * undefined when `value` is anything other than a JavaScript number. |
| 1193 | * |
| 1194 | * ```js |
| 1195 | * import { Buffer } from 'node:buffer'; |
| 1196 | * |
| 1197 | * const buf = Buffer.allocUnsafe(4); |
| 1198 | * |
| 1199 | * buf.writeFloatBE(0xcafebabe, 0); |
| 1200 | * |
| 1201 | * console.log(buf); |
| 1202 | * // Prints: <Buffer 4f 4a fe bb> |
| 1203 | * ``` |
| 1204 | * @since v0.11.15 |
| 1205 | * @param value Number to be written to `buf`. |
| 1206 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`. |
| 1207 | * @return `offset` plus the number of bytes written. |
| 1208 | */ |
| 1209 | writeFloatBE(value: number, offset?: number): number; |
| 1210 | /** |
| 1211 | * 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 |
| 1212 | * other than a JavaScript number. |
| 1213 | * |
| 1214 | * ```js |
| 1215 | * import { Buffer } from 'node:buffer'; |
| 1216 | * |
| 1217 | * const buf = Buffer.allocUnsafe(8); |
| 1218 | * |
| 1219 | * buf.writeDoubleLE(123.456, 0); |
| 1220 | * |
| 1221 | * console.log(buf); |
| 1222 | * // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40> |
| 1223 | * ``` |
| 1224 | * @since v0.11.15 |
| 1225 | * @param value Number to be written to `buf`. |
| 1226 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. |
| 1227 | * @return `offset` plus the number of bytes written. |
| 1228 | */ |
| 1229 | writeDoubleLE(value: number, offset?: number): number; |
| 1230 | /** |
| 1231 | * 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 |
| 1232 | * other than a JavaScript number. |
| 1233 | * |
| 1234 | * ```js |
| 1235 | * import { Buffer } from 'node:buffer'; |
| 1236 | * |
| 1237 | * const buf = Buffer.allocUnsafe(8); |
| 1238 | * |
| 1239 | * buf.writeDoubleBE(123.456, 0); |
| 1240 | * |
| 1241 | * console.log(buf); |
| 1242 | * // Prints: <Buffer 40 5e dd 2f 1a 9f be 77> |
| 1243 | * ``` |
| 1244 | * @since v0.11.15 |
| 1245 | * @param value Number to be written to `buf`. |
| 1246 | * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`. |
| 1247 | * @return `offset` plus the number of bytes written. |
| 1248 | */ |
| 1249 | writeDoubleBE(value: number, offset?: number): number; |
| 1250 | /** |
| 1251 | * Fills `buf` with the specified `value`. If the `offset` and `end` are not given, |
| 1252 | * the entire `buf` will be filled: |
| 1253 | * |
| 1254 | * ```js |
| 1255 | * import { Buffer } from 'node:buffer'; |
| 1256 | * |
| 1257 | * // Fill a `Buffer` with the ASCII character 'h'. |
| 1258 | * |
| 1259 | * const b = Buffer.allocUnsafe(50).fill('h'); |
| 1260 | * |
| 1261 | * console.log(b.toString()); |
| 1262 | * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh |
| 1263 | * |
| 1264 | * // Fill a buffer with empty string |
| 1265 | * const c = Buffer.allocUnsafe(5).fill(''); |
| 1266 | * |
| 1267 | * console.log(c.fill('')); |
| 1268 | * // Prints: <Buffer 00 00 00 00 00> |
| 1269 | * ``` |
| 1270 | * |
| 1271 | * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or |
| 1272 | * integer. If the resulting integer is greater than `255` (decimal), `buf` will be |
| 1273 | * filled with `value & 255`. |
| 1274 | * |
| 1275 | * If the final write of a `fill()` operation falls on a multi-byte character, |
| 1276 | * then only the bytes of that character that fit into `buf` are written: |
| 1277 | * |
| 1278 | * ```js |
| 1279 | * import { Buffer } from 'node:buffer'; |
| 1280 | * |
| 1281 | * // Fill a `Buffer` with character that takes up two bytes in UTF-8. |
| 1282 | * |
| 1283 | * console.log(Buffer.allocUnsafe(5).fill('\u0222')); |
| 1284 | * // Prints: <Buffer c8 a2 c8 a2 c8> |
| 1285 | * ``` |
| 1286 | * |
| 1287 | * If `value` contains invalid characters, it is truncated; if no valid |
| 1288 | * fill data remains, an exception is thrown: |
| 1289 | * |
| 1290 | * ```js |
| 1291 | * import { Buffer } from 'node:buffer'; |
| 1292 | * |
| 1293 | * const buf = Buffer.allocUnsafe(5); |
| 1294 | * |
| 1295 | * console.log(buf.fill('a')); |
| 1296 | * // Prints: <Buffer 61 61 61 61 61> |
| 1297 | * console.log(buf.fill('aazz', 'hex')); |
| 1298 | * // Prints: <Buffer aa aa aa aa aa> |
| 1299 | * console.log(buf.fill('zz', 'hex')); |
| 1300 | * // Throws an exception. |
| 1301 | * ``` |
| 1302 | * @since v0.5.0 |
| 1303 | * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`. |
| 1304 | * @param [offset=0] Number of bytes to skip before starting to fill `buf`. |
| 1305 | * @param [end=buf.length] Where to stop filling `buf` (not inclusive). |
| 1306 | * @param [encoding='utf8'] The encoding for `value` if `value` is a string. |
| 1307 | * @return A reference to `buf`. |
| 1308 | */ |
| 1309 | |
| 1310 | } |
| 1311 | |
| 1312 | var Buffer: BufferConstructor; |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | declare module "node:buffer" { |
| 1317 | export * from "buffer"; |
| 1318 | } |