Node.js Buffer — a fixed-length sequence of bytes extending Uint8Array.
Supports a wide range of encodings and binary read/write operations.
🟢 alloc(size, fill, encoding)
Allocates a zero-filled Buffer of the given size. Optionally pre-filled with a value.
🟢 allocUnsafe(size)
Allocates an uninitialized Buffer. Faster than alloc() but may contain old data.
🟢 allocUnsafeSlow(size)
Like allocUnsafe but always uses the C malloc path (bypasses pool).
🟢 from(input, encodingOrOffset, length)
Creates a Buffer from a string, array, ArrayBuffer, or another Buffer.
🟢 isBuffer(obj)
Returns true if the given object is a Buffer instance.
🟢 isEncoding(encoding)
Returns true if the given encoding name is supported.
🟢 byteLength(string, encoding)
Returns the byte length of a string when encoded with the given encoding.
🟢 concat(list, totalLength)
Concatenates a list of Buffers into a single Buffer.
🟢 compare(buf1, buf2)
Compares two Buffers lexicographically (for sorting).
🟢 compare(target, targetStart, targetEnd, sourceStart, sourceEnd)
Compares two Buffers lexicographically (for sorting).
🟢 copy(target, targetStart, sourceStart, sourceEnd)
Copies bytes from this Buffer into target.
🟢 equals(otherBuffer)
Returns true if this Buffer has the same bytes as otherBuffer.
🟢 fill(value, offset, end, encoding)
Allocates a zero-filled Buffer of the given size. Optionally pre-filled with a value.
🟢 includes(value, byteOffset, encoding)
Returns true if value is found anywhere in the Buffer.
🟢 indexOf(value, byteOffset, encoding)
Returns the index of the first occurrence of value, or -1 if not found.
🟢 lastIndexOf(value, byteOffset, encoding)
Returns the index of the last occurrence of value, or -1 if not found.
🟢 slice(start, end)
Returns a new Buffer referencing the same memory over a sub-range.
🟢 subarray(start, end)
Returns a new Buffer that references the same memory over a sub-range.
🟢 write(string, offset, length, encoding)
Writes a string to the Buffer at the given offset using the specified encoding.
🟢 toString(encoding, start, end)
Decodes the Buffer to a string using the given encoding.
🟢 toJSON()
Returns a JSON representation of the Buffer as `{ type: 'Buffer', data: [...] }`.
🟢 readUInt8(offset)
Reads an unsigned 8-bit integer at the given offset.
🟢 readUInt16BE(offset)
Reads an unsigned 16-bit big-endian integer at the given offset.
🟢 readUInt16LE(offset)
Reads an unsigned 16-bit little-endian integer at the given offset.
🟢 readUInt32BE(offset)
Reads an unsigned 32-bit big-endian integer at the given offset.
🟢 readUInt32LE(offset)
Reads an unsigned 32-bit little-endian integer at the given offset.
🟢 readInt8(offset)
Reads a signed 8-bit integer at the given offset.
🟢 readInt16BE(offset)
Reads a signed 16-bit big-endian integer at the given offset.
🟢 readInt16LE(offset)
Reads a signed 16-bit little-endian integer at the given offset.
🟢 readInt32BE(offset)
Reads a signed 32-bit big-endian integer at the given offset.
🟢 readInt32LE(offset)
Reads a signed 32-bit little-endian integer at the given offset.
🟢 readFloatBE(offset)
Reads a 32-bit big-endian float at the given offset.
🟢 readFloatLE(offset)
Reads a 32-bit little-endian float at the given offset.
🟢 readDoubleBE(offset)
Reads a 64-bit big-endian double at the given offset.
🟢 readDoubleLE(offset)
Reads a 64-bit little-endian double at the given offset.
🟢 writeUInt8(value, offset)
Writes an unsigned 8-bit integer at the given offset.
🟢 writeUInt16BE(value, offset)
Writes an unsigned 16-bit big-endian integer at the given offset.
🟢 writeUInt16LE(value, offset)
Writes an unsigned 16-bit little-endian integer at the given offset.
🟢 writeUInt32BE(value, offset)
Writes an unsigned 32-bit big-endian integer at the given offset.
🟢 writeUInt32LE(value, offset)
Writes an unsigned 32-bit little-endian integer at the given offset.
🟢 writeInt8(value, offset)
Writes a signed 8-bit integer at the given offset.
🟢 writeInt16BE(value, offset)
Writes a signed 16-bit big-endian integer at the given offset.
🟢 writeInt16LE(value, offset)
Writes a signed 16-bit little-endian integer at the given offset.
🟢 writeInt32BE(value, offset)
Writes a signed 32-bit big-endian integer at the given offset.
🟢 writeInt32LE(value, offset)
Writes a signed 32-bit little-endian integer at the given offset.
🟢 writeFloatBE(value, offset)
Writes a 32-bit big-endian float at the given offset.
🟢 writeFloatLE(value, offset)
Writes a 32-bit little-endian float at the given offset.
🟢 writeDoubleBE(value, offset)
Writes a 64-bit big-endian double at the given offset.
🟢 writeDoubleLE(value, offset)
Writes a 64-bit little-endian double at the given offset.
🟢 swap16()
Interprets the Buffer as an array of unsigned 16-bit integers and swaps byte order in-place.
🟢 swap32()
Interprets the Buffer as an array of unsigned 32-bit integers and swaps byte order in-place.
🟢 swap64()
Interprets the Buffer as an array of unsigned 64-bit integers and swaps byte order in-place.
Interprets the Buffer as an array of unsigned 16-bit integers and swaps byte order in-place.
Interprets the Buffer as an array of unsigned 32-bit integers and swaps byte order in-place.
Interprets the Buffer as an array of unsigned 64-bit integers and swaps byte order in-place.