{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"buffer","path":"/buffer","type":"module","module":"buffer","title":"Buffer","introducedIn":"v0.1.90","sourceLink":{"path":"lib/buffer.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/buffer.js"},"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`Buffer` objects are used to represent a fixed-length sequence of bytes. Many\nNode.js APIs support `Buffer`s.\n\nThe `Buffer` class is a subclass of JavaScript's {Uint8Array} class and\nextends it with methods that cover additional use cases. Node.js APIs accept\nplain {Uint8Array}s wherever `Buffer`s are supported as well.\n\nWhile the `Buffer` class is available within the global scope, it is still\nrecommended to explicitly reference it via an import or require statement.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Creates a zero-filled Buffer of length 10.\nconst buf1 = Buffer.alloc(10);\n\n// Creates a Buffer of length 10,\n// filled with bytes which all have the value `1`.\nconst buf2 = Buffer.alloc(10, 1);\n\n// Creates an uninitialized buffer of length 10.\n// This is faster than calling Buffer.alloc() but the returned\n// Buffer instance might contain old data that needs to be\n// overwritten using fill(), write(), or other functions that fill the Buffer's\n// contents.\nconst buf3 = Buffer.allocUnsafe(10);\n\n// Creates a Buffer containing the bytes [1, 2, 3].\nconst buf4 = Buffer.from([1, 2, 3]);\n\n// Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries\n// are all truncated using `(value & 255)` to fit into the range 0–255.\nconst buf5 = Buffer.from([257, 257.5, -255, '1']);\n\n// Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':\n// [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)\n// [116, 195, 169, 115, 116] (in decimal notation)\nconst buf6 = Buffer.from('tést');\n\n// Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].\nconst buf7 = Buffer.from('tést', 'latin1');\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Creates a zero-filled Buffer of length 10.\nconst buf1 = Buffer.alloc(10);\n\n// Creates a Buffer of length 10,\n// filled with bytes which all have the value `1`.\nconst buf2 = Buffer.alloc(10, 1);\n\n// Creates an uninitialized buffer of length 10.\n// This is faster than calling Buffer.alloc() but the returned\n// Buffer instance might contain old data that needs to be\n// overwritten using fill(), write(), or other functions that fill the Buffer's\n// contents.\nconst buf3 = Buffer.allocUnsafe(10);\n\n// Creates a Buffer containing the bytes [1, 2, 3].\nconst buf4 = Buffer.from([1, 2, 3]);\n\n// Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries\n// are all truncated using `(value & 255)` to fit into the range 0–255.\nconst buf5 = Buffer.from([257, 257.5, -255, '1']);\n\n// Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':\n// [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)\n// [116, 195, 169, 115, 116] (in decimal notation)\nconst buf6 = Buffer.from('tést');\n\n// Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].\nconst buf7 = Buffer.from('tést', 'latin1');\n```","summary":"`Buffer` objects are used to represent a fixed-length sequence of bytes. Many Node.js APIs support `Buffer`s.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Creates a zero-filled Buffer of length 10.\nconst buf1 = Buffer.alloc(10);\n\n// Creates a Buffer of length 10,\n// filled with bytes which all have the value `1`.\nconst buf2 = Buffer.alloc(10, 1);\n\n// Creates an uninitialized buffer of length 10.\n// This is faster than calling Buffer.alloc() but the returned\n// Buffer instance might contain old data that needs to be\n// overwritten using fill(), write(), or other functions that fill the Buffer's\n// contents.\nconst buf3 = Buffer.allocUnsafe(10);\n\n// Creates a Buffer containing the bytes [1, 2, 3].\nconst buf4 = Buffer.from([1, 2, 3]);\n\n// Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries\n// are all truncated using `(value & 255)` to fit into the range 0–255.\nconst buf5 = Buffer.from([257, 257.5, -255, '1']);\n\n// Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':\n// [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)\n// [116, 195, 169, 115, 116] (in decimal notation)\nconst buf6 = Buffer.from('tést');\n\n// Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].\nconst buf7 = Buffer.from('tést', 'latin1');"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Creates a zero-filled Buffer of length 10.\nconst buf1 = Buffer.alloc(10);\n\n// Creates a Buffer of length 10,\n// filled with bytes which all have the value `1`.\nconst buf2 = Buffer.alloc(10, 1);\n\n// Creates an uninitialized buffer of length 10.\n// This is faster than calling Buffer.alloc() but the returned\n// Buffer instance might contain old data that needs to be\n// overwritten using fill(), write(), or other functions that fill the Buffer's\n// contents.\nconst buf3 = Buffer.allocUnsafe(10);\n\n// Creates a Buffer containing the bytes [1, 2, 3].\nconst buf4 = Buffer.from([1, 2, 3]);\n\n// Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries\n// are all truncated using `(value & 255)` to fit into the range 0–255.\nconst buf5 = Buffer.from([257, 257.5, -255, '1']);\n\n// Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':\n// [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)\n// [116, 195, 169, 115, 116] (in decimal notation)\nconst buf6 = Buffer.from('tést');\n\n// Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].\nconst buf7 = Buffer.from('tést', 'latin1');"}],"children":[{"kind":"section","id":"buffers-and-character-encodings","name":"Buffers and character encodings","title":"Buffers and character encodings","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.7.0","v14.18.0"],"prUrl":"https://github.com/nodejs/node/pull/36952","commit":null,"description":"Introduced `base64url` encoding."},{"versions":["v6.4.0"],"prUrl":"https://github.com/nodejs/node/pull/7111","commit":null,"description":"Introduced `latin1` as an alias for `binary`."},{"versions":["v5.0.0"],"prUrl":"https://github.com/nodejs/node/pull/2859","commit":null,"description":"Removed the deprecated `raw` and `raws` encodings."}],"description":"When converting between `Buffer`s and strings, a character encoding may be\nspecified. If no character encoding is specified, UTF-8 will be used as the\ndefault.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('hello world', 'utf8');\n\nconsole.log(buf.toString('hex'));\n// Prints: 68656c6c6f20776f726c64\nconsole.log(buf.toString('base64'));\n// Prints: aGVsbG8gd29ybGQ=\n\nconsole.log(Buffer.from('fhqwhgads', 'utf8'));\n// Prints: <Buffer 66 68 71 77 68 67 61 64 73>\nconsole.log(Buffer.from('fhqwhgads', 'utf16le'));\n// Prints: <Buffer 66 00 68 00 71 00 77 00 68 00 67 00 61 00 64 00 73 00>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('hello world', 'utf8');\n\nconsole.log(buf.toString('hex'));\n// Prints: 68656c6c6f20776f726c64\nconsole.log(buf.toString('base64'));\n// Prints: aGVsbG8gd29ybGQ=\n\nconsole.log(Buffer.from('fhqwhgads', 'utf8'));\n// Prints: <Buffer 66 68 71 77 68 67 61 64 73>\nconsole.log(Buffer.from('fhqwhgads', 'utf16le'));\n// Prints: <Buffer 66 00 68 00 71 00 77 00 68 00 67 00 61 00 64 00 73 00>\n```\n\nNode.js buffers accept all case variations of encoding strings that they\nreceive. For example, UTF-8 can be specified as `'utf8'`, `'UTF8'`, or `'uTf8'`.\n\nThe character encodings currently supported by Node.js are the following:\n\n* `'utf8'` (alias: `'utf-8'`): Multi-byte encoded Unicode characters. Many web\n  pages and other document formats use [UTF-8](https://en.wikipedia.org/wiki/UTF-8). This is the default character\n  encoding. When decoding a `Buffer` into a string that does not exclusively\n  contain valid UTF-8 data, the Unicode replacement character `U+FFFD` � will be\n  used to represent those errors.\n\n* `'utf16le'` (alias: `'utf-16le'`): Multi-byte encoded Unicode characters.\n  Unlike `'utf8'`, each character in the string will be encoded using either 2\n  or 4 bytes. Node.js only supports the [little-endian](https://en.wikipedia.org/wiki/Endianness) variant of\n  [UTF-16](https://en.wikipedia.org/wiki/UTF-16).\n\n* `'latin1'`: Latin-1 stands for [ISO-8859-1](https://en.wikipedia.org/wiki/ISO-8859-1). This character encoding only\n  supports the Unicode characters from `U+0000` to `U+00FF`. Each character is\n  encoded using a single byte. Characters that do not fit into that range are\n  truncated and will be mapped to characters in that range.\n\nConverting a `Buffer` into a string using one of the above is referred to as\ndecoding, and converting a string into a `Buffer` is referred to as encoding.\n\nNode.js also supports the following binary-to-text encodings. For\nbinary-to-text encodings, the naming convention is reversed: Converting a\n`Buffer` into a string is typically referred to as encoding, and converting a\nstring into a `Buffer` as decoding.\n\n* `'base64'`: [Base64](https://en.wikipedia.org/wiki/Base64) encoding. When creating a `Buffer` from a string,\n  this encoding will also correctly accept \"URL and Filename Safe Alphabet\" as\n  specified in [RFC 4648, Section 5](https://tools.ietf.org/html/rfc4648#section-5). Whitespace characters such as spaces,\n  tabs, and new lines contained within the base64-encoded string are ignored.\n\n* `'base64url'`: [base64url](https://tools.ietf.org/html/rfc4648#section-5) encoding as specified in\n  [RFC 4648, Section 5](https://tools.ietf.org/html/rfc4648#section-5). When creating a `Buffer` from a string, this\n  encoding will also correctly accept regular base64-encoded strings. When\n  encoding a `Buffer` to a string, this encoding will omit padding.\n\n* `'hex'`: Encode each byte as two hexadecimal characters. Data truncation\n  may occur when decoding strings that do not exclusively consist of an even\n  number of hexadecimal characters. See below for an example.\n\nThe following legacy character encodings are also supported:\n\n* `'ascii'`: For 7-bit [ASCII](https://en.wikipedia.org/wiki/ASCII) data only. When encoding a string into a\n  `Buffer`, this is equivalent to using `'latin1'`. When decoding a `Buffer`\n  into a string, using this encoding will additionally unset the highest bit of\n  each byte before decoding as `'latin1'`.\n  Generally, there should be no reason to use this encoding, as `'utf8'`\n  (or, if the data is known to always be ASCII-only, `'latin1'`) will be a\n  better choice when encoding or decoding ASCII-only text. It is only provided\n  for legacy compatibility.\n\n* `'binary'`: Alias for `'latin1'`.\n  The name of this encoding can be very misleading, as all of the\n  encodings listed here convert between strings and binary data. For converting\n  between strings and `Buffer`s, typically `'utf8'` is the right choice.\n\n* `'ucs2'`, `'ucs-2'`: Aliases of `'utf16le'`. UCS-2 used to refer to a variant\n  of UTF-16 that did not support characters that had code points larger than\n  U+FFFF. In Node.js, these code points are always supported.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nBuffer.from('1ag123', 'hex');\n// Prints <Buffer 1a>, data truncated when first non-hexadecimal value\n// ('g') encountered.\n\nBuffer.from('1a7', 'hex');\n// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').\n\nBuffer.from('1634', 'hex');\n// Prints <Buffer 16 34>, all data represented.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nBuffer.from('1ag123', 'hex');\n// Prints <Buffer 1a>, data truncated when first non-hexadecimal value\n// ('g') encountered.\n\nBuffer.from('1a7', 'hex');\n// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').\n\nBuffer.from('1634', 'hex');\n// Prints <Buffer 16 34>, all data represented.\n```\n\nModern Web browsers follow the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) which aliases\nboth `'latin1'` and `'ISO-8859-1'` to `'win-1252'`. This means that while doing\nsomething like `http.get()`, if the returned charset is one of those listed in\nthe WHATWG specification it is possible that the server actually returned\n`'win-1252'`-encoded data, and using `'latin1'` encoding may incorrectly decode\nthe characters.","summary":"When converting between `Buffer`s and strings, a character encoding may be specified. If no character encoding is specified, UTF-8 will be used as the default.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('hello world', 'utf8');\n\nconsole.log(buf.toString('hex'));\n// Prints: 68656c6c6f20776f726c64\nconsole.log(buf.toString('base64'));\n// Prints: aGVsbG8gd29ybGQ=\n\nconsole.log(Buffer.from('fhqwhgads', 'utf8'));\n// Prints: <Buffer 66 68 71 77 68 67 61 64 73>\nconsole.log(Buffer.from('fhqwhgads', 'utf16le'));\n// Prints: <Buffer 66 00 68 00 71 00 77 00 68 00 67 00 61 00 64 00 73 00>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('hello world', 'utf8');\n\nconsole.log(buf.toString('hex'));\n// Prints: 68656c6c6f20776f726c64\nconsole.log(buf.toString('base64'));\n// Prints: aGVsbG8gd29ybGQ=\n\nconsole.log(Buffer.from('fhqwhgads', 'utf8'));\n// Prints: <Buffer 66 68 71 77 68 67 61 64 73>\nconsole.log(Buffer.from('fhqwhgads', 'utf16le'));\n// Prints: <Buffer 66 00 68 00 71 00 77 00 68 00 67 00 61 00 64 00 73 00>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nBuffer.from('1ag123', 'hex');\n// Prints <Buffer 1a>, data truncated when first non-hexadecimal value\n// ('g') encountered.\n\nBuffer.from('1a7', 'hex');\n// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').\n\nBuffer.from('1634', 'hex');\n// Prints <Buffer 16 34>, all data represented."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nBuffer.from('1ag123', 'hex');\n// Prints <Buffer 1a>, data truncated when first non-hexadecimal value\n// ('g') encountered.\n\nBuffer.from('1a7', 'hex');\n// Prints <Buffer 1a>, data truncated when data ends in single digit ('7').\n\nBuffer.from('1634', 'hex');\n// Prints <Buffer 16 34>, all data represented."}],"children":[]},{"kind":"section","id":"buffers-and-typedarrays","name":"Buffers and TypedArrays","title":"Buffers and TypedArrays","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v3.0.0"],"prUrl":"https://github.com/nodejs/node/pull/2002","commit":null,"description":"The `Buffer` class now inherits from `Uint8Array`."}],"description":"`Buffer` instances are also JavaScript {Uint8Array} and {TypedArray}\ninstances. All {TypedArray} methods and properties are available on `Buffer`s. There are,\nhowever, subtle incompatibilities between the `Buffer` API and the\n{TypedArray} API.\n\nIn particular:\n\n* While [`TypedArray.prototype.slice()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice) creates a copy of part of the `TypedArray`,\n  [`Buffer.prototype.slice()`](#bufslicestart-end) creates a view over the existing `Buffer`\n  without copying. This behavior can be surprising, and only exists for legacy\n  compatibility. [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray) can be used to achieve\n  the behavior of [`Buffer.prototype.slice()`](#bufslicestart-end) on both `Buffer`s\n  and other `TypedArray`s and should be preferred.\n* [`buf.toString()`](#buftostringencoding-start-end) is incompatible with its `TypedArray` equivalent.\n* A number of methods, e.g. [`buf.indexOf()`](#bufindexofvalue-start-end-encoding), support additional arguments.\n\nThere are two ways to create new {TypedArray} instances from a `Buffer`:\n\n* Passing a `Buffer` to a {TypedArray} constructor will copy the `Buffer`'s\n  contents, interpreted as an array of integers, and not as a byte sequence\n  of the target type.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\nconst uint32array = new Uint32Array(buf);\n\nconsole.log(uint32array);\n\n// Prints: Uint32Array(4) [ 1, 2, 3, 4 ]\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\nconst uint32array = new Uint32Array(buf);\n\nconsole.log(uint32array);\n\n// Prints: Uint32Array(4) [ 1, 2, 3, 4 ]\n```\n\n* Passing the `Buffer`'s underlying {ArrayBuffer} will create a\n  {TypedArray} that shares its memory with the `Buffer`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('hello', 'utf16le');\nconst uint16array = new Uint16Array(\n  buf.buffer,\n  buf.byteOffset,\n  buf.length / Uint16Array.BYTES_PER_ELEMENT);\n\nconsole.log(uint16array);\n\n// Prints: Uint16Array(5) [ 104, 101, 108, 108, 111 ]\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('hello', 'utf16le');\nconst uint16array = new Uint16Array(\n  buf.buffer,\n  buf.byteOffset,\n  buf.length / Uint16Array.BYTES_PER_ELEMENT);\n\nconsole.log(uint16array);\n\n// Prints: Uint16Array(5) [ 104, 101, 108, 108, 111 ]\n```\n\nIt is possible to create a new `Buffer` that shares the same allocated\nmemory as a {TypedArray} instance by using the `TypedArray` object's\n`.buffer` property in the same way. [`Buffer.from()`](#static-method-bufferfromarraybuffer-byteoffset-length)\nbehaves like `new Uint8Array()` in this context.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Copies the contents of `arr`.\nconst buf1 = Buffer.from(arr);\n\n// Shares memory with `arr`.\nconst buf2 = Buffer.from(arr.buffer);\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 a0 0f>\n\narr[1] = 6000;\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 70 17>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Copies the contents of `arr`.\nconst buf1 = Buffer.from(arr);\n\n// Shares memory with `arr`.\nconst buf2 = Buffer.from(arr.buffer);\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 a0 0f>\n\narr[1] = 6000;\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 70 17>\n```\n\nWhen creating a `Buffer` using a {TypedArray}'s `.buffer`, it is\npossible to use only a portion of the underlying {ArrayBuffer} by passing in\n`byteOffset` and `length` parameters.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(20);\nconst buf = Buffer.from(arr.buffer, 0, 16);\n\nconsole.log(buf.length);\n// Prints: 16\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(20);\nconst buf = Buffer.from(arr.buffer, 0, 16);\n\nconsole.log(buf.length);\n// Prints: 16\n```\n\nThe `Buffer.from()` and [`TypedArray.from()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from) have different signatures and\nimplementations. Specifically, the {TypedArray} variants accept a second\nargument that is a mapping function that is invoked on every element of the\ntyped array:\n\n* [`TypedArray.from(source[, mapFn[, thisArg]])`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)\n\nThe `Buffer.from()` method, however, does not support the use of a mapping\nfunction:\n\n* [`Buffer.from(array)`](#static-method-bufferfromarray)\n* [`Buffer.from(buffer)`](#static-method-bufferfrombuffer)\n* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`](#static-method-bufferfromarraybuffer-byteoffset-length)\n* [`Buffer.from(string[, encoding])`](#static-method-bufferfromstring-encoding)","summary":"`Buffer` instances are also JavaScript {Uint8Array} and {TypedArray} instances. All {TypedArray} methods and properties are available on `Buffer`s. There are, however, subtle incompatibilities between the `Buffer` API and the {TypedArray} API.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\nconst uint32array = new Uint32Array(buf);\n\nconsole.log(uint32array);\n\n// Prints: Uint32Array(4) [ 1, 2, 3, 4 ]"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\nconst uint32array = new Uint32Array(buf);\n\nconsole.log(uint32array);\n\n// Prints: Uint32Array(4) [ 1, 2, 3, 4 ]"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('hello', 'utf16le');\nconst uint16array = new Uint16Array(\n  buf.buffer,\n  buf.byteOffset,\n  buf.length / Uint16Array.BYTES_PER_ELEMENT);\n\nconsole.log(uint16array);\n\n// Prints: Uint16Array(5) [ 104, 101, 108, 108, 111 ]"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('hello', 'utf16le');\nconst uint16array = new Uint16Array(\n  buf.buffer,\n  buf.byteOffset,\n  buf.length / Uint16Array.BYTES_PER_ELEMENT);\n\nconsole.log(uint16array);\n\n// Prints: Uint16Array(5) [ 104, 101, 108, 108, 111 ]"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Copies the contents of `arr`.\nconst buf1 = Buffer.from(arr);\n\n// Shares memory with `arr`.\nconst buf2 = Buffer.from(arr.buffer);\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 a0 0f>\n\narr[1] = 6000;\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 70 17>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Copies the contents of `arr`.\nconst buf1 = Buffer.from(arr);\n\n// Shares memory with `arr`.\nconst buf2 = Buffer.from(arr.buffer);\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 a0 0f>\n\narr[1] = 6000;\n\nconsole.log(buf1);\n// Prints: <Buffer 88 a0>\nconsole.log(buf2);\n// Prints: <Buffer 88 13 70 17>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(20);\nconst buf = Buffer.from(arr.buffer, 0, 16);\n\nconsole.log(buf.length);\n// Prints: 16"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(20);\nconst buf = Buffer.from(arr.buffer, 0, 16);\n\nconsole.log(buf.length);\n// Prints: 16"}],"children":[{"kind":"section","id":"buffer-methods-are-callable-with-uint8array-instances","name":"Buffer methods are callable with Uint8Array instances","title":"Buffer methods are callable with `Uint8Array` instances","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"All methods on the Buffer prototype are callable with a `Uint8Array` instance.\n\n```js\nconst { toString, write } = Buffer.prototype;\n\nconst uint8array = new Uint8Array(5);\n\nwrite.call(uint8array, 'hello', 0, 5, 'utf8'); // 5\n// <Uint8Array 68 65 6c 6c 6f>\n\ntoString.call(uint8array, 'utf8'); // 'hello'\n```","summary":"All methods on the Buffer prototype are callable with a `Uint8Array` instance.","examples":[{"language":"js","displayName":null,"code":"const { toString, write } = Buffer.prototype;\n\nconst uint8array = new Uint8Array(5);\n\nwrite.call(uint8array, 'hello', 0, 5, 'utf8'); // 5\n// <Uint8Array 68 65 6c 6c 6f>\n\ntoString.call(uint8array, 'utf8'); // 'hello'"}],"children":[]}]},{"kind":"section","id":"buffers-and-iteration","name":"Buffers and iteration","title":"Buffers and iteration","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`Buffer` instances can be iterated over using `for..of` syntax:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3]);\n\nfor (const b of buf) {\n  console.log(b);\n}\n// Prints:\n//   1\n//   2\n//   3\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3]);\n\nfor (const b of buf) {\n  console.log(b);\n}\n// Prints:\n//   1\n//   2\n//   3\n```\n\nAdditionally, the [`buf.values()`](#bufvalues), [`buf.keys()`](#bufkeys), and\n[`buf.entries()`](#bufentries) methods can be used to create iterators.","summary":"`Buffer` instances can be iterated over using `for..of` syntax:","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3]);\n\nfor (const b of buf) {\n  console.log(b);\n}\n// Prints:\n//   1\n//   2\n//   3"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3]);\n\nfor (const b of buf) {\n  console.log(b);\n}\n// Prints:\n//   1\n//   2\n//   3"}],"children":[]},{"kind":"class","id":"class-blob","name":"Blob","title":"Class: `Blob`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v18.0.0","v16.17.0"],"prUrl":"https://github.com/nodejs/node/pull/41270","commit":null,"description":"No longer experimental."}],"extends":null,"description":"A {Blob} encapsulates immutable, raw data that can be safely shared across\nmultiple worker threads.","summary":"A {Blob} encapsulates immutable, raw data that can be safely shared across multiple worker threads.","examples":[],"children":[{"kind":"constructor","id":"new-bufferblobsources-options","name":"Blob","title":"`new buffer.Blob([sources[, options]])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v16.7.0"],"prUrl":"https://github.com/nodejs/node/pull/39708","commit":null,"description":"Added the standard `endings` option to replace line-endings, and removed the non-standard `encoding` option."}],"signature":{"parameters":[{"name":"sources","type":{"text":"string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":11,"end":22},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":27,"end":37},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":42,"end":50},{"name":"Blob","href":"buffer.html#class-blob","start":55,"end":59}]},"description":"An\narray of string, {ArrayBuffer}, {TypedArray}, {DataView}, or {Blob} objects,\nor any mix of such objects, that will be stored within the `Blob`.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"endings","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"One of either `'transparent'` or `'native'`. When set\nto `'native'`, line endings in string source parts will be converted to\nthe platform native line-ending as specified by `require('node:os').EOL`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The Blob content-type. The intent is for `type` to convey\nthe MIME media type of the data, however no validation of the type format\nis performed.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":null},"description":"Creates a new `Blob` object containing a concatenation of the given sources.\n\n{ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into\nthe 'Blob' and can therefore be safely modified after the 'Blob' is created.\n\nString sources are encoded as UTF-8 byte sequences and copied into the Blob.\nUnmatched surrogate pairs within each string part will be replaced by Unicode\nU+FFFD replacement characters.","summary":"Creates a new `Blob` object containing a concatenation of the given sources.","examples":[],"children":[]},{"kind":"method","id":"blobarraybuffer","name":"arrayBuffer","title":"`blob.arrayBuffer()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Returns a promise that fulfills with an {ArrayBuffer} containing a copy of\nthe `Blob` data.","summary":"Returns a promise that fulfills with an {ArrayBuffer} containing a copy of the `Blob` data.","examples":[],"children":[]},{"kind":"method","id":"blobbytes","name":"bytes","title":"`blob.bytes()`","scope":"module","overloadOf":null,"stability":null,"added":["v22.3.0","v20.16.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.\n\n```js\nconst blob = new Blob(['hello']);\nblob.bytes().then((bytes) => {\n  console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]\n});\n```","summary":"The `blob.bytes()` method returns the byte of the `Blob` object as a `Promise<Uint8Array>`.","examples":[{"language":"js","displayName":null,"code":"const blob = new Blob(['hello']);\nblob.bytes().then((bytes) => {\n  console.log(bytes); // Outputs: Uint8Array(5) [ 104, 101, 108, 108, 111 ]\n});"}],"children":[]},{"kind":"property","id":"blobsize","name":"size","title":"`blob.size`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"The total size of the `Blob` in bytes.","summary":"The total size of the `Blob` in bytes.","examples":[],"children":[]},{"kind":"method","id":"blobslicestart-end-type","name":"slice","title":"`blob.slice([start[, end[, type]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"start","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The starting index.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The ending index.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The content-type for the new `Blob`","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Blob","links":[{"name":"Blob","href":"buffer.html#class-blob","start":0,"end":4}]},"description":""}},"description":"Creates and returns a new `Blob` containing a subset of this `Blob` objects\ndata. The original `Blob` is not altered.","summary":"Creates and returns a new `Blob` containing a subset of this `Blob` objects data. The original `Blob` is not altered.","examples":[],"children":[]},{"kind":"method","id":"blobstream","name":"stream","title":"`blob.stream()`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":""}},"description":"Returns a new `ReadableStream` that allows the content of the `Blob` to be read.","summary":"Returns a new `ReadableStream` that allows the content of the `Blob` to be read.","examples":[],"children":[]},{"kind":"method","id":"blobtext","name":"text","title":"`blob.text()`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":""}},"description":"Returns a promise that fulfills with the contents of the `Blob` decoded as a\nUTF-8 string.","summary":"Returns a promise that fulfills with the contents of the `Blob` decoded as a UTF-8 string.","examples":[],"children":[]},{"kind":"method","id":"blobtextstream","name":"textStream","title":"`blob.textStream()`","scope":"module","overloadOf":null,"stability":null,"added":["v26.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"ReadableStream","links":[{"name":"ReadableStream","href":"webstreams.html#class-readablestream","start":0,"end":14}]},"description":""}},"description":"Returns a new `ReadableStream` that allows the content of the `Blob` to be read\nas a stream of UTF-8 decoded strings. It is equivalent to piping\n[`blob.stream()`](#blobstream) through a [`TextDecoderStream`](webstreams.html#class-textdecoderstream) set up with UTF-8.","summary":"Returns a new `ReadableStream` that allows the content of the `Blob` to be read as a stream of UTF-8 decoded strings. It is equivalent to piping `blob.stream()` through a `TextDecoderStream` set up with UTF-8.","examples":[],"children":[]},{"kind":"property","id":"blobtype","name":"type","title":"`blob.type`","scope":"module","overloadOf":null,"stability":null,"added":["v15.7.0","v14.18.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The content-type of the `Blob`.","summary":"The content-type of the `Blob`.","examples":[],"children":[]},{"kind":"section","id":"blob-objects-and-messagechannel","name":"Blob objects and MessageChannel","title":"`Blob` objects and `MessageChannel`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Once a {Blob} object is created, it can be sent via `MessagePort` to multiple\ndestinations without transferring or immediately copying the data. The data\ncontained by the `Blob` is copied only when the `arrayBuffer()` or `text()`\nmethods are called.\n\n```mjs\nimport { Blob } from 'node:buffer';\nimport { setTimeout as delay } from 'node:timers/promises';\n\nconst blob = new Blob(['hello there']);\n\nconst mc1 = new MessageChannel();\nconst mc2 = new MessageChannel();\n\nmc1.port1.onmessage = async ({ data }) => {\n  console.log(await data.arrayBuffer());\n  mc1.port1.close();\n};\n\nmc2.port1.onmessage = async ({ data }) => {\n  await delay(1000);\n  console.log(await data.arrayBuffer());\n  mc2.port1.close();\n};\n\nmc1.port2.postMessage(blob);\nmc2.port2.postMessage(blob);\n\n// The Blob is still usable after posting.\nblob.text().then(console.log);\n```\n\n```cjs\nconst { Blob } = require('node:buffer');\nconst { setTimeout: delay } = require('node:timers/promises');\n\nconst blob = new Blob(['hello there']);\n\nconst mc1 = new MessageChannel();\nconst mc2 = new MessageChannel();\n\nmc1.port1.onmessage = async ({ data }) => {\n  console.log(await data.arrayBuffer());\n  mc1.port1.close();\n};\n\nmc2.port1.onmessage = async ({ data }) => {\n  await delay(1000);\n  console.log(await data.arrayBuffer());\n  mc2.port1.close();\n};\n\nmc1.port2.postMessage(blob);\nmc2.port2.postMessage(blob);\n\n// The Blob is still usable after posting.\nblob.text().then(console.log);\n```","summary":"Once a {Blob} object is created, it can be sent via `MessagePort` to multiple destinations without transferring or immediately copying the data. The data contained by the `Blob` is copied only when the `arrayBuffer()` or `text()` methods are called.","examples":[{"language":"mjs","displayName":null,"code":"import { Blob } from 'node:buffer';\nimport { setTimeout as delay } from 'node:timers/promises';\n\nconst blob = new Blob(['hello there']);\n\nconst mc1 = new MessageChannel();\nconst mc2 = new MessageChannel();\n\nmc1.port1.onmessage = async ({ data }) => {\n  console.log(await data.arrayBuffer());\n  mc1.port1.close();\n};\n\nmc2.port1.onmessage = async ({ data }) => {\n  await delay(1000);\n  console.log(await data.arrayBuffer());\n  mc2.port1.close();\n};\n\nmc1.port2.postMessage(blob);\nmc2.port2.postMessage(blob);\n\n// The Blob is still usable after posting.\nblob.text().then(console.log);"},{"language":"cjs","displayName":null,"code":"const { Blob } = require('node:buffer');\nconst { setTimeout: delay } = require('node:timers/promises');\n\nconst blob = new Blob(['hello there']);\n\nconst mc1 = new MessageChannel();\nconst mc2 = new MessageChannel();\n\nmc1.port1.onmessage = async ({ data }) => {\n  console.log(await data.arrayBuffer());\n  mc1.port1.close();\n};\n\nmc2.port1.onmessage = async ({ data }) => {\n  await delay(1000);\n  console.log(await data.arrayBuffer());\n  mc2.port1.close();\n};\n\nmc1.port2.postMessage(blob);\nmc2.port2.postMessage(blob);\n\n// The Blob is still usable after posting.\nblob.text().then(console.log);"}],"children":[]}]},{"kind":"class","id":"class-buffer","name":"Buffer","title":"Class: `Buffer`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"The `Buffer` class is a global type for dealing with binary data directly.\nIt can be constructed in a variety of ways.","summary":"The `Buffer` class is a global type for dealing with binary data directly. It can be constructed in a variety of ways.","examples":[],"children":[{"kind":"staticMethod","id":"static-method-bufferallocsize-fill-encoding","name":"alloc","title":"Static method: `Buffer.alloc(size[, fill[, encoding]])`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v20.0.0"],"prUrl":"https://github.com/nodejs/node/pull/45796","commit":null,"description":"Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of ERR_INVALID_ARG_VALUE for invalid input arguments."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/34682","commit":null,"description":"Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE for invalid input arguments."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18129","commit":null,"description":"Attempting to fill a non-zero length buffer with a zero length buffer triggers a thrown exception."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/17427","commit":null,"description":"Specifying an invalid string for `fill` triggers a thrown exception."},{"versions":["v8.9.3"],"prUrl":"https://github.com/nodejs/node/pull/17428","commit":null,"description":"Specifying an invalid string for `fill` now results in a zero-filled buffer."}],"signature":{"parameters":[{"name":"size","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The desired length of the new `Buffer`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fill","type":{"text":"string | Buffer | Uint8Array | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":18,"end":28},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":31,"end":38}]},"description":"A value to pre-fill the new `Buffer`\nwith.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"If `fill` is a string, this is its encoding.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the\n`Buffer` will be zero-filled.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(5);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(5);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00>\n```\n\nIf `size` is larger than\n[`buffer.constants.MAX_LENGTH`](#bufferconstantsmax_length) or smaller than 0, [`ERR_OUT_OF_RANGE`](errors.html#err_out_of_range)\nis thrown.\n\nIf `fill` is specified, the allocated `Buffer` will be initialized by calling\n[`buf.fill(fill)`](#buffillvalue-offset-end-encoding).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(5, 'a');\n\nconsole.log(buf);\n// Prints: <Buffer 61 61 61 61 61>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(5, 'a');\n\nconsole.log(buf);\n// Prints: <Buffer 61 61 61 61 61>\n```\n\nIf both `fill` and `encoding` are specified, the allocated `Buffer` will be\ninitialized by calling [`buf.fill(fill, encoding)`](#buffillvalue-offset-end-encoding).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');\n\nconsole.log(buf);\n// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');\n\nconsole.log(buf);\n// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>\n```\n\nCalling [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding) can be measurably slower than the alternative\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) but ensures that the newly created `Buffer` instance\ncontents will never contain sensitive data from previous allocations, including\ndata that might not have been allocated for `Buffer`s.\n\nA `TypeError` will be thrown if `size` is not a number.","summary":"Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be zero-filled.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(5);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(5);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(5, 'a');\n\nconsole.log(buf);\n// Prints: <Buffer 61 61 61 61 61>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(5, 'a');\n\nconsole.log(buf);\n// Prints: <Buffer 61 61 61 61 61>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');\n\nconsole.log(buf);\n// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');\n\nconsole.log(buf);\n// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferallocunsafesize-alignment","name":"allocUnsafe","title":"Static method: `Buffer.allocUnsafe(size[, alignment])`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/65003","commit":null,"description":"Added the `alignment` argument."},{"versions":["v20.0.0"],"prUrl":"https://github.com/nodejs/node/pull/45796","commit":null,"description":"Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of ERR_INVALID_ARG_VALUE for invalid input arguments."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/34682","commit":null,"description":"Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE for invalid input arguments."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/7079","commit":null,"description":"Passing a negative `size` will now throw an error."}],"signature":{"parameters":[{"name":"size","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The desired length of the new `Buffer`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"alignment","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"If given, the memory backing the new `Buffer` will start\nat an address that is a multiple of `alignment`. Must be a power of two no\nlarger than `2 ** 30`. See [Aligned allocations](#aligned-allocations).","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Allocates a new `Buffer` of `size` bytes. If `size` is larger than\n[`buffer.constants.MAX_LENGTH`](#bufferconstantsmax_length) or smaller than 0, [`ERR_OUT_OF_RANGE`](errors.html#err_out_of_range)\nis thrown.\n\nThe underlying memory for `Buffer` instances created in this way is *not\ninitialized*. The contents of the newly created `Buffer` are unknown and\n*may contain sensitive data*. Use [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding) instead to initialize\n`Buffer` instances with zeroes.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(10);\n\nconsole.log(buf);\n// Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>\n\nbuf.fill(0);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(10);\n\nconsole.log(buf);\n// Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>\n\nbuf.fill(0);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>\n```\n\nA `TypeError` will be thrown if `size` is not a number.\n\nThe `Buffer` module pre-allocates an internal `Buffer` instance of\nsize [`Buffer.poolSize`](#bufferpoolsize) that is used as a pool for the fast allocation of new\n`Buffer` instances created using [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment), [`Buffer.from(array)`](#static-method-bufferfromarray),\n[`Buffer.from(string)`](#static-method-bufferfromstring-encoding), and [`Buffer.concat()`](#static-method-bufferconcatlist-totallength) only when `size` is less than\n`Buffer.poolSize >>> 1` (floor of [`Buffer.poolSize`](#bufferpoolsize) divided by two).\n\nUse of this pre-allocated internal memory pool is a key difference between\ncalling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.\nSpecifically, `Buffer.alloc(size, fill)` will *never* use the internal `Buffer`\npool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal\n`Buffer` pool if `size` is less than or equal to half [`Buffer.poolSize`](#bufferpoolsize). The\ndifference is subtle but can be important when an application requires the\nadditional performance that [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) provides.","summary":"Allocates a new `Buffer` of `size` bytes. If `size` is larger than `buffer.constants.MAX_LENGTH` or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(10);\n\nconsole.log(buf);\n// Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>\n\nbuf.fill(0);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(10);\n\nconsole.log(buf);\n// Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>\n\nbuf.fill(0);\n\nconsole.log(buf);\n// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferallocunsafeslowsize-alignment","name":"allocUnsafeSlow","title":"Static method: `Buffer.allocUnsafeSlow(size[, alignment])`","scope":"module","overloadOf":null,"stability":null,"added":["v5.12.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/65003","commit":null,"description":"Added the `alignment` argument."},{"versions":["v20.0.0"],"prUrl":"https://github.com/nodejs/node/pull/45796","commit":null,"description":"Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of ERR_INVALID_ARG_VALUE for invalid input arguments."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/34682","commit":null,"description":"Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE for invalid input arguments."}],"signature":{"parameters":[{"name":"size","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The desired length of the new `Buffer`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"alignment","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"If given, the memory backing the new `Buffer` will start\nat an address that is a multiple of `alignment`. Must be a power of two no\nlarger than `2 ** 30`. See [Aligned allocations](#aligned-allocations).","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Allocates a new `Buffer` of `size` bytes. If `size` is larger than\n[`buffer.constants.MAX_LENGTH`](#bufferconstantsmax_length) or smaller than 0, [`ERR_OUT_OF_RANGE`](errors.html#err_out_of_range)\nis thrown. A zero-length `Buffer` is created if `size` is 0.\n\nThe underlying memory for `Buffer` instances created in this way is *not\ninitialized*. The contents of the newly created `Buffer` are unknown and\n*may contain sensitive data*. Use [`buf.fill(0)`](#buffillvalue-offset-end-encoding) to initialize\nsuch `Buffer` instances with zeroes.\n\nWhen using [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) to allocate new `Buffer` instances,\nallocations less than `Buffer.poolSize >>> 1` (32KiB when default poolSize is used) are sliced\nfrom a single pre-allocated `Buffer`. This allows applications to avoid the\ngarbage collection overhead of creating many individually allocated `Buffer`\ninstances. This approach improves both performance and memory usage by\neliminating the need to track and clean up as many individual `ArrayBuffer` objects.\n\nHowever, in the case where a developer may need to retain a small chunk of\nmemory from a pool for an indeterminate amount of time, it may be appropriate\nto create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and\nthen copying out the relevant bits.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Need to keep around a few small chunks of memory.\nconst store = [];\n\nsocket.on('readable', () => {\n  let data;\n  while (null !== (data = readable.read())) {\n    // Allocate for retained data.\n    const sb = Buffer.allocUnsafeSlow(10);\n\n    // Copy the data into the new allocation.\n    data.copy(sb, 0, 0, 10);\n\n    store.push(sb);\n  }\n});\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Need to keep around a few small chunks of memory.\nconst store = [];\n\nsocket.on('readable', () => {\n  let data;\n  while (null !== (data = readable.read())) {\n    // Allocate for retained data.\n    const sb = Buffer.allocUnsafeSlow(10);\n\n    // Copy the data into the new allocation.\n    data.copy(sb, 0, 0, 10);\n\n    store.push(sb);\n  }\n});\n```\n\nA `TypeError` will be thrown if `size` is not a number.","summary":"Allocates a new `Buffer` of `size` bytes. If `size` is larger than `buffer.constants.MAX_LENGTH` or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if `size` is 0.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Need to keep around a few small chunks of memory.\nconst store = [];\n\nsocket.on('readable', () => {\n  let data;\n  while (null !== (data = readable.read())) {\n    // Allocate for retained data.\n    const sb = Buffer.allocUnsafeSlow(10);\n\n    // Copy the data into the new allocation.\n    data.copy(sb, 0, 0, 10);\n\n    store.push(sb);\n  }\n});"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Need to keep around a few small chunks of memory.\nconst store = [];\n\nsocket.on('readable', () => {\n  let data;\n  while (null !== (data = readable.read())) {\n    // Allocate for retained data.\n    const sb = Buffer.allocUnsafeSlow(10);\n\n    // Copy the data into the new allocation.\n    data.copy(sb, 0, 0, 10);\n\n    store.push(sb);\n  }\n});"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferbytelengthstring-encoding","name":"byteLength","title":"Static method: `Buffer.byteLength(string[, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.90"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8946","commit":null,"description":"Passing invalid input will now throw an error."},{"versions":["v5.10.0"],"prUrl":"https://github.com/nodejs/node/pull/5255","commit":null,"description":"The `string` parameter can now be any `TypedArray`, `DataView` or `ArrayBuffer`."}],"signature":{"parameters":[{"name":"string","type":{"text":"string | Buffer | TypedArray | DataView | ArrayBuffer | SharedArrayBuffer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":18,"end":28},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":31,"end":39},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":42,"end":53},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":56,"end":73}]},"description":"A\nvalue to calculate the length of.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"If `string` is a string, this is its encoding.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes contained within `string`."}},"description":"Returns the byte length of a string when encoded using `encoding`.\nThis 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\nfor the encoding that is used to convert the string into bytes.\n\nFor `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.\nFor strings that contain non-base64/hex-encoded data (e.g. whitespace), the\nreturn value might be greater than the length of a `Buffer` created from the\nstring.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst str = '\\u00bd + \\u00bc = \\u00be';\n\nconsole.log(`${str}: ${str.length} characters, ` +\n            `${Buffer.byteLength(str, 'utf8')} bytes`);\n// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst str = '\\u00bd + \\u00bc = \\u00be';\n\nconsole.log(`${str}: ${str.length} characters, ` +\n            `${Buffer.byteLength(str, 'utf8')} bytes`);\n// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes\n```\n\nWhen `string` is a {Buffer | DataView | TypedArray | ArrayBuffer | SharedArrayBuffer},\nthe byte length as reported by `.byteLength` is returned.","summary":"Returns the byte length of a string when encoded using `encoding`. This is not the same as `String.prototype.length`, which does not account for the encoding that is used to convert the string into bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst str = '\\u00bd + \\u00bc = \\u00be';\n\nconsole.log(`${str}: ${str.length} characters, ` +\n            `${Buffer.byteLength(str, 'utf8')} bytes`);\n// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst str = '\\u00bd + \\u00bc = \\u00be';\n\nconsole.log(`${str}: ${str.length} characters, ` +\n            `${Buffer.byteLength(str, 'utf8')} bytes`);\n// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes"}],"children":[]},{"kind":"staticMethod","id":"static-method-buffercomparebuf1-buf2","name":"compare","title":"Static method: `Buffer.compare(buf1, buf2)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The arguments can now be `Uint8Array`s."}],"signature":{"parameters":[{"name":"buf1","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"buf2","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Either `-1`, `0`, or `1`, depending on the result of the\ncomparison. See [`buf.compare()`](#bufcomparetarget-targetstart-targetend-sourcestart-sourceend) for details."}},"description":"Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of\n`Buffer` instances. This is equivalent to calling\n[`buf1.compare(buf2)`](#bufcomparetarget-targetstart-targetend-sourcestart-sourceend).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('1234');\nconst buf2 = Buffer.from('0123');\nconst arr = [buf1, buf2];\n\nconsole.log(arr.sort(Buffer.compare));\n// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]\n// (This result is equal to: [buf2, buf1].)\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('1234');\nconst buf2 = Buffer.from('0123');\nconst arr = [buf1, buf2];\n\nconsole.log(arr.sort(Buffer.compare));\n// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]\n// (This result is equal to: [buf2, buf1].)\n```","summary":"Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('1234');\nconst buf2 = Buffer.from('0123');\nconst arr = [buf1, buf2];\n\nconsole.log(arr.sort(Buffer.compare));\n// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]\n// (This result is equal to: [buf2, buf1].)"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('1234');\nconst buf2 = Buffer.from('0123');\nconst arr = [buf1, buf2];\n\nconsole.log(arr.sort(Buffer.compare));\n// Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]\n// (This result is equal to: [buf2, buf1].)"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferconcatlist-totallength","name":"concat","title":"Static method: `Buffer.concat(list[, totalLength])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.11"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The elements of `list` can now be `Uint8Array`s."}],"signature":{"parameters":[{"name":"list","type":{"text":"Buffer[] | Uint8Array[]","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":11,"end":21}]},"description":"List of `Buffer` or {Uint8Array}\ninstances to concatenate.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"totalLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Total length of the `Buffer` instances in `list`\nwhen concatenated.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Returns a new `Buffer` which is the result of concatenating all the `Buffer`\ninstances in the `list` together.\n\nIf the list has no items, or if the `totalLength` is 0, then a new zero-length\n`Buffer` is returned.\n\nIf `totalLength` is not provided, it is calculated from the `Buffer` instances\nin `list` by adding their lengths.\n\nIf `totalLength` is provided, it must be an unsigned integer. If the\ncombined length of the `Buffer`s in `list` exceeds `totalLength`, the result is\ntruncated to `totalLength`. If the combined length of the `Buffer`s in `list` is\nless than `totalLength`, the remaining space is filled with zeros.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create a single `Buffer` from a list of three `Buffer` instances.\n\nconst buf1 = Buffer.alloc(10);\nconst buf2 = Buffer.alloc(14);\nconst buf3 = Buffer.alloc(18);\nconst totalLength = buf1.length + buf2.length + buf3.length;\n\nconsole.log(totalLength);\n// Prints: 42\n\nconst bufA = Buffer.concat([buf1, buf2, buf3], totalLength);\n\nconsole.log(bufA);\n// Prints: <Buffer 00 00 00 00 ...>\nconsole.log(bufA.length);\n// Prints: 42\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create a single `Buffer` from a list of three `Buffer` instances.\n\nconst buf1 = Buffer.alloc(10);\nconst buf2 = Buffer.alloc(14);\nconst buf3 = Buffer.alloc(18);\nconst totalLength = buf1.length + buf2.length + buf3.length;\n\nconsole.log(totalLength);\n// Prints: 42\n\nconst bufA = Buffer.concat([buf1, buf2, buf3], totalLength);\n\nconsole.log(bufA);\n// Prints: <Buffer 00 00 00 00 ...>\nconsole.log(bufA.length);\n// Prints: 42\n```\n\n`Buffer.concat()` may also use the internal `Buffer` pool like\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) does.","summary":"Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create a single `Buffer` from a list of three `Buffer` instances.\n\nconst buf1 = Buffer.alloc(10);\nconst buf2 = Buffer.alloc(14);\nconst buf3 = Buffer.alloc(18);\nconst totalLength = buf1.length + buf2.length + buf3.length;\n\nconsole.log(totalLength);\n// Prints: 42\n\nconst bufA = Buffer.concat([buf1, buf2, buf3], totalLength);\n\nconsole.log(bufA);\n// Prints: <Buffer 00 00 00 00 ...>\nconsole.log(bufA.length);\n// Prints: 42"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create a single `Buffer` from a list of three `Buffer` instances.\n\nconst buf1 = Buffer.alloc(10);\nconst buf2 = Buffer.alloc(14);\nconst buf3 = Buffer.alloc(18);\nconst totalLength = buf1.length + buf2.length + buf3.length;\n\nconsole.log(totalLength);\n// Prints: 42\n\nconst bufA = Buffer.concat([buf1, buf2, buf3], totalLength);\n\nconsole.log(bufA);\n// Prints: <Buffer 00 00 00 00 ...>\nconsole.log(bufA.length);\n// Prints: 42"}],"children":[]},{"kind":"staticMethod","id":"static-method-buffercopybytesfromview-offset-length","name":"copyBytesFrom","title":"Static method: `Buffer.copyBytesFrom(view[, offset[, length]])`","scope":"module","overloadOf":null,"stability":null,"added":["v19.8.0","v18.16.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"view","type":{"text":"TypedArray","links":[{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":0,"end":10}]},"description":"The {TypedArray} to copy.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The starting offset within `view`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of elements from `view` to copy.","default":"view.length - offset","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Copies the underlying memory of `view` into a new `Buffer`.\n\n```js\nconst u16 = new Uint16Array([0, 0xffff]);\nconst buf = Buffer.copyBytesFrom(u16, 1, 1);\nu16[1] = 0;\nconsole.log(buf.length); // 2\nconsole.log(buf[0]); // 255\nconsole.log(buf[1]); // 255\n```","summary":"Copies the underlying memory of `view` into a new `Buffer`.","examples":[{"language":"js","displayName":null,"code":"const u16 = new Uint16Array([0, 0xffff]);\nconst buf = Buffer.copyBytesFrom(u16, 1, 1);\nu16[1] = 0;\nconsole.log(buf.length); // 2\nconsole.log(buf[0]); // 255\nconsole.log(buf[1]); // 255"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferfromarray","name":"from","title":"Static method: `Buffer.from(array)`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"array","type":{"text":"integer[]","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.\nArray entries outside that range will be truncated to fit into it.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.\nconst buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.\nconst buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);\n```\n\nIf `array` is an `Array`-like object (that is, one with a `length` property of\ntype `number`), it is treated as if it is an array, unless it is a `Buffer` or\na `Uint8Array`. This means all other `TypedArray` variants get treated as an\n`Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use\n[`Buffer.copyBytesFrom()`](#static-method-buffercopybytesfromview-offset-length).\n\nA `TypeError` will be thrown if `array` is not an `Array` or another type\nappropriate for `Buffer.from()` variants.\n\n`Buffer.from(array)` and [`Buffer.from(string)`](#static-method-bufferfromstring-encoding) may also use the internal\n`Buffer` pool like [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) does.","summary":"Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`. Array entries outside that range will be truncated to fit into it.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.\nconst buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.\nconst buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferfromarraybuffer-byteoffset-length","name":"from","title":"Static method: `Buffer.from(arrayBuffer[, byteOffset[, length]])`","scope":"module","overloadOf":"static-method-bufferfromarray","stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"arrayBuffer","type":{"text":"ArrayBuffer | SharedArrayBuffer","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31}]},"description":"An {ArrayBuffer},\n{SharedArrayBuffer}, for example the `.buffer` property of a\n{TypedArray}.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteOffset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Index of first byte to expose.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to expose.","default":"arrayBuffer.byteLength - byteOffset","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"This creates a view of the {ArrayBuffer} without copying the underlying\nmemory. For example, when passed a reference to the `.buffer` property of a\n{TypedArray} instance, the newly created `Buffer` will share the same\nallocated memory as the {TypedArray}'s underlying `ArrayBuffer`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Shares memory with `arr`.\nconst buf = Buffer.from(arr.buffer);\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 a0 0f>\n\n// Changing the original Uint16Array changes the Buffer also.\narr[1] = 6000;\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 70 17>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Shares memory with `arr`.\nconst buf = Buffer.from(arr.buffer);\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 a0 0f>\n\n// Changing the original Uint16Array changes the Buffer also.\narr[1] = 6000;\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 70 17>\n```\n\nThe optional `byteOffset` and `length` arguments specify a memory range within\nthe `arrayBuffer` that will be shared by the `Buffer`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst ab = new ArrayBuffer(10);\nconst buf = Buffer.from(ab, 0, 2);\n\nconsole.log(buf.length);\n// Prints: 2\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst ab = new ArrayBuffer(10);\nconst buf = Buffer.from(ab, 0, 2);\n\nconsole.log(buf.length);\n// Prints: 2\n```\n\nA `TypeError` will be thrown if `arrayBuffer` is not an {ArrayBuffer} or a\n{SharedArrayBuffer} or another type appropriate for `Buffer.from()`\nvariants.\n\nIt is important to remember that a backing `ArrayBuffer` can cover a range\nof memory that extends beyond the bounds of a `TypedArray` view. A new\n`Buffer` created using the `buffer` property of a `TypedArray` may extend\nbeyond the range of the `TypedArray`:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements\nconst arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements\nconsole.log(arrA.buffer === arrB.buffer); // true\n\nconst buf = Buffer.from(arrB.buffer);\nconsole.log(buf);\n// Prints: <Buffer 63 64 65 66>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements\nconst arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements\nconsole.log(arrA.buffer === arrB.buffer); // true\n\nconst buf = Buffer.from(arrB.buffer);\nconsole.log(buf);\n// Prints: <Buffer 63 64 65 66>\n```","summary":"This creates a view of the {ArrayBuffer} without copying the underlying memory. For example, when passed a reference to the `.buffer` property of a {TypedArray} instance, the newly created `Buffer` will share the same allocated memory as the {TypedArray}'s underlying `ArrayBuffer`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Shares memory with `arr`.\nconst buf = Buffer.from(arr.buffer);\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 a0 0f>\n\n// Changing the original Uint16Array changes the Buffer also.\narr[1] = 6000;\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 70 17>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst arr = new Uint16Array(2);\n\narr[0] = 5000;\narr[1] = 4000;\n\n// Shares memory with `arr`.\nconst buf = Buffer.from(arr.buffer);\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 a0 0f>\n\n// Changing the original Uint16Array changes the Buffer also.\narr[1] = 6000;\n\nconsole.log(buf);\n// Prints: <Buffer 88 13 70 17>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst ab = new ArrayBuffer(10);\nconst buf = Buffer.from(ab, 0, 2);\n\nconsole.log(buf.length);\n// Prints: 2"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst ab = new ArrayBuffer(10);\nconst buf = Buffer.from(ab, 0, 2);\n\nconsole.log(buf.length);\n// Prints: 2"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements\nconst arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements\nconsole.log(arrA.buffer === arrB.buffer); // true\n\nconst buf = Buffer.from(arrB.buffer);\nconsole.log(buf);\n// Prints: <Buffer 63 64 65 66>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements\nconst arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements\nconsole.log(arrA.buffer === arrB.buffer); // true\n\nconst buf = Buffer.from(arrB.buffer);\nconsole.log(buf);\n// Prints: <Buffer 63 64 65 66>"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferfrombuffer","name":"from","title":"Static method: `Buffer.from(buffer)`","scope":"module","overloadOf":"static-method-bufferfromarray","stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"An existing `Buffer` or {Uint8Array} from\nwhich to copy data.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Copies the passed `buffer` data onto a new `Buffer` instance.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('buffer');\nconst buf2 = Buffer.from(buf1);\n\nbuf1[0] = 0x61;\n\nconsole.log(buf1.toString());\n// Prints: auffer\nconsole.log(buf2.toString());\n// Prints: buffer\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('buffer');\nconst buf2 = Buffer.from(buf1);\n\nbuf1[0] = 0x61;\n\nconsole.log(buf1.toString());\n// Prints: auffer\nconsole.log(buf2.toString());\n// Prints: buffer\n```\n\nA `TypeError` will be thrown if `buffer` is not a `Buffer` or another type\nappropriate for `Buffer.from()` variants.","summary":"Copies the passed `buffer` data onto a new `Buffer` instance.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('buffer');\nconst buf2 = Buffer.from(buf1);\n\nbuf1[0] = 0x61;\n\nconsole.log(buf1.toString());\n// Prints: auffer\nconsole.log(buf2.toString());\n// Prints: buffer"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('buffer');\nconst buf2 = Buffer.from(buf1);\n\nbuf1[0] = 0x61;\n\nconsole.log(buf1.toString());\n// Prints: auffer\nconsole.log(buf2.toString());\n// Prints: buffer"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferfromobject-offsetorencoding-length","name":"from","title":"Static method: `Buffer.from(object[, offsetOrEncoding[, length]])`","scope":"module","overloadOf":"static-method-bufferfromarray","stability":null,"added":["v8.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"object","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"An object supporting `Symbol.toPrimitive` or `valueOf()`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offsetOrEncoding","type":{"text":"integer | string","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":10,"end":16}]},"description":"A byte-offset or encoding.","default":null,"optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"A length.","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"For objects whose `valueOf()` function returns a value not strictly equal to\n`object`, returns `Buffer.from(object.valueOf(), offsetOrEncoding, length)`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from(new String('this is a test'));\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from(new String('this is a test'));\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>\n```\n\nFor objects that support `Symbol.toPrimitive`, returns\n`Buffer.from(object[Symbol.toPrimitive]('string'), offsetOrEncoding)`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nclass Foo {\n  [Symbol.toPrimitive]() {\n    return 'this is a test';\n  }\n}\n\nconst buf = Buffer.from(new Foo(), 'utf8');\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nclass Foo {\n  [Symbol.toPrimitive]() {\n    return 'this is a test';\n  }\n}\n\nconst buf = Buffer.from(new Foo(), 'utf8');\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>\n```\n\nA `TypeError` will be thrown if `object` does not have the mentioned methods or\nis not of another type appropriate for `Buffer.from()` variants.","summary":"For objects whose `valueOf()` function returns a value not strictly equal to `object`, returns `Buffer.from(object.valueOf(), offsetOrEncoding, length)`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from(new String('this is a test'));\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from(new String('this is a test'));\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nclass Foo {\n  [Symbol.toPrimitive]() {\n    return 'this is a test';\n  }\n}\n\nconst buf = Buffer.from(new Foo(), 'utf8');\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nclass Foo {\n  [Symbol.toPrimitive]() {\n    return 'this is a test';\n  }\n}\n\nconst buf = Buffer.from(new Foo(), 'utf8');\n// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferfromstring-encoding","name":"from","title":"Static method: `Buffer.from(string[, encoding])`","scope":"module","overloadOf":"static-method-bufferfromarray","stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"A string to encode.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The encoding of `string`.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Creates a new `Buffer` containing `string`. The `encoding` parameter identifies\nthe character encoding to be used when converting `string` into bytes.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('this is a tést');\nconst buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');\n\nconsole.log(buf1.toString());\n// Prints: this is a tést\nconsole.log(buf2.toString());\n// Prints: this is a tést\nconsole.log(buf1.toString('latin1'));\n// Prints: this is a tÃ©st\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('this is a tést');\nconst buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');\n\nconsole.log(buf1.toString());\n// Prints: this is a tést\nconsole.log(buf2.toString());\n// Prints: this is a tést\nconsole.log(buf1.toString('latin1'));\n// Prints: this is a tÃ©st\n```\n\nA `TypeError` will be thrown if `string` is not a string or another type\nappropriate for `Buffer.from()` variants.\n\n[`Buffer.from(string)`](#static-method-bufferfromstring-encoding) may also use the internal `Buffer` pool like\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) does.","summary":"Creates a new `Buffer` containing `string`. The `encoding` parameter identifies the character encoding to be used when converting `string` into bytes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('this is a tést');\nconst buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');\n\nconsole.log(buf1.toString());\n// Prints: this is a tést\nconsole.log(buf2.toString());\n// Prints: this is a tést\nconsole.log(buf1.toString('latin1'));\n// Prints: this is a tÃ©st"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('this is a tést');\nconst buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');\n\nconsole.log(buf1.toString());\n// Prints: this is a tést\nconsole.log(buf2.toString());\n// Prints: this is a tést\nconsole.log(buf1.toString('latin1'));\n// Prints: this is a tÃ©st"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferisbufferobj","name":"isBuffer","title":"Static method: `Buffer.isBuffer(obj)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.101"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"obj","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if `obj` is a `Buffer`, `false` otherwise.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nBuffer.isBuffer(Buffer.alloc(10)); // true\nBuffer.isBuffer(Buffer.from('foo')); // true\nBuffer.isBuffer('a string'); // false\nBuffer.isBuffer([]); // false\nBuffer.isBuffer(new Uint8Array(1024)); // false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nBuffer.isBuffer(Buffer.alloc(10)); // true\nBuffer.isBuffer(Buffer.from('foo')); // true\nBuffer.isBuffer('a string'); // false\nBuffer.isBuffer([]); // false\nBuffer.isBuffer(new Uint8Array(1024)); // false\n```","summary":"Returns `true` if `obj` is a `Buffer`, `false` otherwise.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nBuffer.isBuffer(Buffer.alloc(10)); // true\nBuffer.isBuffer(Buffer.from('foo')); // true\nBuffer.isBuffer('a string'); // false\nBuffer.isBuffer([]); // false\nBuffer.isBuffer(new Uint8Array(1024)); // false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nBuffer.isBuffer(Buffer.alloc(10)); // true\nBuffer.isBuffer(Buffer.from('foo')); // true\nBuffer.isBuffer('a string'); // false\nBuffer.isBuffer([]); // false\nBuffer.isBuffer(new Uint8Array(1024)); // false"}],"children":[]},{"kind":"staticMethod","id":"static-method-bufferisencodingencoding","name":"isEncoding","title":"Static method: `Buffer.isEncoding(encoding)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.1"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"A character encoding name to check.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if `encoding` is the name of a supported character encoding,\nor `false` otherwise.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconsole.log(Buffer.isEncoding('utf8'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('hex'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('utf/8'));\n// Prints: false\n\nconsole.log(Buffer.isEncoding(''));\n// Prints: false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconsole.log(Buffer.isEncoding('utf8'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('hex'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('utf/8'));\n// Prints: false\n\nconsole.log(Buffer.isEncoding(''));\n// Prints: false\n```","summary":"Returns `true` if `encoding` is the name of a supported character encoding, or `false` otherwise.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconsole.log(Buffer.isEncoding('utf8'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('hex'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('utf/8'));\n// Prints: false\n\nconsole.log(Buffer.isEncoding(''));\n// Prints: false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconsole.log(Buffer.isEncoding('utf8'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('hex'));\n// Prints: true\n\nconsole.log(Buffer.isEncoding('utf/8'));\n// Prints: false\n\nconsole.log(Buffer.isEncoding(''));\n// Prints: false"}],"children":[]},{"kind":"property","id":"bufferpoolsize","name":"poolSize","title":"`Buffer.poolSize`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.3.0"],"prUrl":"https://github.com/nodejs/node/pull/63597","commit":null,"description":"Default raised from 8192 to 65536."}],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":"65536","description":"This is the size (in bytes) of pre-allocated internal `Buffer` instances used\nfor pooling. This value may be modified.","summary":"This is the size (in bytes) of pre-allocated internal `Buffer` instances used for pooling. This value may be modified.","examples":[],"children":[]},{"kind":"property","id":"bufindex","name":"[index]","title":"`buf[index]`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The index operator `[index]` can be used to get and set the octet at position\n`index` in `buf`. The values refer to individual bytes, so the legal value\nrange is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal).\n\nThis operator is inherited from `Uint8Array`, so its behavior on out-of-bounds\naccess is the same as `Uint8Array`. In other words, `buf[index]` returns\n`undefined` when `index` is negative or greater or equal to `buf.length`, and\n`buf[index] = value` does not modify the buffer if `index` is negative or\n`>= buf.length`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Copy an ASCII string into a `Buffer` one byte at a time.\n// (This only works for ASCII-only strings. In general, one should use\n// `Buffer.from()` to perform this conversion.)\n\nconst str = 'Node.js';\nconst buf = Buffer.allocUnsafe(str.length);\n\nfor (let i = 0; i < str.length; i++) {\n  buf[i] = str.charCodeAt(i);\n}\n\nconsole.log(buf.toString('utf8'));\n// Prints: Node.js\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Copy an ASCII string into a `Buffer` one byte at a time.\n// (This only works for ASCII-only strings. In general, one should use\n// `Buffer.from()` to perform this conversion.)\n\nconst str = 'Node.js';\nconst buf = Buffer.allocUnsafe(str.length);\n\nfor (let i = 0; i < str.length; i++) {\n  buf[i] = str.charCodeAt(i);\n}\n\nconsole.log(buf.toString('utf8'));\n// Prints: Node.js\n```","summary":"The index operator `[index]` can be used to get and set the octet at position `index` in `buf`. The values refer to individual bytes, so the legal value range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal).","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Copy an ASCII string into a `Buffer` one byte at a time.\n// (This only works for ASCII-only strings. In general, one should use\n// `Buffer.from()` to perform this conversion.)\n\nconst str = 'Node.js';\nconst buf = Buffer.allocUnsafe(str.length);\n\nfor (let i = 0; i < str.length; i++) {\n  buf[i] = str.charCodeAt(i);\n}\n\nconsole.log(buf.toString('utf8'));\n// Prints: Node.js"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Copy an ASCII string into a `Buffer` one byte at a time.\n// (This only works for ASCII-only strings. In general, one should use\n// `Buffer.from()` to perform this conversion.)\n\nconst str = 'Node.js';\nconst buf = Buffer.allocUnsafe(str.length);\n\nfor (let i = 0; i < str.length; i++) {\n  buf[i] = str.charCodeAt(i);\n}\n\nconsole.log(buf.toString('utf8'));\n// Prints: Node.js"}],"children":[]},{"kind":"property","id":"bufbuffer","name":"buffer","title":"`buf.buffer`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"ArrayBuffer","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11}]},"default":null,"description":"The underlying `ArrayBuffer` object based on which this `Buffer`\nobject is created.\n\nThis `ArrayBuffer` is not guaranteed to correspond exactly to the original\n`Buffer`. See the notes on `buf.byteOffset` for details.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst arrayBuffer = new ArrayBuffer(16);\nconst buffer = Buffer.from(arrayBuffer);\n\nconsole.log(buffer.buffer === arrayBuffer);\n// Prints: true\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst arrayBuffer = new ArrayBuffer(16);\nconst buffer = Buffer.from(arrayBuffer);\n\nconsole.log(buffer.buffer === arrayBuffer);\n// Prints: true\n```","summary":"This `ArrayBuffer` is not guaranteed to correspond exactly to the original `Buffer`. See the notes on `buf.byteOffset` for details.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst arrayBuffer = new ArrayBuffer(16);\nconst buffer = Buffer.from(arrayBuffer);\n\nconsole.log(buffer.buffer === arrayBuffer);\n// Prints: true"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst arrayBuffer = new ArrayBuffer(16);\nconst buffer = Buffer.from(arrayBuffer);\n\nconsole.log(buffer.buffer === arrayBuffer);\n// Prints: true"}],"children":[]},{"kind":"property","id":"bufbyteoffset","name":"byteOffset","title":"`buf.byteOffset`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The `byteOffset` of the `Buffer`'s underlying `ArrayBuffer` object.\n\nWhen setting `byteOffset` in `Buffer.from(ArrayBuffer, byteOffset, length)`,\nor sometimes when allocating a `Buffer` smaller than `Buffer.poolSize`, the\nbuffer does not start from a zero offset on the underlying `ArrayBuffer`.\n\nThis can cause problems when accessing the underlying `ArrayBuffer` directly\nusing `buf.buffer`, as other parts of the `ArrayBuffer` may be unrelated\nto the `Buffer` object itself.\n\nA common issue when creating a `TypedArray` object that shares its memory with\na `Buffer` is that in this case one needs to specify the `byteOffset` correctly:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create a buffer smaller than `Buffer.poolSize`.\nconst nodeBuffer = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);\n\n// When casting the Node.js Buffer to an Int8Array, use the byteOffset\n// to refer only to the part of `nodeBuffer.buffer` that contains the memory\n// for `nodeBuffer`.\nnew Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length);\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create a buffer smaller than `Buffer.poolSize`.\nconst nodeBuffer = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);\n\n// When casting the Node.js Buffer to an Int8Array, use the byteOffset\n// to refer only to the part of `nodeBuffer.buffer` that contains the memory\n// for `nodeBuffer`.\nnew Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length);\n```","summary":"When setting `byteOffset` in `Buffer.from(ArrayBuffer, byteOffset, length)`, or sometimes when allocating a `Buffer` smaller than `Buffer.poolSize`, the buffer does not start from a zero offset on the underlying `ArrayBuffer`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create a buffer smaller than `Buffer.poolSize`.\nconst nodeBuffer = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);\n\n// When casting the Node.js Buffer to an Int8Array, use the byteOffset\n// to refer only to the part of `nodeBuffer.buffer` that contains the memory\n// for `nodeBuffer`.\nnew Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length);"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create a buffer smaller than `Buffer.poolSize`.\nconst nodeBuffer = Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);\n\n// When casting the Node.js Buffer to an Int8Array, use the byteOffset\n// to refer only to the part of `nodeBuffer.buffer` that contains the memory\n// for `nodeBuffer`.\nnew Int8Array(nodeBuffer.buffer, nodeBuffer.byteOffset, nodeBuffer.length);"}],"children":[]},{"kind":"method","id":"bufcomparetarget-targetstart-targetend-sourcestart-sourceend","name":"compare","title":"`buf.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The `target` parameter can now be a `Uint8Array`."},{"versions":["v5.11.0"],"prUrl":"https://github.com/nodejs/node/pull/5880","commit":null,"description":"Additional parameters for specifying offsets are supported now."}],"signature":{"parameters":[{"name":"target","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"A `Buffer` or {Uint8Array} with which to\ncompare `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"targetStart","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `target` at which to begin\ncomparison.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"targetEnd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `target` at which to end comparison\n(not inclusive).","default":"target.length","optional":true,"rest":false,"properties":[]},{"name":"sourceStart","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `buf` at which to begin comparison.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"sourceEnd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `buf` at which to end comparison\n(not inclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Compares `buf` with `target` and returns a number indicating whether `buf`\ncomes before, after, or is the same as `target` in sort order.\nComparison is based on the actual sequence of bytes in each `Buffer`.\n\n* `0` is returned if `target` is the same as `buf`\n* `1` is returned if `target` should come *before* `buf` when sorted.\n* `-1` is returned if `target` should come *after* `buf` when sorted.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('BCD');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.compare(buf1));\n// Prints: 0\nconsole.log(buf1.compare(buf2));\n// Prints: -1\nconsole.log(buf1.compare(buf3));\n// Prints: -1\nconsole.log(buf2.compare(buf1));\n// Prints: 1\nconsole.log(buf2.compare(buf3));\n// Prints: 1\nconsole.log([buf1, buf2, buf3].sort(Buffer.compare));\n// Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]\n// (This result is equal to: [buf1, buf3, buf2].)\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('BCD');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.compare(buf1));\n// Prints: 0\nconsole.log(buf1.compare(buf2));\n// Prints: -1\nconsole.log(buf1.compare(buf3));\n// Prints: -1\nconsole.log(buf2.compare(buf1));\n// Prints: 1\nconsole.log(buf2.compare(buf3));\n// Prints: 1\nconsole.log([buf1, buf2, buf3].sort(Buffer.compare));\n// Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]\n// (This result is equal to: [buf1, buf3, buf2].)\n```\n\nThe optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`\narguments can be used to limit the comparison to specific ranges within `target`\nand `buf` respectively.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);\nconst buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);\n\nconsole.log(buf1.compare(buf2, 5, 9, 0, 4));\n// Prints: 0\nconsole.log(buf1.compare(buf2, 0, 6, 4));\n// Prints: -1\nconsole.log(buf1.compare(buf2, 5, 6, 5));\n// Prints: 1\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);\nconst buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);\n\nconsole.log(buf1.compare(buf2, 5, 9, 0, 4));\n// Prints: 0\nconsole.log(buf1.compare(buf2, 0, 6, 4));\n// Prints: -1\nconsole.log(buf1.compare(buf2, 5, 6, 5));\n// Prints: 1\n```\n\n[`ERR_OUT_OF_RANGE`](errors.html#err_out_of_range) is thrown if `targetStart < 0`, `sourceStart < 0`,\n`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.","summary":"Compares `buf` with `target` and returns a number indicating whether `buf` comes before, after, or is the same as `target` in sort order. Comparison is based on the actual sequence of bytes in each `Buffer`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('BCD');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.compare(buf1));\n// Prints: 0\nconsole.log(buf1.compare(buf2));\n// Prints: -1\nconsole.log(buf1.compare(buf3));\n// Prints: -1\nconsole.log(buf2.compare(buf1));\n// Prints: 1\nconsole.log(buf2.compare(buf3));\n// Prints: 1\nconsole.log([buf1, buf2, buf3].sort(Buffer.compare));\n// Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]\n// (This result is equal to: [buf1, buf3, buf2].)"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('BCD');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.compare(buf1));\n// Prints: 0\nconsole.log(buf1.compare(buf2));\n// Prints: -1\nconsole.log(buf1.compare(buf3));\n// Prints: -1\nconsole.log(buf2.compare(buf1));\n// Prints: 1\nconsole.log(buf2.compare(buf3));\n// Prints: 1\nconsole.log([buf1, buf2, buf3].sort(Buffer.compare));\n// Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]\n// (This result is equal to: [buf1, buf3, buf2].)"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);\nconst buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);\n\nconsole.log(buf1.compare(buf2, 5, 9, 0, 4));\n// Prints: 0\nconsole.log(buf1.compare(buf2, 0, 6, 4));\n// Prints: -1\nconsole.log(buf1.compare(buf2, 5, 6, 5));\n// Prints: 1"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);\nconst buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);\n\nconsole.log(buf1.compare(buf2, 5, 9, 0, 4));\n// Prints: 0\nconsole.log(buf1.compare(buf2, 0, 6, 4));\n// Prints: -1\nconsole.log(buf1.compare(buf2, 5, 6, 5));\n// Prints: 1"}],"children":[]},{"kind":"method","id":"bufcopytarget-targetstart-sourcestart-sourceend","name":"copy","title":"`buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.90"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"target","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"A `Buffer` or {Uint8Array} to copy into.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"targetStart","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `target` at which to begin\nwriting.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"sourceStart","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `buf` from which to begin copying.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"sourceEnd","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The offset within `buf` at which to stop copying (not\ninclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The number of bytes copied."}},"description":"Copies data from a region of `buf` to a region in `target`, even if the `target`\nmemory region overlaps with `buf`.\n\n[`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available\nfor all TypedArrays, including Node.js `Buffer`s, although it takes\ndifferent function arguments.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create two `Buffer` instances.\nconst buf1 = Buffer.allocUnsafe(26);\nconst buf2 = Buffer.allocUnsafe(26).fill('!');\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\n// Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.\nbuf1.copy(buf2, 8, 16, 20);\n// This is equivalent to:\n// buf2.set(buf1.subarray(16, 20), 8);\n\nconsole.log(buf2.toString('ascii', 0, 25));\n// Prints: !!!!!!!!qrst!!!!!!!!!!!!!\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create two `Buffer` instances.\nconst buf1 = Buffer.allocUnsafe(26);\nconst buf2 = Buffer.allocUnsafe(26).fill('!');\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\n// Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.\nbuf1.copy(buf2, 8, 16, 20);\n// This is equivalent to:\n// buf2.set(buf1.subarray(16, 20), 8);\n\nconsole.log(buf2.toString('ascii', 0, 25));\n// Prints: !!!!!!!!qrst!!!!!!!!!!!!!\n```\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create a `Buffer` and copy data from one region to an overlapping region\n// within the same `Buffer`.\n\nconst buf = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf[i] = i + 97;\n}\n\nbuf.copy(buf, 0, 4, 10);\n\nconsole.log(buf.toString());\n// Prints: efghijghijklmnopqrstuvwxyz\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create a `Buffer` and copy data from one region to an overlapping region\n// within the same `Buffer`.\n\nconst buf = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf[i] = i + 97;\n}\n\nbuf.copy(buf, 0, 4, 10);\n\nconsole.log(buf.toString());\n// Prints: efghijghijklmnopqrstuvwxyz\n```","summary":"Copies data from a region of `buf` to a region in `target`, even if the `target` memory region overlaps with `buf`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create two `Buffer` instances.\nconst buf1 = Buffer.allocUnsafe(26);\nconst buf2 = Buffer.allocUnsafe(26).fill('!');\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\n// Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.\nbuf1.copy(buf2, 8, 16, 20);\n// This is equivalent to:\n// buf2.set(buf1.subarray(16, 20), 8);\n\nconsole.log(buf2.toString('ascii', 0, 25));\n// Prints: !!!!!!!!qrst!!!!!!!!!!!!!"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create two `Buffer` instances.\nconst buf1 = Buffer.allocUnsafe(26);\nconst buf2 = Buffer.allocUnsafe(26).fill('!');\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\n// Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.\nbuf1.copy(buf2, 8, 16, 20);\n// This is equivalent to:\n// buf2.set(buf1.subarray(16, 20), 8);\n\nconsole.log(buf2.toString('ascii', 0, 25));\n// Prints: !!!!!!!!qrst!!!!!!!!!!!!!"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create a `Buffer` and copy data from one region to an overlapping region\n// within the same `Buffer`.\n\nconst buf = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf[i] = i + 97;\n}\n\nbuf.copy(buf, 0, 4, 10);\n\nconsole.log(buf.toString());\n// Prints: efghijghijklmnopqrstuvwxyz"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create a `Buffer` and copy data from one region to an overlapping region\n// within the same `Buffer`.\n\nconst buf = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf[i] = i + 97;\n}\n\nbuf.copy(buf, 0, 4, 10);\n\nconsole.log(buf.toString());\n// Prints: efghijghijklmnopqrstuvwxyz"}],"children":[]},{"kind":"method","id":"bufentries","name":"entries","title":"`buf.entries()`","scope":"module","overloadOf":null,"stability":null,"added":["v1.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Iterator","links":[{"name":"Iterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Iterator","start":0,"end":8}]},"description":""}},"description":"Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents\nof `buf`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Log the entire contents of a `Buffer`.\n\nconst buf = Buffer.from('buffer');\n\nfor (const pair of buf.entries()) {\n  console.log(pair);\n}\n// Prints:\n//   [0, 98]\n//   [1, 117]\n//   [2, 102]\n//   [3, 102]\n//   [4, 101]\n//   [5, 114]\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Log the entire contents of a `Buffer`.\n\nconst buf = Buffer.from('buffer');\n\nfor (const pair of buf.entries()) {\n  console.log(pair);\n}\n// Prints:\n//   [0, 98]\n//   [1, 117]\n//   [2, 102]\n//   [3, 102]\n//   [4, 101]\n//   [5, 114]\n```","summary":"Creates and returns an iterator of `[index, byte]` pairs from the contents of `buf`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Log the entire contents of a `Buffer`.\n\nconst buf = Buffer.from('buffer');\n\nfor (const pair of buf.entries()) {\n  console.log(pair);\n}\n// Prints:\n//   [0, 98]\n//   [1, 117]\n//   [2, 102]\n//   [3, 102]\n//   [4, 101]\n//   [5, 114]"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Log the entire contents of a `Buffer`.\n\nconst buf = Buffer.from('buffer');\n\nfor (const pair of buf.entries()) {\n  console.log(pair);\n}\n// Prints:\n//   [0, 98]\n//   [1, 117]\n//   [2, 102]\n//   [3, 102]\n//   [4, 101]\n//   [5, 114]"}],"children":[]},{"kind":"method","id":"bufequalsotherbuffer","name":"equals","title":"`buf.equals(otherBuffer)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.13"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The arguments can now be `Uint8Array`s."}],"signature":{"parameters":[{"name":"otherBuffer","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"A `Buffer` or {Uint8Array} with which to\ncompare `buf`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,\n`false` otherwise. Equivalent to\n[`buf.compare(otherBuffer) === 0`](#bufcomparetarget-targetstart-targetend-sourcestart-sourceend).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('414243', 'hex');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.equals(buf2));\n// Prints: true\nconsole.log(buf1.equals(buf3));\n// Prints: false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('414243', 'hex');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.equals(buf2));\n// Prints: true\nconsole.log(buf1.equals(buf3));\n// Prints: false\n```","summary":"Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes, `false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('414243', 'hex');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.equals(buf2));\n// Prints: true\nconsole.log(buf1.equals(buf3));\n// Prints: false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from('ABC');\nconst buf2 = Buffer.from('414243', 'hex');\nconst buf3 = Buffer.from('ABCD');\n\nconsole.log(buf1.equals(buf2));\n// Prints: true\nconsole.log(buf1.equals(buf3));\n// Prints: false"}],"children":[]},{"kind":"method","id":"buffillvalue-offset-end-encoding","name":"fill","title":"`buf.fill(value[, offset[, end]][, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v11.0.0"],"prUrl":"https://github.com/nodejs/node/pull/22969","commit":null,"description":"Throws `ERR_OUT_OF_RANGE` instead of `ERR_INDEX_OUT_OF_RANGE`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18790","commit":null,"description":"Negative `end` values throw an `ERR_INDEX_OUT_OF_RANGE` error."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18129","commit":null,"description":"Attempting to fill a non-zero length buffer with a zero length buffer triggers a thrown exception."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/17427","commit":null,"description":"Specifying an invalid string for `value` triggers a thrown exception."},{"versions":["v5.7.0"],"prUrl":"https://github.com/nodejs/node/pull/4935","commit":null,"description":"The `encoding` parameter is supported now."}],"signature":{"parameters":[{"name":"value","type":{"text":"string | Buffer | Uint8Array | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":18,"end":28},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":31,"end":38}]},"description":"The value with which to fill `buf`.\nEmpty value (string, Uint8Array, Buffer) is coerced to `0`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to fill `buf`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to stop filling `buf` (not inclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The encoding for `value` if `value` is a string.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A reference to `buf`."}},"description":"Fills `buf` with the specified `value`. If the `offset` and `end` are not given,\nthe entire `buf` will be filled:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Fill a `Buffer` with the ASCII character 'h'.\n\nconst b = Buffer.allocUnsafe(50).fill('h');\n\nconsole.log(b.toString());\n// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n\n// Fill a buffer with empty string\nconst c = Buffer.allocUnsafe(5).fill('');\n\nconsole.log(c.fill(''));\n// Prints: <Buffer 00 00 00 00 00>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Fill a `Buffer` with the ASCII character 'h'.\n\nconst b = Buffer.allocUnsafe(50).fill('h');\n\nconsole.log(b.toString());\n// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n\n// Fill a buffer with empty string\nconst c = Buffer.allocUnsafe(5).fill('');\n\nconsole.log(c.fill(''));\n// Prints: <Buffer 00 00 00 00 00>\n```\n\n`value` is coerced to a `uint32` value if it is not a string, `Buffer`, or\ninteger. If the resulting integer is greater than `255` (decimal), `buf` will be\nfilled with `value & 255`.\n\nIf the final write of a `fill()` operation falls on a multi-byte character,\nthen only the bytes of that character that fit into `buf` are written:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Fill a `Buffer` with character that takes up two bytes in UTF-8.\n\nconsole.log(Buffer.allocUnsafe(5).fill('\\u0222'));\n// Prints: <Buffer c8 a2 c8 a2 c8>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Fill a `Buffer` with character that takes up two bytes in UTF-8.\n\nconsole.log(Buffer.allocUnsafe(5).fill('\\u0222'));\n// Prints: <Buffer c8 a2 c8 a2 c8>\n```\n\nIf `value` contains invalid characters, it is truncated; if no valid\nfill data remains, an exception is thrown:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(5);\n\nconsole.log(buf.fill('a'));\n// Prints: <Buffer 61 61 61 61 61>\nconsole.log(buf.fill('aazz', 'hex'));\n// Prints: <Buffer aa aa aa aa aa>\nconsole.log(buf.fill('zz', 'hex'));\n// Throws an exception.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(5);\n\nconsole.log(buf.fill('a'));\n// Prints: <Buffer 61 61 61 61 61>\nconsole.log(buf.fill('aazz', 'hex'));\n// Prints: <Buffer aa aa aa aa aa>\nconsole.log(buf.fill('zz', 'hex'));\n// Throws an exception.\n```","summary":"Fills `buf` with the specified `value`. If the `offset` and `end` are not given, the entire `buf` will be filled:","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Fill a `Buffer` with the ASCII character 'h'.\n\nconst b = Buffer.allocUnsafe(50).fill('h');\n\nconsole.log(b.toString());\n// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n\n// Fill a buffer with empty string\nconst c = Buffer.allocUnsafe(5).fill('');\n\nconsole.log(c.fill(''));\n// Prints: <Buffer 00 00 00 00 00>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Fill a `Buffer` with the ASCII character 'h'.\n\nconst b = Buffer.allocUnsafe(50).fill('h');\n\nconsole.log(b.toString());\n// Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh\n\n// Fill a buffer with empty string\nconst c = Buffer.allocUnsafe(5).fill('');\n\nconsole.log(c.fill(''));\n// Prints: <Buffer 00 00 00 00 00>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Fill a `Buffer` with character that takes up two bytes in UTF-8.\n\nconsole.log(Buffer.allocUnsafe(5).fill('\\u0222'));\n// Prints: <Buffer c8 a2 c8 a2 c8>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Fill a `Buffer` with character that takes up two bytes in UTF-8.\n\nconsole.log(Buffer.allocUnsafe(5).fill('\\u0222'));\n// Prints: <Buffer c8 a2 c8 a2 c8>"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(5);\n\nconsole.log(buf.fill('a'));\n// Prints: <Buffer 61 61 61 61 61>\nconsole.log(buf.fill('aazz', 'hex'));\n// Prints: <Buffer aa aa aa aa aa>\nconsole.log(buf.fill('zz', 'hex'));\n// Throws an exception."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(5);\n\nconsole.log(buf.fill('a'));\n// Prints: <Buffer 61 61 61 61 61>\nconsole.log(buf.fill('aazz', 'hex'));\n// Prints: <Buffer aa aa aa aa aa>\nconsole.log(buf.fill('zz', 'hex'));\n// Throws an exception."}],"children":[]},{"kind":"method","id":"bufincludesvalue-start-end-encoding","name":"includes","title":"`buf.includes(value[, start[, end]][, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v5.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62390","commit":null,"description":"Added the `end` parameter."},{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."}],"signature":{"parameters":[{"name":"value","type":{"text":"string | Buffer | Uint8Array | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":18,"end":28},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":31,"end":38}]},"description":"What to search for.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to begin searching in `buf`. If negative, then\noffset is calculated from the end of `buf`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to stop searching in `buf` (exclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"If `value` is a string, this is its encoding.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"`true` if `value` was found in `buf`, `false` otherwise."}},"description":"Equivalent to [`buf.indexOf() !== -1`](#bufindexofvalue-start-end-encoding).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.includes('this'));\n// Prints: true\nconsole.log(buf.includes('is'));\n// Prints: true\nconsole.log(buf.includes(Buffer.from('a buffer')));\n// Prints: true\nconsole.log(buf.includes(97));\n// Prints: true (97 is the decimal ASCII value for 'a')\nconsole.log(buf.includes(Buffer.from('a buffer example')));\n// Prints: false\nconsole.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: true\nconsole.log(buf.includes('this', 4));\n// Prints: false\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.includes('this'));\n// Prints: true\nconsole.log(buf.includes('is'));\n// Prints: true\nconsole.log(buf.includes(Buffer.from('a buffer')));\n// Prints: true\nconsole.log(buf.includes(97));\n// Prints: true (97 is the decimal ASCII value for 'a')\nconsole.log(buf.includes(Buffer.from('a buffer example')));\n// Prints: false\nconsole.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: true\nconsole.log(buf.includes('this', 4));\n// Prints: false\n```","summary":"Equivalent to `buf.indexOf() !== -1`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.includes('this'));\n// Prints: true\nconsole.log(buf.includes('is'));\n// Prints: true\nconsole.log(buf.includes(Buffer.from('a buffer')));\n// Prints: true\nconsole.log(buf.includes(97));\n// Prints: true (97 is the decimal ASCII value for 'a')\nconsole.log(buf.includes(Buffer.from('a buffer example')));\n// Prints: false\nconsole.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: true\nconsole.log(buf.includes('this', 4));\n// Prints: false"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.includes('this'));\n// Prints: true\nconsole.log(buf.includes('is'));\n// Prints: true\nconsole.log(buf.includes(Buffer.from('a buffer')));\n// Prints: true\nconsole.log(buf.includes(97));\n// Prints: true (97 is the decimal ASCII value for 'a')\nconsole.log(buf.includes(Buffer.from('a buffer example')));\n// Prints: false\nconsole.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: true\nconsole.log(buf.includes('this', 4));\n// Prints: false"}],"children":[]},{"kind":"method","id":"bufindexofvalue-start-end-encoding","name":"indexOf","title":"`buf.indexOf(value[, start[, end]][, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v1.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62390","commit":null,"description":"Added the `end` parameter."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The `value` can now be a `Uint8Array`."},{"versions":["v5.7.0","v4.4.0"],"prUrl":"https://github.com/nodejs/node/pull/4803","commit":null,"description":"When `encoding` is being passed, the `byteOffset` parameter is no longer required."}],"signature":{"parameters":[{"name":"value","type":{"text":"string | Buffer | Uint8Array | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":18,"end":28},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":31,"end":38}]},"description":"What to search for.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to begin searching in `buf`. If negative, then\noffset is calculated from the end of `buf`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to stop searching in `buf` (exclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"If `value` is a string, this is the encoding used to\ndetermine the binary representation of the string that will be searched for in\n`buf`.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The index of the first occurrence of `value` in `buf`, or\n`-1` if `buf` does not contain `value`."}},"description":"If `value` is:\n\n* a string, `value` is interpreted according to the character encoding in\n  `encoding`.\n* a `Buffer` or {Uint8Array}, `value` will be used in its entirety.\n  To compare a partial `Buffer`, use [`buf.subarray`](#bufsubarraystart-end).\n* a number, `value` will be interpreted as an unsigned 8-bit integer\n  value between `0` and `255`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.indexOf('this'));\n// Prints: 0\nconsole.log(buf.indexOf('is'));\n// Prints: 2\nconsole.log(buf.indexOf(Buffer.from('a buffer')));\n// Prints: 8\nconsole.log(buf.indexOf(97));\n// Prints: 8 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.indexOf(Buffer.from('a buffer example')));\n// Prints: -1\nconsole.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: 8\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.indexOf('\\u03a3', 0, 'utf16le'));\n// Prints: 4\nconsole.log(utf16Buffer.indexOf('\\u03a3', -4, 'utf16le'));\n// Prints: 6\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.indexOf('this'));\n// Prints: 0\nconsole.log(buf.indexOf('is'));\n// Prints: 2\nconsole.log(buf.indexOf(Buffer.from('a buffer')));\n// Prints: 8\nconsole.log(buf.indexOf(97));\n// Prints: 8 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.indexOf(Buffer.from('a buffer example')));\n// Prints: -1\nconsole.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: 8\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.indexOf('\\u03a3', 0, 'utf16le'));\n// Prints: 4\nconsole.log(utf16Buffer.indexOf('\\u03a3', -4, 'utf16le'));\n// Prints: 6\n```\n\nIf `value` is not a string, number, or `Buffer`, this method will throw a\n`TypeError`. If `value` is a number, it will be coerced to a valid byte value,\nan integer between 0 and 255.\n\nIf `byteOffset` is not a number, it will be coerced to a number. If the result\nof coercion is `NaN` or `0`, then the entire buffer will be searched. This\nbehavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.indexOf(99.9));\nconsole.log(b.indexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN or 0.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.indexOf('b', undefined));\nconsole.log(b.indexOf('b', {}));\nconsole.log(b.indexOf('b', null));\nconsole.log(b.indexOf('b', []));\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.indexOf(99.9));\nconsole.log(b.indexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN or 0.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.indexOf('b', undefined));\nconsole.log(b.indexOf('b', {}));\nconsole.log(b.indexOf('b', null));\nconsole.log(b.indexOf('b', []));\n```\n\nIf `value` is an empty string or empty `Buffer` and `byteOffset` is less\nthan `buf.length`, `byteOffset` will be returned. If `value` is empty and\n`byteOffset` is at least `buf.length`, `buf.length` will be returned.","summary":"If `value` is:","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.indexOf('this'));\n// Prints: 0\nconsole.log(buf.indexOf('is'));\n// Prints: 2\nconsole.log(buf.indexOf(Buffer.from('a buffer')));\n// Prints: 8\nconsole.log(buf.indexOf(97));\n// Prints: 8 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.indexOf(Buffer.from('a buffer example')));\n// Prints: -1\nconsole.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: 8\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.indexOf('\\u03a3', 0, 'utf16le'));\n// Prints: 4\nconsole.log(utf16Buffer.indexOf('\\u03a3', -4, 'utf16le'));\n// Prints: 6"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this is a buffer');\n\nconsole.log(buf.indexOf('this'));\n// Prints: 0\nconsole.log(buf.indexOf('is'));\n// Prints: 2\nconsole.log(buf.indexOf(Buffer.from('a buffer')));\n// Prints: 8\nconsole.log(buf.indexOf(97));\n// Prints: 8 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.indexOf(Buffer.from('a buffer example')));\n// Prints: -1\nconsole.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));\n// Prints: 8\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.indexOf('\\u03a3', 0, 'utf16le'));\n// Prints: 4\nconsole.log(utf16Buffer.indexOf('\\u03a3', -4, 'utf16le'));\n// Prints: 6"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.indexOf(99.9));\nconsole.log(b.indexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN or 0.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.indexOf('b', undefined));\nconsole.log(b.indexOf('b', {}));\nconsole.log(b.indexOf('b', null));\nconsole.log(b.indexOf('b', []));"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.indexOf(99.9));\nconsole.log(b.indexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN or 0.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.indexOf('b', undefined));\nconsole.log(b.indexOf('b', {}));\nconsole.log(b.indexOf('b', null));\nconsole.log(b.indexOf('b', []));"}],"children":[]},{"kind":"method","id":"bufkeys","name":"keys","title":"`buf.keys()`","scope":"module","overloadOf":null,"stability":null,"added":["v1.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Iterator","links":[{"name":"Iterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Iterator","start":0,"end":8}]},"description":""}},"description":"Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indexes).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nfor (const key of buf.keys()) {\n  console.log(key);\n}\n// Prints:\n//   0\n//   1\n//   2\n//   3\n//   4\n//   5\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nfor (const key of buf.keys()) {\n  console.log(key);\n}\n// Prints:\n//   0\n//   1\n//   2\n//   3\n//   4\n//   5\n```","summary":"Creates and returns an iterator of `buf` keys (indexes).","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nfor (const key of buf.keys()) {\n  console.log(key);\n}\n// Prints:\n//   0\n//   1\n//   2\n//   3\n//   4\n//   5"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nfor (const key of buf.keys()) {\n  console.log(key);\n}\n// Prints:\n//   0\n//   1\n//   2\n//   3\n//   4\n//   5"}],"children":[]},{"kind":"method","id":"buflastindexofvalue-start-end-encoding","name":"lastIndexOf","title":"`buf.lastIndexOf(value[, start[, end]][, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v6.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.1.0"],"prUrl":"https://github.com/nodejs/node/pull/62390","commit":null,"description":"Added the `end` parameter."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The `value` can now be a `Uint8Array`."}],"signature":{"parameters":[{"name":"value","type":{"text":"string | Buffer | Uint8Array | integer","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":18,"end":28},{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":31,"end":38}]},"description":"What to search for.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to begin searching in `buf`. If negative, then\noffset is calculated from the end of `buf`.","default":"buf.length - 1","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where to stop searching in `buf` (exclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"If `value` is a string, this is the encoding used to\ndetermine the binary representation of the string that will be searched for in\n`buf`.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The index of the last occurrence of `value` in `buf`, or\n`-1` if `buf` does not contain `value`."}},"description":"Identical to [`buf.indexOf()`](#bufindexofvalue-start-end-encoding), except the last occurrence of `value` is found\nrather than the first occurrence.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this buffer is a buffer');\n\nconsole.log(buf.lastIndexOf('this'));\n// Prints: 0\nconsole.log(buf.lastIndexOf('buffer'));\n// Prints: 17\nconsole.log(buf.lastIndexOf(Buffer.from('buffer')));\n// Prints: 17\nconsole.log(buf.lastIndexOf(97));\n// Prints: 15 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.lastIndexOf(Buffer.from('yolo')));\n// Prints: -1\nconsole.log(buf.lastIndexOf('buffer', 5));\n// Prints: 5\nconsole.log(buf.lastIndexOf('buffer', 4));\n// Prints: -1\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', undefined, 'utf16le'));\n// Prints: 6\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', -5, 'utf16le'));\n// Prints: 4\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this buffer is a buffer');\n\nconsole.log(buf.lastIndexOf('this'));\n// Prints: 0\nconsole.log(buf.lastIndexOf('buffer'));\n// Prints: 17\nconsole.log(buf.lastIndexOf(Buffer.from('buffer')));\n// Prints: 17\nconsole.log(buf.lastIndexOf(97));\n// Prints: 15 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.lastIndexOf(Buffer.from('yolo')));\n// Prints: -1\nconsole.log(buf.lastIndexOf('buffer', 5));\n// Prints: 5\nconsole.log(buf.lastIndexOf('buffer', 4));\n// Prints: -1\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', undefined, 'utf16le'));\n// Prints: 6\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', -5, 'utf16le'));\n// Prints: 4\n```\n\nIf `value` is not a string, number, or `Buffer`, this method will throw a\n`TypeError`. If `value` is a number, it will be coerced to a valid byte value,\nan integer between 0 and 255.\n\nIf `byteOffset` is not a number, it will be coerced to a number. Any arguments\nthat coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.\nThis behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.lastIndexOf(99.9));\nconsole.log(b.lastIndexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.lastIndexOf('b', undefined));\nconsole.log(b.lastIndexOf('b', {}));\n\n// Passing a byteOffset that coerces to 0.\n// Prints: -1, equivalent to passing 0.\nconsole.log(b.lastIndexOf('b', null));\nconsole.log(b.lastIndexOf('b', []));\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.lastIndexOf(99.9));\nconsole.log(b.lastIndexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.lastIndexOf('b', undefined));\nconsole.log(b.lastIndexOf('b', {}));\n\n// Passing a byteOffset that coerces to 0.\n// Prints: -1, equivalent to passing 0.\nconsole.log(b.lastIndexOf('b', null));\nconsole.log(b.lastIndexOf('b', []));\n```\n\nIf `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.","summary":"Identical to `buf.indexOf()`, except the last occurrence of `value` is found rather than the first occurrence.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('this buffer is a buffer');\n\nconsole.log(buf.lastIndexOf('this'));\n// Prints: 0\nconsole.log(buf.lastIndexOf('buffer'));\n// Prints: 17\nconsole.log(buf.lastIndexOf(Buffer.from('buffer')));\n// Prints: 17\nconsole.log(buf.lastIndexOf(97));\n// Prints: 15 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.lastIndexOf(Buffer.from('yolo')));\n// Prints: -1\nconsole.log(buf.lastIndexOf('buffer', 5));\n// Prints: 5\nconsole.log(buf.lastIndexOf('buffer', 4));\n// Prints: -1\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', undefined, 'utf16le'));\n// Prints: 6\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', -5, 'utf16le'));\n// Prints: 4"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('this buffer is a buffer');\n\nconsole.log(buf.lastIndexOf('this'));\n// Prints: 0\nconsole.log(buf.lastIndexOf('buffer'));\n// Prints: 17\nconsole.log(buf.lastIndexOf(Buffer.from('buffer')));\n// Prints: 17\nconsole.log(buf.lastIndexOf(97));\n// Prints: 15 (97 is the decimal ASCII value for 'a')\nconsole.log(buf.lastIndexOf(Buffer.from('yolo')));\n// Prints: -1\nconsole.log(buf.lastIndexOf('buffer', 5));\n// Prints: 5\nconsole.log(buf.lastIndexOf('buffer', 4));\n// Prints: -1\n\nconst utf16Buffer = Buffer.from('\\u039a\\u0391\\u03a3\\u03a3\\u0395', 'utf16le');\n\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', undefined, 'utf16le'));\n// Prints: 6\nconsole.log(utf16Buffer.lastIndexOf('\\u03a3', -5, 'utf16le'));\n// Prints: 4"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.lastIndexOf(99.9));\nconsole.log(b.lastIndexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.lastIndexOf('b', undefined));\nconsole.log(b.lastIndexOf('b', {}));\n\n// Passing a byteOffset that coerces to 0.\n// Prints: -1, equivalent to passing 0.\nconsole.log(b.lastIndexOf('b', null));\nconsole.log(b.lastIndexOf('b', []));"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst b = Buffer.from('abcdef');\n\n// Passing a value that's a number, but not a valid byte.\n// Prints: 2, equivalent to searching for 99 or 'c'.\nconsole.log(b.lastIndexOf(99.9));\nconsole.log(b.lastIndexOf(256 + 99));\n\n// Passing a byteOffset that coerces to NaN.\n// Prints: 1, searching the whole buffer.\nconsole.log(b.lastIndexOf('b', undefined));\nconsole.log(b.lastIndexOf('b', {}));\n\n// Passing a byteOffset that coerces to 0.\n// Prints: -1, equivalent to passing 0.\nconsole.log(b.lastIndexOf('b', null));\nconsole.log(b.lastIndexOf('b', []));"}],"children":[]},{"kind":"property","id":"buflength","name":"length","title":"`buf.length`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.90"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"Returns the number of bytes in `buf`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create a `Buffer` and write a shorter string to it using UTF-8.\n\nconst buf = Buffer.alloc(1234);\n\nconsole.log(buf.length);\n// Prints: 1234\n\nbuf.write('some string', 0, 'utf8');\n\nconsole.log(buf.length);\n// Prints: 1234\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create a `Buffer` and write a shorter string to it using UTF-8.\n\nconst buf = Buffer.alloc(1234);\n\nconsole.log(buf.length);\n// Prints: 1234\n\nbuf.write('some string', 0, 'utf8');\n\nconsole.log(buf.length);\n// Prints: 1234\n```","summary":"Returns the number of bytes in `buf`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create a `Buffer` and write a shorter string to it using UTF-8.\n\nconst buf = Buffer.alloc(1234);\n\nconsole.log(buf.length);\n// Prints: 1234\n\nbuf.write('some string', 0, 'utf8');\n\nconsole.log(buf.length);\n// Prints: 1234"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create a `Buffer` and write a shorter string to it using UTF-8.\n\nconst buf = Buffer.alloc(1234);\n\nconsole.log(buf.length);\n// Prints: 1234\n\nbuf.write('some string', 0, 'utf8');\n\nconsole.log(buf.length);\n// Prints: 1234"}],"children":[]},{"kind":"property","id":"bufparent","name":"parent","title":"`buf.parent`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated: Use [`buf.buffer`](#bufbuffer) instead."},"added":[],"deprecated":["v8.0.0"],"removed":[],"napiVersion":[],"changes":[],"type":null,"default":null,"description":"The `buf.parent` property is a deprecated alias for `buf.buffer`.","summary":"The `buf.parent` property is a deprecated alias for `buf.buffer`.","examples":[],"children":[]},{"kind":"method","id":"bufreadbigint64beoffset","name":"readBigInt64BE","title":"`buf.readBigInt64BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":""}},"description":"Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed\nvalues.","summary":"Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.","examples":[],"children":[]},{"kind":"method","id":"bufreadbigint64leoffset","name":"readBigInt64LE","title":"`buf.readBigInt64LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":""}},"description":"Reads a signed, little-endian 64-bit integer from `buf` at the specified\n`offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed\nvalues.","summary":"Reads a signed, little-endian 64-bit integer from `buf` at the specified `offset`.","examples":[],"children":[]},{"kind":"method","id":"bufreadbiguint64beoffset","name":"readBigUInt64BE","title":"`buf.readBigUInt64BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.10.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34960","commit":null,"description":"This function is also available as `buf.readBigUint64BE()`."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":""}},"description":"Reads an unsigned, big-endian 64-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readBigUint64BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64BE(0));\n// Prints: 4294967295n\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64BE(0));\n// Prints: 4294967295n\n```","summary":"Reads an unsigned, big-endian 64-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64BE(0));\n// Prints: 4294967295n"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64BE(0));\n// Prints: 4294967295n"}],"children":[]},{"kind":"method","id":"bufreadbiguint64leoffset","name":"readBigUInt64LE","title":"`buf.readBigUInt64LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.10.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34960","commit":null,"description":"This function is also available as `buf.readBigUint64LE()`."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":""}},"description":"Reads an unsigned, little-endian 64-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readBigUint64LE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64LE(0));\n// Prints: 18446744069414584320n\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64LE(0));\n// Prints: 18446744069414584320n\n```","summary":"Reads an unsigned, little-endian 64-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64LE(0));\n// Prints: 18446744069414584320n"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);\n\nconsole.log(buf.readBigUInt64LE(0));\n// Prints: 18446744069414584320n"}],"children":[]},{"kind":"method","id":"bufreaddoublebeoffset","name":"readDoubleBE","title":"`buf.readDoubleBE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Reads a 64-bit, big-endian double from `buf` at the specified `offset`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleBE(0));\n// Prints: 8.20788039913184e-304\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleBE(0));\n// Prints: 8.20788039913184e-304\n```","summary":"Reads a 64-bit, big-endian double from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleBE(0));\n// Prints: 8.20788039913184e-304"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleBE(0));\n// Prints: 8.20788039913184e-304"}],"children":[]},{"kind":"method","id":"bufreaddoubleleoffset","name":"readDoubleLE","title":"`buf.readDoubleLE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Reads a 64-bit, little-endian double from `buf` at the specified `offset`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleLE(0));\n// Prints: 5.447603722011605e-270\nconsole.log(buf.readDoubleLE(1));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleLE(0));\n// Prints: 5.447603722011605e-270\nconsole.log(buf.readDoubleLE(1));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads a 64-bit, little-endian double from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleLE(0));\n// Prints: 5.447603722011605e-270\nconsole.log(buf.readDoubleLE(1));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);\n\nconsole.log(buf.readDoubleLE(0));\n// Prints: 5.447603722011605e-270\nconsole.log(buf.readDoubleLE(1));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadfloatbeoffset","name":"readFloatBE","title":"`buf.readFloatBE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Reads a 32-bit, big-endian float from `buf` at the specified `offset`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatBE(0));\n// Prints: 2.387939260590663e-38\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatBE(0));\n// Prints: 2.387939260590663e-38\n```","summary":"Reads a 32-bit, big-endian float from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatBE(0));\n// Prints: 2.387939260590663e-38"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatBE(0));\n// Prints: 2.387939260590663e-38"}],"children":[]},{"kind":"method","id":"bufreadfloatleoffset","name":"readFloatLE","title":"`buf.readFloatLE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":""}},"description":"Reads a 32-bit, little-endian float from `buf` at the specified `offset`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatLE(0));\n// Prints: 1.539989614439558e-36\nconsole.log(buf.readFloatLE(1));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatLE(0));\n// Prints: 1.539989614439558e-36\nconsole.log(buf.readFloatLE(1));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads a 32-bit, little-endian float from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatLE(0));\n// Prints: 1.539989614439558e-36\nconsole.log(buf.readFloatLE(1));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, 2, 3, 4]);\n\nconsole.log(buf.readFloatLE(0));\n// Prints: 1.539989614439558e-36\nconsole.log(buf.readFloatLE(1));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadint8offset","name":"readInt8","title":"`buf.readInt8([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 1`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads a signed 8-bit integer from `buf` at the specified `offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed values.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([-1, 5]);\n\nconsole.log(buf.readInt8(0));\n// Prints: -1\nconsole.log(buf.readInt8(1));\n// Prints: 5\nconsole.log(buf.readInt8(2));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([-1, 5]);\n\nconsole.log(buf.readInt8(0));\n// Prints: -1\nconsole.log(buf.readInt8(1));\n// Prints: 5\nconsole.log(buf.readInt8(2));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads a signed 8-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([-1, 5]);\n\nconsole.log(buf.readInt8(0));\n// Prints: -1\nconsole.log(buf.readInt8(1));\n// Prints: 5\nconsole.log(buf.readInt8(2));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([-1, 5]);\n\nconsole.log(buf.readInt8(0));\n// Prints: -1\nconsole.log(buf.readInt8(1));\n// Prints: 5\nconsole.log(buf.readInt8(2));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadint16beoffset","name":"readInt16BE","title":"`buf.readInt16BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed values.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16BE(0));\n// Prints: 5\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16BE(0));\n// Prints: 5\n```","summary":"Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16BE(0));\n// Prints: 5"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16BE(0));\n// Prints: 5"}],"children":[]},{"kind":"method","id":"bufreadint16leoffset","name":"readInt16LE","title":"`buf.readInt16LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads a signed, little-endian 16-bit integer from `buf` at the specified\n`offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed values.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16LE(0));\n// Prints: 1280\nconsole.log(buf.readInt16LE(1));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16LE(0));\n// Prints: 1280\nconsole.log(buf.readInt16LE(1));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads a signed, little-endian 16-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16LE(0));\n// Prints: 1280\nconsole.log(buf.readInt16LE(1));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 5]);\n\nconsole.log(buf.readInt16LE(0));\n// Prints: 1280\nconsole.log(buf.readInt16LE(1));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadint32beoffset","name":"readInt32BE","title":"`buf.readInt32BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed values.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32BE(0));\n// Prints: 5\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32BE(0));\n// Prints: 5\n```","summary":"Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32BE(0));\n// Prints: 5"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32BE(0));\n// Prints: 5"}],"children":[]},{"kind":"method","id":"bufreadint32leoffset","name":"readInt32LE","title":"`buf.readInt32LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads a signed, little-endian 32-bit integer from `buf` at the specified\n`offset`.\n\nIntegers read from a `Buffer` are interpreted as two's complement signed values.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32LE(0));\n// Prints: 83886080\nconsole.log(buf.readInt32LE(1));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32LE(0));\n// Prints: 83886080\nconsole.log(buf.readInt32LE(1));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads a signed, little-endian 32-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32LE(0));\n// Prints: 83886080\nconsole.log(buf.readInt32LE(1));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0, 0, 0, 5]);\n\nconsole.log(buf.readInt32LE(0));\n// Prints: 83886080\nconsole.log(buf.readInt32LE(1));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadintbeoffset-bytelength","name":"readIntBE","title":"`buf.readIntBE(offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to read. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads `byteLength` number of bytes from `buf` at the specified `offset`\nand interprets the result as a big-endian, two's complement signed value\nsupporting up to 48 bits of accuracy.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\nconsole.log(buf.readIntBE(1, 0).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\nconsole.log(buf.readIntBE(1, 0).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value supporting up to 48 bits of accuracy.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\nconsole.log(buf.readIntBE(1, 0).toString(16));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\nconsole.log(buf.readIntBE(1, 0).toString(16));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreadintleoffset-bytelength","name":"readIntLE","title":"`buf.readIntLE(offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to read. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads `byteLength` number of bytes from `buf` at the specified `offset`\nand interprets the result as a little-endian, two's complement signed value\nsupporting up to 48 bits of accuracy.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntLE(0, 6).toString(16));\n// Prints: -546f87a9cbee\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntLE(0, 6).toString(16));\n// Prints: -546f87a9cbee\n```","summary":"Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value supporting up to 48 bits of accuracy.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntLE(0, 6).toString(16));\n// Prints: -546f87a9cbee"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readIntLE(0, 6).toString(16));\n// Prints: -546f87a9cbee"}],"children":[]},{"kind":"method","id":"bufreaduint8offset","name":"readUInt8","title":"`buf.readUInt8([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUint8()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 1`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads an unsigned 8-bit integer from `buf` at the specified `offset`.\n\nThis function is also available under the `readUint8` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, -2]);\n\nconsole.log(buf.readUInt8(0));\n// Prints: 1\nconsole.log(buf.readUInt8(1));\n// Prints: 254\nconsole.log(buf.readUInt8(2));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, -2]);\n\nconsole.log(buf.readUInt8(0));\n// Prints: 1\nconsole.log(buf.readUInt8(1));\n// Prints: 254\nconsole.log(buf.readUInt8(2));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads an unsigned 8-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([1, -2]);\n\nconsole.log(buf.readUInt8(0));\n// Prints: 1\nconsole.log(buf.readUInt8(1));\n// Prints: 254\nconsole.log(buf.readUInt8(2));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([1, -2]);\n\nconsole.log(buf.readUInt8(0));\n// Prints: 1\nconsole.log(buf.readUInt8(1));\n// Prints: 254\nconsole.log(buf.readUInt8(2));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreaduint16beoffset","name":"readUInt16BE","title":"`buf.readUInt16BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUint16BE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads an unsigned, big-endian 16-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readUint16BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16BE(0).toString(16));\n// Prints: 1234\nconsole.log(buf.readUInt16BE(1).toString(16));\n// Prints: 3456\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16BE(0).toString(16));\n// Prints: 1234\nconsole.log(buf.readUInt16BE(1).toString(16));\n// Prints: 3456\n```","summary":"Reads an unsigned, big-endian 16-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16BE(0).toString(16));\n// Prints: 1234\nconsole.log(buf.readUInt16BE(1).toString(16));\n// Prints: 3456"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16BE(0).toString(16));\n// Prints: 1234\nconsole.log(buf.readUInt16BE(1).toString(16));\n// Prints: 3456"}],"children":[]},{"kind":"method","id":"bufreaduint16leoffset","name":"readUInt16LE","title":"`buf.readUInt16LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUint16LE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads an unsigned, little-endian 16-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readUint16LE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16LE(0).toString(16));\n// Prints: 3412\nconsole.log(buf.readUInt16LE(1).toString(16));\n// Prints: 5634\nconsole.log(buf.readUInt16LE(2).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16LE(0).toString(16));\n// Prints: 3412\nconsole.log(buf.readUInt16LE(1).toString(16));\n// Prints: 5634\nconsole.log(buf.readUInt16LE(2).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16LE(0).toString(16));\n// Prints: 3412\nconsole.log(buf.readUInt16LE(1).toString(16));\n// Prints: 5634\nconsole.log(buf.readUInt16LE(2).toString(16));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56]);\n\nconsole.log(buf.readUInt16LE(0).toString(16));\n// Prints: 3412\nconsole.log(buf.readUInt16LE(1).toString(16));\n// Prints: 5634\nconsole.log(buf.readUInt16LE(2).toString(16));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreaduint32beoffset","name":"readUInt32BE","title":"`buf.readUInt32BE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUint32BE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads an unsigned, big-endian 32-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readUint32BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32BE(0).toString(16));\n// Prints: 12345678\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32BE(0).toString(16));\n// Prints: 12345678\n```","summary":"Reads an unsigned, big-endian 32-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32BE(0).toString(16));\n// Prints: 12345678"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32BE(0).toString(16));\n// Prints: 12345678"}],"children":[]},{"kind":"method","id":"bufreaduint32leoffset","name":"readUInt32LE","title":"`buf.readUInt32LE([offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUint32LE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads an unsigned, little-endian 32-bit integer from `buf` at the specified\n`offset`.\n\nThis function is also available under the `readUint32LE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32LE(0).toString(16));\n// Prints: 78563412\nconsole.log(buf.readUInt32LE(1).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32LE(0).toString(16));\n// Prints: 78563412\nconsole.log(buf.readUInt32LE(1).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads an unsigned, little-endian 32-bit integer from `buf` at the specified `offset`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32LE(0).toString(16));\n// Prints: 78563412\nconsole.log(buf.readUInt32LE(1).toString(16));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);\n\nconsole.log(buf.readUInt32LE(0).toString(16));\n// Prints: 78563412\nconsole.log(buf.readUInt32LE(1).toString(16));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreaduintbeoffset-bytelength","name":"readUIntBE","title":"`buf.readUIntBE(offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."},{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUintBE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to read. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads `byteLength` number of bytes from `buf` at the specified `offset`\nand interprets the result as an unsigned big-endian integer supporting\nup to 48 bits of accuracy.\n\nThis function is also available under the `readUintBE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readUIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readUIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE.\n```","summary":"Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting up to 48 bits of accuracy.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readUIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntBE(0, 6).toString(16));\n// Prints: 1234567890ab\nconsole.log(buf.readUIntBE(1, 6).toString(16));\n// Throws ERR_OUT_OF_RANGE."}],"children":[]},{"kind":"method","id":"bufreaduintleoffset-bytelength","name":"readUIntLE","title":"`buf.readUIntLE(offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."},{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.readUintLE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to read. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to read. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":""}},"description":"Reads `byteLength` number of bytes from `buf` at the specified `offset`\nand interprets the result as an unsigned, little-endian integer supporting\nup to 48 bits of accuracy.\n\nThis function is also available under the `readUintLE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntLE(0, 6).toString(16));\n// Prints: ab9078563412\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntLE(0, 6).toString(16));\n// Prints: ab9078563412\n```","summary":"Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting up to 48 bits of accuracy.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntLE(0, 6).toString(16));\n// Prints: ab9078563412"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);\n\nconsole.log(buf.readUIntLE(0, 6).toString(16));\n// Prints: ab9078563412"}],"children":[]},{"kind":"method","id":"bufsubarraystart-end","name":"subarray","title":"`buf.subarray([start[, end]])`","scope":"module","overloadOf":null,"stability":null,"added":["v3.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where the new `Buffer` will start.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where the new `Buffer` will end (not inclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Returns a new `Buffer` that references the same memory as the original, but\noffset and cropped by the `start` and `end` indexes.\n\nSpecifying `end` greater than [`buf.length`](#buflength) will return the same result as\nthat of `end` equal to [`buf.length`](#buflength).\n\nThis method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).\n\nModifying the new `Buffer` slice will modify the memory in the original `Buffer`\nbecause the allocated memory of the two objects overlap.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\n// Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte\n// from the original `Buffer`.\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconst buf2 = buf1.subarray(0, 3);\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: abc\n\nbuf1[0] = 33;\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: !bc\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\n// Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte\n// from the original `Buffer`.\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconst buf2 = buf1.subarray(0, 3);\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: abc\n\nbuf1[0] = 33;\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: !bc\n```\n\nSpecifying negative indexes causes the slice to be generated relative to the\nend of `buf` rather than the beginning.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nconsole.log(buf.subarray(-6, -1).toString());\n// Prints: buffe\n// (Equivalent to buf.subarray(0, 5).)\n\nconsole.log(buf.subarray(-6, -2).toString());\n// Prints: buff\n// (Equivalent to buf.subarray(0, 4).)\n\nconsole.log(buf.subarray(-5, -2).toString());\n// Prints: uff\n// (Equivalent to buf.subarray(1, 4).)\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nconsole.log(buf.subarray(-6, -1).toString());\n// Prints: buffe\n// (Equivalent to buf.subarray(0, 5).)\n\nconsole.log(buf.subarray(-6, -2).toString());\n// Prints: buff\n// (Equivalent to buf.subarray(0, 4).)\n\nconsole.log(buf.subarray(-5, -2).toString());\n// Prints: uff\n// (Equivalent to buf.subarray(1, 4).)\n```","summary":"Returns a new `Buffer` that references the same memory as the original, but offset and cropped by the `start` and `end` indexes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\n// Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte\n// from the original `Buffer`.\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconst buf2 = buf1.subarray(0, 3);\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: abc\n\nbuf1[0] = 33;\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: !bc"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\n// Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte\n// from the original `Buffer`.\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconst buf2 = buf1.subarray(0, 3);\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: abc\n\nbuf1[0] = 33;\n\nconsole.log(buf2.toString('ascii', 0, buf2.length));\n// Prints: !bc"},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nconsole.log(buf.subarray(-6, -1).toString());\n// Prints: buffe\n// (Equivalent to buf.subarray(0, 5).)\n\nconsole.log(buf.subarray(-6, -2).toString());\n// Prints: buff\n// (Equivalent to buf.subarray(0, 4).)\n\nconsole.log(buf.subarray(-5, -2).toString());\n// Prints: uff\n// (Equivalent to buf.subarray(1, 4).)"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nconsole.log(buf.subarray(-6, -1).toString());\n// Prints: buffe\n// (Equivalent to buf.subarray(0, 5).)\n\nconsole.log(buf.subarray(-6, -2).toString());\n// Prints: buff\n// (Equivalent to buf.subarray(0, 4).)\n\nconsole.log(buf.subarray(-5, -2).toString());\n// Prints: uff\n// (Equivalent to buf.subarray(1, 4).)"}],"children":[]},{"kind":"method","id":"bufslicestart-end","name":"slice","title":"`buf.slice([start[, end]])`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated: Use [`buf.subarray`](#bufsubarraystart-end) instead."},"added":["v0.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v17.5.0","v16.15.0"],"prUrl":"https://github.com/nodejs/node/pull/41596","commit":null,"description":"The buf.slice() method has been deprecated."},{"versions":["v7.1.0","v6.9.2"],"prUrl":"https://github.com/nodejs/node/pull/9341","commit":null,"description":"Coercing the offsets to integers now handles values outside the 32-bit integer range properly."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/9101","commit":null,"description":"All offsets are now coerced to integers before doing any calculations with them."}],"signature":{"parameters":[{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where the new `Buffer` will start.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Where the new `Buffer` will end (not inclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Returns a new `Buffer` that references the same memory as the original, but\noffset and cropped by the `start` and `end` indexes.\n\nThis method is not compatible with the `Uint8Array.prototype.slice()`,\nwhich is a superclass of `Buffer`. To copy the slice, use\n`Uint8Array.prototype.slice()`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nconst copiedBuf = Uint8Array.prototype.slice.call(buf);\ncopiedBuf[0]++;\nconsole.log(copiedBuf.toString());\n// Prints: cuffer\n\nconsole.log(buf.toString());\n// Prints: buffer\n\n// With buf.slice(), the original buffer is modified.\nconst notReallyCopiedBuf = buf.slice();\nnotReallyCopiedBuf[0]++;\nconsole.log(notReallyCopiedBuf.toString());\n// Prints: cuffer\nconsole.log(buf.toString());\n// Also prints: cuffer (!)\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nconst copiedBuf = Uint8Array.prototype.slice.call(buf);\ncopiedBuf[0]++;\nconsole.log(copiedBuf.toString());\n// Prints: cuffer\n\nconsole.log(buf.toString());\n// Prints: buffer\n\n// With buf.slice(), the original buffer is modified.\nconst notReallyCopiedBuf = buf.slice();\nnotReallyCopiedBuf[0]++;\nconsole.log(notReallyCopiedBuf.toString());\n// Prints: cuffer\nconsole.log(buf.toString());\n// Also prints: cuffer (!)\n```","summary":"Returns a new `Buffer` that references the same memory as the original, but offset and cropped by the `start` and `end` indexes.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nconst copiedBuf = Uint8Array.prototype.slice.call(buf);\ncopiedBuf[0]++;\nconsole.log(copiedBuf.toString());\n// Prints: cuffer\n\nconsole.log(buf.toString());\n// Prints: buffer\n\n// With buf.slice(), the original buffer is modified.\nconst notReallyCopiedBuf = buf.slice();\nnotReallyCopiedBuf[0]++;\nconsole.log(notReallyCopiedBuf.toString());\n// Prints: cuffer\nconsole.log(buf.toString());\n// Also prints: cuffer (!)"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nconst copiedBuf = Uint8Array.prototype.slice.call(buf);\ncopiedBuf[0]++;\nconsole.log(copiedBuf.toString());\n// Prints: cuffer\n\nconsole.log(buf.toString());\n// Prints: buffer\n\n// With buf.slice(), the original buffer is modified.\nconst notReallyCopiedBuf = buf.slice();\nnotReallyCopiedBuf[0]++;\nconsole.log(notReallyCopiedBuf.toString());\n// Prints: cuffer\nconsole.log(buf.toString());\n// Also prints: cuffer (!)"}],"children":[]},{"kind":"method","id":"bufswap16","name":"swap16","title":"`buf.swap16()`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A reference to `buf`."}},"description":"Interprets `buf` as an array of unsigned 16-bit integers and swaps the\nbyte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`](errors.html#err_invalid_buffer_size) if [`buf.length`](#buflength)\nis not a multiple of 2.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap16();\n\nconsole.log(buf1);\n// Prints: <Buffer 02 01 04 03 06 05 08 07>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap16();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap16();\n\nconsole.log(buf1);\n// Prints: <Buffer 02 01 04 03 06 05 08 07>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap16();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```\n\nOne convenient use of `buf.swap16()` is to perform a fast in-place conversion\nbetween UTF-16 little-endian and UTF-16 big-endian:\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('This is little-endian UTF-16', 'utf16le');\nbuf.swap16(); // Convert to big-endian UTF-16 text.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('This is little-endian UTF-16', 'utf16le');\nbuf.swap16(); // Convert to big-endian UTF-16 text.\n```","summary":"Interprets `buf` as an array of unsigned 16-bit integers and swaps the byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap16();\n\nconsole.log(buf1);\n// Prints: <Buffer 02 01 04 03 06 05 08 07>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap16();\n// Throws ERR_INVALID_BUFFER_SIZE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap16();\n\nconsole.log(buf1);\n// Prints: <Buffer 02 01 04 03 06 05 08 07>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap16();\n// Throws ERR_INVALID_BUFFER_SIZE."},{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('This is little-endian UTF-16', 'utf16le');\nbuf.swap16(); // Convert to big-endian UTF-16 text."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('This is little-endian UTF-16', 'utf16le');\nbuf.swap16(); // Convert to big-endian UTF-16 text."}],"children":[]},{"kind":"method","id":"bufswap32","name":"swap32","title":"`buf.swap32()`","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A reference to `buf`."}},"description":"Interprets `buf` as an array of unsigned 32-bit integers and swaps the\nbyte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`](errors.html#err_invalid_buffer_size) if [`buf.length`](#buflength)\nis not a multiple of 4.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap32();\n\nconsole.log(buf1);\n// Prints: <Buffer 04 03 02 01 08 07 06 05>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap32();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap32();\n\nconsole.log(buf1);\n// Prints: <Buffer 04 03 02 01 08 07 06 05>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap32();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```","summary":"Interprets `buf` as an array of unsigned 32-bit integers and swaps the byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap32();\n\nconsole.log(buf1);\n// Prints: <Buffer 04 03 02 01 08 07 06 05>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap32();\n// Throws ERR_INVALID_BUFFER_SIZE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap32();\n\nconsole.log(buf1);\n// Prints: <Buffer 04 03 02 01 08 07 06 05>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap32();\n// Throws ERR_INVALID_BUFFER_SIZE."}],"children":[]},{"kind":"method","id":"bufswap64","name":"swap64","title":"`buf.swap64()`","scope":"module","overloadOf":null,"stability":null,"added":["v6.3.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":"A reference to `buf`."}},"description":"Interprets `buf` as an array of 64-bit numbers and swaps byte order *in-place*.\nThrows [`ERR_INVALID_BUFFER_SIZE`](errors.html#err_invalid_buffer_size) if [`buf.length`](#buflength) is not a multiple of 8.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap64();\n\nconsole.log(buf1);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap64();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap64();\n\nconsole.log(buf1);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap64();\n// Throws ERR_INVALID_BUFFER_SIZE.\n```","summary":"Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap64();\n\nconsole.log(buf1);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap64();\n// Throws ERR_INVALID_BUFFER_SIZE."},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);\n\nconsole.log(buf1);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n\nbuf1.swap64();\n\nconsole.log(buf1);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n\nconst buf2 = Buffer.from([0x1, 0x2, 0x3]);\n\nbuf2.swap64();\n// Throws ERR_INVALID_BUFFER_SIZE."}],"children":[]},{"kind":"method","id":"buftojson","name":"toJSON","title":"`buf.toJSON()`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":""}},"description":"Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls\nthis function when stringifying a `Buffer` instance.\n\n`Buffer.from()` accepts objects in the format returned from this method.\nIn particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);\nconst json = JSON.stringify(buf);\n\nconsole.log(json);\n// Prints: {\"type\":\"Buffer\",\"data\":[1,2,3,4,5]}\n\nconst copy = JSON.parse(json, (key, value) => {\n  return value && value.type === 'Buffer' ?\n    Buffer.from(value) :\n    value;\n});\n\nconsole.log(copy);\n// Prints: <Buffer 01 02 03 04 05>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);\nconst json = JSON.stringify(buf);\n\nconsole.log(json);\n// Prints: {\"type\":\"Buffer\",\"data\":[1,2,3,4,5]}\n\nconst copy = JSON.parse(json, (key, value) => {\n  return value && value.type === 'Buffer' ?\n    Buffer.from(value) :\n    value;\n});\n\nconsole.log(copy);\n// Prints: <Buffer 01 02 03 04 05>\n```","summary":"Returns a JSON representation of `buf`. `JSON.stringify()` implicitly calls this function when stringifying a `Buffer` instance.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);\nconst json = JSON.stringify(buf);\n\nconsole.log(json);\n// Prints: {\"type\":\"Buffer\",\"data\":[1,2,3,4,5]}\n\nconst copy = JSON.parse(json, (key, value) => {\n  return value && value.type === 'Buffer' ?\n    Buffer.from(value) :\n    value;\n});\n\nconsole.log(copy);\n// Prints: <Buffer 01 02 03 04 05>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);\nconst json = JSON.stringify(buf);\n\nconsole.log(json);\n// Prints: {\"type\":\"Buffer\",\"data\":[1,2,3,4,5]}\n\nconst copy = JSON.parse(json, (key, value) => {\n  return value && value.type === 'Buffer' ?\n    Buffer.from(value) :\n    value;\n});\n\nconsole.log(copy);\n// Prints: <Buffer 01 02 03 04 05>"}],"children":[]},{"kind":"method","id":"buftostringencoding-start-end","name":"toString","title":"`buf.toString([encoding[, start[, end]]])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.90"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."}],"signature":{"parameters":[{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The character encoding to use.","default":"'utf8'","optional":true,"rest":false,"properties":[]},{"name":"start","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The byte offset to start decoding at.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"end","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The byte offset to stop decoding at (not inclusive).","default":"buf.length","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Decodes `buf` to a string according to the specified character encoding in\n`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.\n\nIf `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,\nthen each invalid byte is replaced with the replacement character `U+FFFD`.\n\nThe maximum length of a string instance (in UTF-16 code units) is available\nas [`buffer.constants.MAX_STRING_LENGTH`](#bufferconstantsmax_string_length).\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconsole.log(buf1.toString('utf8'));\n// Prints: abcdefghijklmnopqrstuvwxyz\nconsole.log(buf1.toString('utf8', 0, 5));\n// Prints: abcde\n\nconst buf2 = Buffer.from('tést');\n\nconsole.log(buf2.toString('hex'));\n// Prints: 74c3a97374\nconsole.log(buf2.toString('utf8', 0, 3));\n// Prints: té\nconsole.log(buf2.toString(undefined, 0, 3));\n// Prints: té\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconsole.log(buf1.toString('utf8'));\n// Prints: abcdefghijklmnopqrstuvwxyz\nconsole.log(buf1.toString('utf8', 0, 5));\n// Prints: abcde\n\nconst buf2 = Buffer.from('tést');\n\nconsole.log(buf2.toString('hex'));\n// Prints: 74c3a97374\nconsole.log(buf2.toString('utf8', 0, 3));\n// Prints: té\nconsole.log(buf2.toString(undefined, 0, 3));\n// Prints: té\n```","summary":"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`.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconsole.log(buf1.toString('utf8'));\n// Prints: abcdefghijklmnopqrstuvwxyz\nconsole.log(buf1.toString('utf8', 0, 5));\n// Prints: abcde\n\nconst buf2 = Buffer.from('tést');\n\nconsole.log(buf2.toString('hex'));\n// Prints: 74c3a97374\nconsole.log(buf2.toString('utf8', 0, 3));\n// Prints: té\nconsole.log(buf2.toString(undefined, 0, 3));\n// Prints: té"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf1 = Buffer.allocUnsafe(26);\n\nfor (let i = 0; i < 26; i++) {\n  // 97 is the decimal ASCII value for 'a'.\n  buf1[i] = i + 97;\n}\n\nconsole.log(buf1.toString('utf8'));\n// Prints: abcdefghijklmnopqrstuvwxyz\nconsole.log(buf1.toString('utf8', 0, 5));\n// Prints: abcde\n\nconst buf2 = Buffer.from('tést');\n\nconsole.log(buf2.toString('hex'));\n// Prints: 74c3a97374\nconsole.log(buf2.toString('utf8', 0, 3));\n// Prints: té\nconsole.log(buf2.toString(undefined, 0, 3));\n// Prints: té"}],"children":[]},{"kind":"method","id":"bufvalues","name":"values","title":"`buf.values()`","scope":"module","overloadOf":null,"stability":null,"added":["v1.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":{"type":{"text":"Iterator","links":[{"name":"Iterator","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Iterator","start":0,"end":8}]},"description":""}},"description":"Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is\ncalled automatically when a `Buffer` is used in a `for..of` statement.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nfor (const value of buf.values()) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n\nfor (const value of buf) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nfor (const value of buf.values()) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n\nfor (const value of buf) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n```","summary":"Creates and returns an iterator for `buf` values (bytes). This function is called automatically when a `Buffer` is used in a `for..of` statement.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.from('buffer');\n\nfor (const value of buf.values()) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n\nfor (const value of buf) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.from('buffer');\n\nfor (const value of buf.values()) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114\n\nfor (const value of buf) {\n  console.log(value);\n}\n// Prints:\n//   98\n//   117\n//   102\n//   102\n//   101\n//   114"}],"children":[]},{"kind":"method","id":"bufwritestring-offset-length-encoding","name":"write","title":"`buf.write(string[, offset[, length]][, encoding])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.90"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v25.5.0","v24.13.1"],"prUrl":"https://github.com/nodejs/node/pull/56578","commit":null,"description":"supports Uint8Array as `this` value."}],"signature":{"parameters":[{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"String to write to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write `string`.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Maximum number of bytes to write (written bytes will not\nexceed `buf.length - offset`).","default":"buf.length - offset","optional":true,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The character encoding of `string`.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes written."}},"description":"Writes `string` to `buf` at `offset` according to the character encoding in\n`encoding`. The `length` parameter is the number of bytes to write. If `buf` did\nnot contain enough space to fit the entire string, only part of `string` will be\nwritten. However, partially encoded characters will not be written.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(256);\n\nconst len = buf.write('\\u00bd + \\u00bc = \\u00be', 0);\n\nconsole.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);\n// Prints: 12 bytes: ½ + ¼ = ¾\n\nconst buffer = Buffer.alloc(10);\n\nconst length = buffer.write('abcd', 8);\n\nconsole.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);\n// Prints: 2 bytes : ab\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(256);\n\nconst len = buf.write('\\u00bd + \\u00bc = \\u00be', 0);\n\nconsole.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);\n// Prints: 12 bytes: ½ + ¼ = ¾\n\nconst buffer = Buffer.alloc(10);\n\nconst length = buffer.write('abcd', 8);\n\nconsole.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);\n// Prints: 2 bytes : ab\n```","summary":"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 not contain enough space to fit the entire string, only part of `string` will be written. However, partially encoded characters will not be written.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.alloc(256);\n\nconst len = buf.write('\\u00bd + \\u00bc = \\u00be', 0);\n\nconsole.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);\n// Prints: 12 bytes: ½ + ¼ = ¾\n\nconst buffer = Buffer.alloc(10);\n\nconst length = buffer.write('abcd', 8);\n\nconsole.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);\n// Prints: 2 bytes : ab"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.alloc(256);\n\nconst len = buf.write('\\u00bd + \\u00bc = \\u00be', 0);\n\nconsole.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);\n// Prints: 12 bytes: ½ + ¼ = ¾\n\nconst buffer = Buffer.alloc(10);\n\nconst length = buffer.write('abcd', 8);\n\nconsole.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);\n// Prints: 2 bytes : ab"}],"children":[]},{"kind":"method","id":"bufwritebigint64bevalue-offset","name":"writeBigInt64BE","title":"`buf.writeBigInt64BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"value","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian.\n\n`value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64BE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64BE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>\n```","summary":"Writes `value` to `buf` at the specified `offset` as big-endian.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64BE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64BE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04 05 06 07 08>"}],"children":[]},{"kind":"method","id":"bufwritebigint64levalue-offset","name":"writeBigInt64LE","title":"`buf.writeBigInt64LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"value","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian.\n\n`value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64LE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64LE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>\n```","summary":"Writes `value` to `buf` at the specified `offset` as little-endian.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64LE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigInt64LE(0x0102030405060708n, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05 04 03 02 01>"}],"children":[]},{"kind":"method","id":"bufwritebiguint64bevalue-offset","name":"writeBigUInt64BE","title":"`buf.writeBigUInt64BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.10.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34960","commit":null,"description":"This function is also available as `buf.writeBigUint64BE()`."}],"signature":{"parameters":[{"name":"value","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian.\n\nThis function is also available under the `writeBigUint64BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64BE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de ca fa fe ca ce fa de>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64BE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de ca fa fe ca ce fa de>\n```","summary":"Writes `value` to `buf` at the specified `offset` as big-endian.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64BE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de ca fa fe ca ce fa de>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64BE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de ca fa fe ca ce fa de>"}],"children":[]},{"kind":"method","id":"bufwritebiguint64levalue-offset","name":"writeBigUInt64LE","title":"`buf.writeBigUInt64LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v12.0.0","v10.20.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.10.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34960","commit":null,"description":"This function is also available as `buf.writeBigUint64LE()`."}],"signature":{"parameters":[{"name":"value","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy: `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64LE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de fa ce ca fe fa ca de>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64LE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de fa ce ca fe fa ca de>\n```\n\nThis function is also available under the `writeBigUint64LE` alias.","summary":"Writes `value` to `buf` at the specified `offset` as little-endian","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64LE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de fa ce ca fe fa ca de>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeBigUInt64LE(0xdecafafecacefaden, 0);\n\nconsole.log(buf);\n// Prints: <Buffer de fa ce ca fe fa ca de>"}],"children":[]},{"kind":"method","id":"bufwritedoublebevalue-offset","name":"writeDoubleBE","title":"`buf.writeDoubleBE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian. The `value`\nmust be a JavaScript number. Behavior is undefined when `value` is anything\nother than a JavaScript number.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleBE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 40 5e dd 2f 1a 9f be 77>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleBE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 40 5e dd 2f 1a 9f be 77>\n```","summary":"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 other than a JavaScript number.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleBE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 40 5e dd 2f 1a 9f be 77>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleBE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 40 5e dd 2f 1a 9f be 77>"}],"children":[]},{"kind":"method","id":"bufwritedoublelevalue-offset","name":"writeDoubleLE","title":"`buf.writeDoubleLE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 8`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian. The `value`\nmust be a JavaScript number. Behavior is undefined when `value` is anything\nother than a JavaScript number.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleLE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleLE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>\n```","summary":"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 other than a JavaScript number.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleLE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(8);\n\nbuf.writeDoubleLE(123.456, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>"}],"children":[]},{"kind":"method","id":"bufwritefloatbevalue-offset","name":"writeFloatBE","title":"`buf.writeFloatBE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is\nundefined when `value` is anything other than a JavaScript number.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 4f 4a fe bb>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 4f 4a fe bb>\n```","summary":"Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is undefined when `value` is anything other than a JavaScript number.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 4f 4a fe bb>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatBE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 4f 4a fe bb>"}],"children":[]},{"kind":"method","id":"bufwritefloatlevalue-offset","name":"writeFloatLE","title":"`buf.writeFloatLE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is\nundefined when `value` is anything other than a JavaScript number.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer bb fe 4a 4f>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer bb fe 4a 4f>\n```","summary":"Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is undefined when `value` is anything other than a JavaScript number.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer bb fe 4a 4f>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeFloatLE(0xcafebabe, 0);\n\nconsole.log(buf);\n// Prints: <Buffer bb fe 4a 4f>"}],"children":[]},{"kind":"method","id":"bufwriteint8value-offset","name":"writeInt8","title":"`buf.writeInt8(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 1`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset`. `value` must be a valid\nsigned 8-bit integer. Behavior is undefined when `value` is anything other than\na signed 8-bit integer.\n\n`value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt8(2, 0);\nbuf.writeInt8(-2, 1);\n\nconsole.log(buf);\n// Prints: <Buffer 02 fe>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt8(2, 0);\nbuf.writeInt8(-2, 1);\n\nconsole.log(buf);\n// Prints: <Buffer 02 fe>\n```","summary":"Writes `value` to `buf` at the specified `offset`. `value` must be a valid signed 8-bit integer. Behavior is undefined when `value` is anything other than a signed 8-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt8(2, 0);\nbuf.writeInt8(-2, 1);\n\nconsole.log(buf);\n// Prints: <Buffer 02 fe>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt8(2, 0);\nbuf.writeInt8(-2, 1);\n\nconsole.log(buf);\n// Prints: <Buffer 02 fe>"}],"children":[]},{"kind":"method","id":"bufwriteint16bevalue-offset","name":"writeInt16BE","title":"`buf.writeInt16BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian.  The `value`\nmust be a valid signed 16-bit integer. Behavior is undefined when `value` is\nanything other than a signed 16-bit integer.\n\nThe `value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16BE(0x0102, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16BE(0x0102, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02>\n```","summary":"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 anything other than a signed 16-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16BE(0x0102, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16BE(0x0102, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02>"}],"children":[]},{"kind":"method","id":"bufwriteint16levalue-offset","name":"writeInt16LE","title":"`buf.writeInt16LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian.  The `value`\nmust be a valid signed 16-bit integer. Behavior is undefined when `value` is\nanything other than a signed 16-bit integer.\n\nThe `value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16LE(0x0304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 04 03>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16LE(0x0304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 04 03>\n```","summary":"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 anything other than a signed 16-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16LE(0x0304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 04 03>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(2);\n\nbuf.writeInt16LE(0x0304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 04 03>"}],"children":[]},{"kind":"method","id":"bufwriteint32bevalue-offset","name":"writeInt32BE","title":"`buf.writeInt32BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian. The `value`\nmust be a valid signed 32-bit integer. Behavior is undefined when `value` is\nanything other than a signed 32-bit integer.\n\nThe `value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32BE(0x01020304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32BE(0x01020304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04>\n```","summary":"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 anything other than a signed 32-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32BE(0x01020304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32BE(0x01020304, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 01 02 03 04>"}],"children":[]},{"kind":"method","id":"bufwriteint32levalue-offset","name":"writeInt32LE","title":"`buf.writeInt32LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian. The `value`\nmust be a valid signed 32-bit integer. Behavior is undefined when `value` is\nanything other than a signed 32-bit integer.\n\nThe `value` is interpreted and written as a two's complement signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32LE(0x05060708, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32LE(0x05060708, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05>\n```","summary":"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 anything other than a signed 32-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32LE(0x05060708, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeInt32LE(0x05060708, 0);\n\nconsole.log(buf);\n// Prints: <Buffer 08 07 06 05>"}],"children":[]},{"kind":"method","id":"bufwriteintbevalue-offset-bytelength","name":"writeIntBE","title":"`buf.writeIntBE(value, offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to write. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset`\nas big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when\n`value` is anything other than a signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>\n```","summary":"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 signed integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>"}],"children":[]},{"kind":"method","id":"bufwriteintlevalue-offset-bytelength","name":"writeIntLE","title":"`buf.writeIntLE(value, offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to write. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset`\nas little-endian. Supports up to 48 bits of accuracy. Behavior is undefined\nwhen `value` is anything other than a signed integer.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>\n```","summary":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset` as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined when `value` is anything other than a signed integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>"}],"children":[]},{"kind":"method","id":"bufwriteuint8value-offset","name":"writeUInt8","title":"`buf.writeUInt8(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUint8()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 1`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset`. `value` must be a\nvalid unsigned 8-bit integer. Behavior is undefined when `value` is anything\nother than an unsigned 8-bit integer.\n\nThis function is also available under the `writeUint8` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt8(0x3, 0);\nbuf.writeUInt8(0x4, 1);\nbuf.writeUInt8(0x23, 2);\nbuf.writeUInt8(0x42, 3);\n\nconsole.log(buf);\n// Prints: <Buffer 03 04 23 42>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt8(0x3, 0);\nbuf.writeUInt8(0x4, 1);\nbuf.writeUInt8(0x23, 2);\nbuf.writeUInt8(0x42, 3);\n\nconsole.log(buf);\n// Prints: <Buffer 03 04 23 42>\n```","summary":"Writes `value` to `buf` at the specified `offset`. `value` must be a valid unsigned 8-bit integer. Behavior is undefined when `value` is anything other than an unsigned 8-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt8(0x3, 0);\nbuf.writeUInt8(0x4, 1);\nbuf.writeUInt8(0x23, 2);\nbuf.writeUInt8(0x42, 3);\n\nconsole.log(buf);\n// Prints: <Buffer 03 04 23 42>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt8(0x3, 0);\nbuf.writeUInt8(0x4, 1);\nbuf.writeUInt8(0x23, 2);\nbuf.writeUInt8(0x42, 3);\n\nconsole.log(buf);\n// Prints: <Buffer 03 04 23 42>"}],"children":[]},{"kind":"method","id":"bufwriteuint16bevalue-offset","name":"writeUInt16BE","title":"`buf.writeUInt16BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUint16BE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian. The `value`\nmust be a valid unsigned 16-bit integer. Behavior is undefined when `value`\nis anything other than an unsigned 16-bit integer.\n\nThis function is also available under the `writeUint16BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer de ad be ef>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer de ad be ef>\n```","summary":"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 unsigned 16-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer de ad be ef>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16BE(0xdead, 0);\nbuf.writeUInt16BE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer de ad be ef>"}],"children":[]},{"kind":"method","id":"bufwriteuint16levalue-offset","name":"writeUInt16LE","title":"`buf.writeUInt16LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUint16LE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 2`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian. The `value`\nmust be a valid unsigned 16-bit integer. Behavior is undefined when `value` is\nanything other than an unsigned 16-bit integer.\n\nThis function is also available under the `writeUint16LE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer ad de ef be>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer ad de ef be>\n```","summary":"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 anything other than an unsigned 16-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer ad de ef be>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt16LE(0xdead, 0);\nbuf.writeUInt16LE(0xbeef, 2);\n\nconsole.log(buf);\n// Prints: <Buffer ad de ef be>"}],"children":[]},{"kind":"method","id":"bufwriteuint32bevalue-offset","name":"writeUInt32BE","title":"`buf.writeUInt32BE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUint32BE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as big-endian. The `value`\nmust be a valid unsigned 32-bit integer. Behavior is undefined when `value`\nis anything other than an unsigned 32-bit integer.\n\nThis function is also available under the `writeUint32BE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer fe ed fa ce>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer fe ed fa ce>\n```","summary":"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 unsigned 32-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer fe ed fa ce>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32BE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer fe ed fa ce>"}],"children":[]},{"kind":"method","id":"bufwriteuint32levalue-offset","name":"writeUInt32LE","title":"`buf.writeUInt32LE(value[, offset])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUint32LE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - 4`.","default":"0","optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `value` to `buf` at the specified `offset` as little-endian. The `value`\nmust be a valid unsigned 32-bit integer. Behavior is undefined when `value` is\nanything other than an unsigned 32-bit integer.\n\nThis function is also available under the `writeUint32LE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer ce fa ed fe>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer ce fa ed fe>\n```","summary":"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 anything other than an unsigned 32-bit integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer ce fa ed fe>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(4);\n\nbuf.writeUInt32LE(0xfeedface, 0);\n\nconsole.log(buf);\n// Prints: <Buffer ce fa ed fe>"}],"children":[]},{"kind":"method","id":"bufwriteuintbevalue-offset-bytelength","name":"writeUIntBE","title":"`buf.writeUIntBE(value, offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUintBE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to write. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset`\nas big-endian. Supports up to 48 bits of accuracy. Behavior is undefined\nwhen `value` is anything other than an unsigned integer.\n\nThis function is also available under the `writeUintBE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>\n```","summary":"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 an unsigned integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntBE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer 12 34 56 78 90 ab>"}],"children":[]},{"kind":"method","id":"bufwriteuintlevalue-offset-bytelength","name":"writeUIntLE","title":"`buf.writeUIntLE(value, offset, byteLength)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.5"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v14.9.0","v12.19.0"],"prUrl":"https://github.com/nodejs/node/pull/34729","commit":null,"description":"This function is also available as `buf.writeUintLE()`."},{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/18395","commit":null,"description":"Removed `noAssert` and no implicit coercion of the offset and `byteLength` to `uint32` anymore."}],"signature":{"parameters":[{"name":"value","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number to be written to `buf`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"offset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to skip before starting to write. Must\nsatisfy `0 <= offset <= buf.length - byteLength`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteLength","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to write. Must satisfy\n`0 < byteLength <= 6`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"`offset` plus the number of bytes written."}},"description":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset`\nas little-endian. Supports up to 48 bits of accuracy. Behavior is undefined\nwhen `value` is anything other than an unsigned integer.\n\nThis function is also available under the `writeUintLE` alias.\n\n```mjs\nimport { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>\n```\n\n```cjs\nconst { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>\n```","summary":"Writes `byteLength` bytes of `value` to `buf` at the specified `offset` as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined when `value` is anything other than an unsigned integer.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer } from 'node:buffer';\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>"},{"language":"cjs","displayName":null,"code":"const { Buffer } = require('node:buffer');\n\nconst buf = Buffer.allocUnsafe(6);\n\nbuf.writeUIntLE(0x1234567890ab, 0, 6);\n\nconsole.log(buf);\n// Prints: <Buffer ab 90 78 56 34 12>"}],"children":[]},{"kind":"constructor","id":"new-bufferarray","name":"Buffer","title":"`new Buffer(array)`","scope":"module","overloadOf":null,"stability":{"index":"0","description":"Deprecated: Use [`Buffer.from(array)`](#static-method-bufferfromarray) instead."},"added":[],"deprecated":["v6.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19524","commit":null,"description":"Calling this constructor emits a deprecation warning when run from code outside the `node_modules` directory."},{"versions":["v7.2.1"],"prUrl":"https://github.com/nodejs/node/pull/9529","commit":null,"description":"Calling this constructor no longer emits a deprecation warning."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8169","commit":null,"description":"Calling this constructor emits a deprecation warning now."}],"signature":{"parameters":[{"name":"array","type":{"text":"integer[]","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"An array of bytes to copy from.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"See [`Buffer.from(array)`](#static-method-bufferfromarray).","summary":"See `Buffer.from(array)`.","examples":[],"children":[]},{"kind":"constructor","id":"new-bufferarraybuffer-byteoffset-length","name":"Buffer","title":"`new Buffer(arrayBuffer[, byteOffset[, length]])`","scope":"module","overloadOf":"new-bufferarray","stability":{"index":"0","description":"Deprecated: Use\n[`Buffer.from(arrayBuffer[, byteOffset[, length]])`](#static-method-bufferfromarraybuffer-byteoffset-length)\ninstead."},"added":["v3.0.0"],"deprecated":["v6.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19524","commit":null,"description":"Calling this constructor emits a deprecation warning when run from code outside the `node_modules` directory."},{"versions":["v7.2.1"],"prUrl":"https://github.com/nodejs/node/pull/9529","commit":null,"description":"Calling this constructor no longer emits a deprecation warning."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8169","commit":null,"description":"Calling this constructor emits a deprecation warning now."},{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/4682","commit":null,"description":"The `byteOffset` and `length` parameters are supported now."}],"signature":{"parameters":[{"name":"arrayBuffer","type":{"text":"ArrayBuffer | SharedArrayBuffer","links":[{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":0,"end":11},{"name":"SharedArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer","start":14,"end":31}]},"description":"An {ArrayBuffer},\n{SharedArrayBuffer} or the `.buffer` property of a {TypedArray}.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"byteOffset","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Index of first byte to expose.","default":"0","optional":true,"rest":false,"properties":[]},{"name":"length","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"Number of bytes to expose.","default":"arrayBuffer.byteLength - byteOffset","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"See\n[`Buffer.from(arrayBuffer[, byteOffset[, length]])`](#static-method-bufferfromarraybuffer-byteoffset-length).","summary":"See `Buffer.from(arrayBuffer[, byteOffset[, length]])`.","examples":[],"children":[]},{"kind":"constructor","id":"new-bufferbuffer","name":"Buffer","title":"`new Buffer(buffer)`","scope":"module","overloadOf":"new-bufferarray","stability":{"index":"0","description":"Deprecated: Use [`Buffer.from(buffer)`](#static-method-bufferfrombuffer) instead."},"added":[],"deprecated":["v6.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19524","commit":null,"description":"Calling this constructor emits a deprecation warning when run from code outside the `node_modules` directory."},{"versions":["v7.2.1"],"prUrl":"https://github.com/nodejs/node/pull/9529","commit":null,"description":"Calling this constructor no longer emits a deprecation warning."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8169","commit":null,"description":"Calling this constructor emits a deprecation warning now."}],"signature":{"parameters":[{"name":"buffer","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"An existing `Buffer` or {Uint8Array} from\nwhich to copy data.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"See [`Buffer.from(buffer)`](#static-method-bufferfrombuffer).","summary":"See `Buffer.from(buffer)`.","examples":[],"children":[]},{"kind":"constructor","id":"new-buffersize","name":"Buffer","title":"`new Buffer(size)`","scope":"module","overloadOf":"new-bufferarray","stability":{"index":"0","description":"Deprecated: Use [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding) instead (also see\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment))."},"added":[],"deprecated":["v6.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19524","commit":null,"description":"Calling this constructor emits a deprecation warning when run from code outside the `node_modules` directory."},{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/12141","commit":null,"description":"The `new Buffer(size)` will return zero-filled memory by default."},{"versions":["v7.2.1"],"prUrl":"https://github.com/nodejs/node/pull/9529","commit":null,"description":"Calling this constructor no longer emits a deprecation warning."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8169","commit":null,"description":"Calling this constructor emits a deprecation warning now."}],"signature":{"parameters":[{"name":"size","type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"description":"The desired length of the new `Buffer`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"See [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding) and [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment). This variant of the\nconstructor is equivalent to [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding).","summary":"See `Buffer.alloc()` and `Buffer.allocUnsafe()`. This variant of the constructor is equivalent to `Buffer.alloc()`.","examples":[],"children":[]},{"kind":"constructor","id":"new-bufferstring-encoding","name":"Buffer","title":"`new Buffer(string[, encoding])`","scope":"module","overloadOf":"new-bufferarray","stability":{"index":"0","description":"Deprecated:\nUse [`Buffer.from(string[, encoding])`](#static-method-bufferfromstring-encoding) instead."},"added":[],"deprecated":["v6.0.0"],"removed":[],"napiVersion":[],"changes":[{"versions":["v10.0.0"],"prUrl":"https://github.com/nodejs/node/pull/19524","commit":null,"description":"Calling this constructor emits a deprecation warning when run from code outside the `node_modules` directory."},{"versions":["v7.2.1"],"prUrl":"https://github.com/nodejs/node/pull/9529","commit":null,"description":"Calling this constructor no longer emits a deprecation warning."},{"versions":["v7.0.0"],"prUrl":"https://github.com/nodejs/node/pull/8169","commit":null,"description":"Calling this constructor emits a deprecation warning now."}],"signature":{"parameters":[{"name":"string","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"String to encode.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"encoding","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The encoding of `string`.","default":"'utf8'","optional":true,"rest":false,"properties":[]}],"returns":null},"description":"See [`Buffer.from(string[, encoding])`](#static-method-bufferfromstring-encoding).","summary":"See `Buffer.from(string[, encoding])`.","examples":[],"children":[]}]},{"kind":"class","id":"class-file","name":"File","title":"Class: `File`","scope":"module","overloadOf":null,"stability":null,"added":["v19.2.0","v18.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v23.0.0"],"prUrl":"https://github.com/nodejs/node/pull/47613","commit":null,"description":"Makes File instances cloneable."},{"versions":["v20.0.0"],"prUrl":"https://github.com/nodejs/node/pull/47153","commit":null,"description":"No longer experimental."}],"extends":{"text":"Blob","links":[{"name":"Blob","href":"buffer.html#class-blob","start":0,"end":4}]},"description":"A {File} provides information about files.","summary":"A {File} provides information about files.","examples":[],"children":[{"kind":"constructor","id":"new-bufferfilesources-filename-options","name":"File","title":"`new buffer.File(sources, fileName[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v19.2.0","v18.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"sources","type":{"text":"string[] | ArrayBuffer[] | TypedArray[] | DataView[] | Blob[] | File[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":11,"end":22},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":27,"end":37},{"name":"DataView","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/DataView","start":42,"end":50},{"name":"Blob","href":"buffer.html#class-blob","start":55,"end":59},{"name":"File","href":"buffer.html#class-file","start":64,"end":68}]},"description":"An array of string, {ArrayBuffer}, {TypedArray}, {DataView}, {File}, or {Blob}\nobjects, or any mix of such objects, that will be stored within the `File`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fileName","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The name of the file.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"endings","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"One of either `'transparent'` or `'native'`. When set\nto `'native'`, line endings in string source parts will be converted to\nthe platform native line-ending as specified by `require('node:os').EOL`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"type","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The File content-type.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"lastModified","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The last modified date of the file.","default":"Date.now()","optional":true,"rest":false,"properties":[]}]}],"returns":null},"description":"","summary":"","examples":[],"children":[]},{"kind":"property","id":"filename","name":"name","title":"`file.name`","scope":"module","overloadOf":null,"stability":null,"added":["v19.2.0","v18.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The name of the `File`.","summary":"The name of the `File`.","examples":[],"children":[]},{"kind":"property","id":"filelastmodified","name":"lastModified","title":"`file.lastModified`","scope":"module","overloadOf":null,"stability":null,"added":["v19.2.0","v18.13.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The last modified date of the `File`.","summary":"The last modified date of the `File`.","examples":[],"children":[]}]},{"kind":"section","id":"nodebuffer-module-apis","name":"node:buffer module APIs","title":"`node:buffer` module APIs","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"While, the `Buffer` object is available as a global, there are additional\n`Buffer`-related APIs that are available only via the `node:buffer` module\naccessed using `require('node:buffer')`.","summary":"While, the `Buffer` object is available as a global, there are additional `Buffer`-related APIs that are available only via the `node:buffer` module accessed using `require('node:buffer')`.","examples":[],"children":[{"kind":"method","id":"bufferatobdata","name":"atob","title":"`buffer.atob(data)`","scope":"module","overloadOf":null,"stability":{"index":"3","description":"Legacy. Use `Buffer.from(data, 'base64')` instead."},"added":["v15.13.0","v14.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"The Base64-encoded input string.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Decodes a string of Base64-encoded data into bytes, and encodes those bytes\ninto a string using Latin-1 (ISO-8859-1).\n\nThe `data` may be any JavaScript-value that can be coerced into a string.\n\n**This function is only provided for compatibility with legacy web platform APIs\nand should never be used in new code, because they use strings to represent\nbinary data and predate the introduction of typed arrays in JavaScript.\nFor code running using Node.js APIs, converting between base64-encoded strings\nand binary data should be performed using `Buffer.from(str, 'base64')` and\n`buf.toString('base64')`.**\n\nAn automated migration is available ([source](https://github.com/nodejs/userland-migrations/tree/main/recipes/buffer-atob-btoa):\n\n```bash\nnpx codemod@latest @nodejs/buffer-atob-btoa\n```","summary":"Decodes a string of Base64-encoded data into bytes, and encodes those bytes into a string using Latin-1 (ISO-8859-1).","examples":[{"language":"bash","displayName":null,"code":"npx codemod@latest @nodejs/buffer-atob-btoa"}],"children":[]},{"kind":"method","id":"bufferbtoadata","name":"btoa","title":"`buffer.btoa(data)`","scope":"module","overloadOf":null,"stability":{"index":"3","description":"Legacy. Use `buf.toString('base64')` instead."},"added":["v15.13.0","v14.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"data","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"An ASCII (Latin1) string.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes\ninto a string using Base64.\n\nThe `data` may be any JavaScript-value that can be coerced into a string.\n\n**This function is only provided for compatibility with legacy web platform APIs\nand should never be used in new code, because they use strings to represent\nbinary data and predate the introduction of typed arrays in JavaScript.\nFor code running using Node.js APIs, converting between base64-encoded strings\nand binary data should be performed using `Buffer.from(str, 'base64')` and\n`buf.toString('base64')`.**\n\nAn automated migration is available ([source](https://github.com/nodejs/userland-migrations/tree/main/recipes/buffer-atob-btoa):\n\n```bash\nnpx codemod@latest @nodejs/buffer-atob-btoa\n```","summary":"Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes into a string using Base64.","examples":[{"language":"bash","displayName":null,"code":"npx codemod@latest @nodejs/buffer-atob-btoa"}],"children":[]},{"kind":"method","id":"bufferisasciiinput","name":"isAscii","title":"`buffer.isAscii(input)`","scope":"module","overloadOf":null,"stability":null,"added":["v19.6.0","v18.15.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/64504","commit":null,"description":"Detached `ArrayBuffer`s and views backed by them are treated as empty."}],"signature":{"parameters":[{"name":"input","type":{"text":"Buffer | ArrayBuffer | TypedArray","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33}]},"description":"The input to validate.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"This function returns `true` if `input` contains only valid ASCII-encoded data,\nincluding the case in which `input` is empty.\n\nA detached `ArrayBuffer`, or a `TypedArray` backed by one, is treated as empty.","summary":"This function returns `true` if `input` contains only valid ASCII-encoded data, including the case in which `input` is empty.","examples":[],"children":[]},{"kind":"method","id":"bufferisutf8input","name":"isUtf8","title":"`buffer.isUtf8(input)`","scope":"module","overloadOf":null,"stability":null,"added":["v19.4.0","v18.14.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v26.8.0"],"prUrl":"https://github.com/nodejs/node/pull/64504","commit":null,"description":"Detached `ArrayBuffer`s and views backed by them are treated as empty."}],"signature":{"parameters":[{"name":"input","type":{"text":"Buffer | ArrayBuffer | TypedArray","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"ArrayBuffer","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer","start":9,"end":20},{"name":"TypedArray","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray","start":23,"end":33}]},"description":"The input to validate.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"This function returns `true` if `input` contains only valid UTF-8-encoded data,\nincluding the case in which `input` is empty.\n\nA detached `ArrayBuffer`, or a `TypedArray` backed by one, is treated as empty.","summary":"This function returns `true` if `input` contains only valid UTF-8-encoded data, including the case in which `input` is empty.","examples":[],"children":[]},{"kind":"property","id":"bufferinspect_max_bytes","name":"INSPECT_MAX_BYTES","title":"`buffer.INSPECT_MAX_BYTES`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.4"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":"50","description":"Returns the maximum number of bytes that will be returned when\n`buf.inspect()` is called. This can be overridden by user modules. See\n[`util.inspect()`](util.html#utilinspectobject-options) for more details on `buf.inspect()` behavior.","summary":"Returns the maximum number of bytes that will be returned when `buf.inspect()` is called. This can be overridden by user modules. See `util.inspect()` for more details on `buf.inspect()` behavior.","examples":[],"children":[]},{"kind":"property","id":"bufferkmaxlength","name":"kMaxLength","title":"`buffer.kMaxLength`","scope":"module","overloadOf":null,"stability":null,"added":["v3.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The largest size allowed for a single `Buffer` instance.\n\nAn alias for [`buffer.constants.MAX_LENGTH`](#bufferconstantsmax_length).","summary":"An alias for `buffer.constants.MAX_LENGTH`.","examples":[],"children":[]},{"kind":"property","id":"bufferkstringmaxlength","name":"kStringMaxLength","title":"`buffer.kStringMaxLength`","scope":"module","overloadOf":null,"stability":null,"added":["v3.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The largest length allowed for a single `string` instance.\n\nAn alias for [`buffer.constants.MAX_STRING_LENGTH`](#bufferconstantsmax_string_length).","summary":"An alias for `buffer.constants.MAX_STRING_LENGTH`.","examples":[],"children":[]},{"kind":"method","id":"bufferresolveobjecturlid","name":"resolveObjectURL","title":"`buffer.resolveObjectURL(id)`","scope":"module","overloadOf":null,"stability":null,"added":["v16.7.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.0.0","v22.17.0"],"prUrl":"https://github.com/nodejs/node/pull/57513","commit":null,"description":"Marking the API stable."}],"signature":{"parameters":[{"name":"id","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"A `'blob:nodedata:...` URL string returned by a prior call to\n`URL.createObjectURL()`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Blob","links":[{"name":"Blob","href":"buffer.html#class-blob","start":0,"end":4}]},"description":""}},"description":"Resolves a `'blob:nodedata:...'` an associated {Blob} object registered using\na prior call to `URL.createObjectURL()`.","summary":"Resolves a `'blob:nodedata:...'` an associated {Blob} object registered using a prior call to `URL.createObjectURL()`.","examples":[],"children":[]},{"kind":"method","id":"buffertranscodesource-fromenc-toenc","name":"transcode","title":"`buffer.transcode(source, fromEnc, toEnc)`","scope":"module","overloadOf":null,"stability":null,"added":["v7.1.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v8.0.0"],"prUrl":"https://github.com/nodejs/node/pull/10236","commit":null,"description":"The `source` parameter can now be a `Uint8Array`."}],"signature":{"parameters":[{"name":"source","type":{"text":"Buffer | Uint8Array","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6},{"name":"Uint8Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array","start":9,"end":19}]},"description":"A `Buffer` or `Uint8Array` instance.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"fromEnc","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The current encoding.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"toEnc","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"To target encoding.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Buffer","links":[{"name":"Buffer","href":"buffer.html#class-buffer","start":0,"end":6}]},"description":""}},"description":"Re-encodes the given `Buffer` or `Uint8Array` instance from one character\nencoding to another. Returns a new `Buffer` instance.\n\nThrows if the `fromEnc` or `toEnc` specify invalid character encodings or if\nconversion from `fromEnc` to `toEnc` is not permitted.\n\nEncodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`,\n`'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.\n\nThe transcoding process will use substitution characters if a given byte\nsequence cannot be adequately represented in the target encoding. For instance:\n\n```mjs\nimport { Buffer, transcode } from 'node:buffer';\n\nconst newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');\nconsole.log(newBuf.toString('ascii'));\n// Prints: '?'\n```\n\n```cjs\nconst { Buffer, transcode } = require('node:buffer');\n\nconst newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');\nconsole.log(newBuf.toString('ascii'));\n// Prints: '?'\n```\n\nBecause the Euro (`€`) sign is not representable in US-ASCII, it is replaced\nwith `?` in the transcoded `Buffer`.","summary":"Re-encodes the given `Buffer` or `Uint8Array` instance from one character encoding to another. Returns a new `Buffer` instance.","examples":[{"language":"mjs","displayName":null,"code":"import { Buffer, transcode } from 'node:buffer';\n\nconst newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');\nconsole.log(newBuf.toString('ascii'));\n// Prints: '?'"},{"language":"cjs","displayName":null,"code":"const { Buffer, transcode } = require('node:buffer');\n\nconst newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');\nconsole.log(newBuf.toString('ascii'));\n// Prints: '?'"}],"children":[]},{"kind":"section","id":"buffer-constants","name":"Buffer constants","title":"Buffer constants","scope":"module","overloadOf":null,"stability":null,"added":["v8.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"","summary":"","examples":[],"children":[{"kind":"property","id":"bufferconstantsmax_length","name":"MAX_LENGTH","title":"`buffer.constants.MAX_LENGTH`","scope":"module","overloadOf":null,"stability":null,"added":["v8.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v22.0.0"],"prUrl":"https://github.com/nodejs/node/pull/52465","commit":null,"description":"Value is changed to 2<sup>53</sup> - 1 on 64-bit architectures, and 2<sup>31</sup> - 1 on 32-bit architectures."},{"versions":["v15.0.0"],"prUrl":"https://github.com/nodejs/node/pull/35415","commit":null,"description":"Value is changed to 2<sup>32</sup> on 64-bit architectures."},{"versions":["v14.0.0"],"prUrl":"https://github.com/nodejs/node/pull/32116","commit":null,"description":"Value is changed from 2<sup>31</sup> - 1 to 2<sup>32</sup> - 1 on 64-bit architectures."}],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The largest size allowed for a single `Buffer` instance.\n\nOn 32-bit architectures, this value is equal to 2<sup>31</sup> - 1 (about 2\nGiB).\n\nOn 64-bit architectures, this value is equal to [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\n(2<sup>53</sup> - 1, about 8 PiB).\n\nIt reflects [`v8::Uint8Array::kMaxLength`](https://v8.github.io/api/head/classv8_1_1Uint8Array.html#a7677e3d0c9c92e4d40bef7212f5980c6) under the hood.\n\nThis value is also available as [`buffer.kMaxLength`](#bufferkmaxlength).","summary":"On 32-bit architectures, this value is equal to 2<sup>31</sup> - 1 (about 2 GiB).","examples":[],"children":[]},{"kind":"property","id":"bufferconstantsmax_string_length","name":"MAX_STRING_LENGTH","title":"`buffer.constants.MAX_STRING_LENGTH`","scope":"module","overloadOf":null,"stability":null,"added":["v8.2.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"integer","links":[{"name":"integer","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":7}]},"default":null,"description":"The largest length allowed for a single `string` instance.\n\nRepresents the largest `length` that a `string` primitive can have, counted\nin UTF-16 code units.\n\nThis value may depend on the JS engine that is being used.","summary":"Represents the largest `length` that a `string` primitive can have, counted in UTF-16 code units.","examples":[],"children":[]}]}]},{"kind":"section","id":"bufferfrom-bufferalloc-and-bufferallocunsafe","name":"Buffer.from(), Buffer.alloc(), and Buffer.allocUnsafe()","title":"`Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"In versions of Node.js prior to 6.0.0, `Buffer` instances were created using the\n`Buffer` constructor function, which allocates the returned `Buffer`\ndifferently based on what arguments are provided:\n\n* Passing a number as the first argument to `Buffer()` (e.g. `new Buffer(10)`)\n  allocates a new `Buffer` object of the specified size. Prior to Node.js 8.0.0,\n  the memory allocated for such `Buffer` instances is *not* initialized and\n  *can contain sensitive data*. Such `Buffer` instances *must* be subsequently\n  initialized by using either [`buf.fill(0)`](#buffillvalue-offset-end-encoding) or by writing to the\n  entire `Buffer` before reading data from the `Buffer`.\n  While this behavior is *intentional* to improve performance,\n  development experience has demonstrated that a more explicit distinction is\n  required between creating a fast-but-uninitialized `Buffer` versus creating a\n  slower-but-safer `Buffer`. Since Node.js 8.0.0, `Buffer(num)` and `new\n  Buffer(num)` return a `Buffer` with initialized memory.\n* Passing a string, array, or `Buffer` as the first argument copies the\n  passed object's data into the `Buffer`.\n* Passing an {ArrayBuffer} or a {SharedArrayBuffer} returns a `Buffer`\n  that shares allocated memory with the given array buffer.\n\nBecause the behavior of `new Buffer()` is different depending on the type of the\nfirst argument, security and reliability issues can be inadvertently introduced\ninto applications when argument validation or `Buffer` initialization is not\nperformed.\n\nFor example, if an attacker can cause an application to receive a number where\na string is expected, the application may call `new Buffer(100)`\ninstead of `new Buffer(\"100\")`, leading it to allocate a 100 byte buffer instead\nof allocating a 3 byte buffer with content `\"100\"`. This is commonly possible\nusing JSON API calls. Since JSON distinguishes between numeric and string types,\nit allows injection of numbers where a naively written application that does not\nvalidate its input sufficiently might expect to always receive a string.\nBefore Node.js 8.0.0, the 100 byte buffer might contain\narbitrary pre-existing in-memory data, so may be used to expose in-memory\nsecrets to a remote attacker. Since Node.js 8.0.0, exposure of memory cannot\noccur because the data is zero-filled. However, other attacks are still\npossible, such as causing very large buffers to be allocated by the server,\nleading to performance degradation or crashing on memory exhaustion.\n\nTo make the creation of `Buffer` instances more reliable and less error-prone,\nthe various forms of the `new Buffer()` constructor have been **deprecated**\nand replaced by separate `Buffer.from()`, [`Buffer.alloc()`](#static-method-bufferallocsize-fill-encoding), and\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) methods.\n\n*Developers should migrate all existing uses of the `new Buffer()` constructors\nto one of these new APIs.*\n\n* [`Buffer.from(array)`](#static-method-bufferfromarray) returns a new `Buffer` that *contains a copy* of the\n  provided octets.\n* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`](#static-method-bufferfromarraybuffer-byteoffset-length)\n  returns a new `Buffer` that *shares the same allocated memory* as the given\n  {ArrayBuffer}.\n* [`Buffer.from(buffer)`](#static-method-bufferfrombuffer) returns a new `Buffer` that *contains a copy* of the\n  contents of the given `Buffer`.\n* [`Buffer.from(string[, encoding])`](#static-method-bufferfromstring-encoding) returns a new\n  `Buffer` that *contains a copy* of the provided string.\n* [`Buffer.alloc(size[, fill[, encoding]])`](#static-method-bufferallocsize-fill-encoding) returns a new\n  initialized `Buffer` of the specified size. This method is slower than\n  [`Buffer.allocUnsafe(size)`](#static-method-bufferallocunsafesize-alignment) but guarantees that newly\n  created `Buffer` instances never contain old data that is potentially\n  sensitive. A `TypeError` will be thrown if `size` is not a number.\n* [`Buffer.allocUnsafe(size)`](#static-method-bufferallocunsafesize-alignment) and\n  [`Buffer.allocUnsafeSlow(size)`](#static-method-bufferallocunsafeslowsize-alignment) each return a\n  new uninitialized `Buffer` of the specified `size`. Because the `Buffer` is\n  uninitialized, the allocated segment of memory might contain old data that is\n  potentially sensitive.\n\n`Buffer` instances returned by [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment), [`Buffer.from(string)`](#static-method-bufferfromstring-encoding),\n[`Buffer.concat()`](#static-method-bufferconcatlist-totallength) and [`Buffer.from(array)`](#static-method-bufferfromarray) *may* be allocated off a shared\ninternal memory pool if `size` is less than or equal to half [`Buffer.poolSize`](#bufferpoolsize).\nInstances returned by [`Buffer.allocUnsafeSlow()`](#static-method-bufferallocunsafeslowsize-alignment) *never* use the shared internal\nmemory pool.","summary":"In versions of Node.js prior to 6.0.0, `Buffer` instances were created using the `Buffer` constructor function, which allocates the returned `Buffer` differently based on what arguments are provided:","examples":[],"children":[{"kind":"section","id":"-zero-fill-buffers-command-line-option","name":"The --zero-fill-buffers command-line option","title":"The `--zero-fill-buffers` command-line option","scope":"module","overloadOf":null,"stability":null,"added":["v5.10.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Node.js can be started using the `--zero-fill-buffers` command-line option to\ncause all newly-allocated `Buffer` instances to be zero-filled upon creation by\ndefault. Without the option, buffers created with [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) and\n[`Buffer.allocUnsafeSlow()`](#static-method-bufferallocunsafeslowsize-alignment) are not zero-filled. Use of this flag can have a\nmeasurable negative impact on performance. Use the `--zero-fill-buffers` option\nonly when necessary to enforce that newly allocated `Buffer` instances cannot\ncontain old data that is potentially sensitive.\n\n```console\n$ node --zero-fill-buffers\n> Buffer.allocUnsafe(5);\n<Buffer 00 00 00 00 00>\n```","summary":"Node.js can be started using the `--zero-fill-buffers` command-line option to cause all newly-allocated `Buffer` instances to be zero-filled upon creation by default. Without the option, buffers created with `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()` are not zero-filled. Use of this flag can have a measurable negative impact on performance. Use the `--zero-fill-buffers` option only when necessary to enforce that newly allocated `Buffer` instances cannot contain old data that is potentially sensitive.","examples":[{"language":"console","displayName":null,"code":"$ node --zero-fill-buffers\n> Buffer.allocUnsafe(5);\n<Buffer 00 00 00 00 00>"}],"children":[]},{"kind":"section","id":"what-makes-bufferallocunsafe-and-bufferallocunsafeslow-unsafe","name":"What makes Buffer.allocUnsafe() and Buffer.allocUnsafeSlow() \"unsafe\"?","title":"What makes `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()` \"unsafe\"?","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"When calling [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) and [`Buffer.allocUnsafeSlow()`](#static-method-bufferallocunsafeslowsize-alignment), the\nsegment of allocated memory is *uninitialized* (it is not zeroed-out). While\nthis design makes the allocation of memory quite fast, the allocated segment of\nmemory might contain old data that is potentially sensitive. Using a `Buffer`\ncreated by [`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) without *completely* overwriting the\nmemory can allow this old data to be leaked when the `Buffer` memory is read.\n\nWhile there are clear performance advantages to using\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment), extra care *must* be taken in order to avoid\nintroducing security vulnerabilities into an application.","summary":"When calling `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()`, the segment of allocated memory is _uninitialized_ (it is not zeroed-out). While this design makes the allocation of memory quite fast, the allocated segment of memory might contain old data that is potentially sensitive. Using a `Buffer` created by `Buffer.allocUnsafe()` without _completely_ overwriting the memory can allow this old data to be leaked when the `Buffer` memory is read.","examples":[],"children":[]},{"kind":"section","id":"aligned-allocations","name":"Aligned allocations","title":"Aligned allocations","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Some operating system interfaces require the memory they operate on to be\naligned, and on some hardware alignment is merely faster. The most common\nexample of the former is unbuffered (\"direct\") file I/O, which on Linux requires\nthe buffer address, the file offset and the transfer length to all be multiples\nof the logical block size of the underlying device:\n\n```mjs\nimport { open } from 'node:fs/promises';\nimport { constants } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst blockSize = 4096;\n\n// The buffer address must be block-aligned for O_DIRECT to accept it.\nconst buf = Buffer.allocUnsafeSlow(blockSize, blockSize);\n\nconst file = await open('/dev/sda', constants.O_RDONLY | constants.O_DIRECT);\ntry {\n  await file.read(buf, 0, blockSize, 0);\n} finally {\n  await file.close();\n}\n```\n\n```cjs\nconst fs = require('node:fs');\nconst { Buffer } = require('node:buffer');\n\nconst blockSize = 4096;\n\n// The buffer address must be block-aligned for O_DIRECT to accept it.\nconst buf = Buffer.allocUnsafeSlow(blockSize, blockSize);\n\nconst flags = fs.constants.O_RDONLY | fs.constants.O_DIRECT;\nfs.open('/dev/sda', flags, (err, fd) => {\n  if (err) throw err;\n  fs.read(fd, buf, 0, blockSize, 0, (err) => {\n    fs.close(fd, () => {});\n    if (err) throw err;\n  });\n});\n```\n\nAlignment can also be worth requesting purely for performance, even when no\ninterface demands it. Aligning a hot `Buffer` to the cache line size (64 bytes on\nmost contemporary CPUs) keeps it from straddling one more cache line than it\nneeds to, so that a small structure is fetched with one cache miss instead of\ntwo, and page-aligned (4096 bytes) allocations similarly help interfaces that map\nor pin memory. These are micro-optimizations: measure before reaching for them,\nsince the extra bytes are not free.\n\nBecause the address of a `Buffer`'s memory cannot be chosen directly, extra bytes\nhave to be allocated or skipped to reach an aligned address.\n[`Buffer.allocUnsafeSlow()`](#static-method-bufferallocunsafeslowsize-alignment) over-allocates up to `alignment - 1` bytes and\npositions the returned `Buffer` at the first suitably aligned byte within them.\n[`Buffer.allocUnsafe()`](#static-method-bufferallocunsafesize-alignment) instead pads its offset into the shared internal pool,\nwhose start is always aligned to 64 bytes, and only falls back to an allocation\nof its own when `alignment` is larger than that. Either way,\n[`buf.byteOffset`](#bufbyteoffset) is usually not 0 and [`buf.buffer`](#bufbuffer) is larger than `size`,\nso code that reaches past the `Buffer` into its underlying `ArrayBuffer` must\ntake the offset into account, as it must for pooled `Buffer`s.\n\nThe alignment is a property of the returned `Buffer` and is preserved for its\nwhole lifetime, but it is not inherited by other views: [`buf.subarray`](#bufsubarraystart-end),\n[`buf.slice()`](#bufslicestart-end) and `structuredClone()` may all produce unaligned `Buffer`s.\n\nAlignment also does not survive being captured in a startup snapshot: memory does\nnot keep its address across serialization, so a `Buffer` allocated while\n[`--build-snapshot`](cli.html#--build-snapshot) is in effect is not aligned in the deserialized process.\nAllocate inside a [`v8.startupSnapshot.setDeserializeMainFunction()`](v8.html#v8startupsnapshotsetdeserializemainfunctioncallback-data) callback,\nor after startup, if the alignment has to hold at run time.","summary":"Some operating system interfaces require the memory they operate on to be aligned, and on some hardware alignment is merely faster. The most common example of the former is unbuffered (\"direct\") file I/O, which on Linux requires the buffer address, the file offset and the transfer length to all be multiples of the logical block size of the underlying device:","examples":[{"language":"mjs","displayName":null,"code":"import { open } from 'node:fs/promises';\nimport { constants } from 'node:fs';\nimport { Buffer } from 'node:buffer';\n\nconst blockSize = 4096;\n\n// The buffer address must be block-aligned for O_DIRECT to accept it.\nconst buf = Buffer.allocUnsafeSlow(blockSize, blockSize);\n\nconst file = await open('/dev/sda', constants.O_RDONLY | constants.O_DIRECT);\ntry {\n  await file.read(buf, 0, blockSize, 0);\n} finally {\n  await file.close();\n}"},{"language":"cjs","displayName":null,"code":"const fs = require('node:fs');\nconst { Buffer } = require('node:buffer');\n\nconst blockSize = 4096;\n\n// The buffer address must be block-aligned for O_DIRECT to accept it.\nconst buf = Buffer.allocUnsafeSlow(blockSize, blockSize);\n\nconst flags = fs.constants.O_RDONLY | fs.constants.O_DIRECT;\nfs.open('/dev/sda', flags, (err, fd) => {\n  if (err) throw err;\n  fs.read(fd, buf, 0, blockSize, 0, (err) => {\n    fs.close(fd, () => {});\n    if (err) throw err;\n  });\n});"}],"children":[]}]}]}