buffer.swap16()

buf.swap16() Return: <Buffer> Interprets the Buffer as an array of unsigned 16-bit integers and swaps the byte-order in-place. Throws a RangeError if the Buffer length is not a multiple of 16 bits. The method returns a reference to the Buffer, so calls can be chained. const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); console.log(buf); // Prints Buffer(0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8) buf.swap16(); console.log(buf); // Prints Buffer(0x2, 0x1, 0x4, 0x3, 0x6,

buffer.slice()

buf.slice([start[, end]]) start <Number> Default: 0 end <Number> Default: buffer.length Return: <Buffer> Returns a new Buffer that references the same memory as the original, but offset and cropped by the start and end indices. Note that modifying the new Buffer slice will modify the memory in the original Buffer because the allocated memory of the two objects overlap. Example: build a Buffer with the ASCII alphabet, take a slice, then modify one byte from the original

buffer.readUIntLE()

buf.readUIntLE(offset, byteLength[, noAssert]) offset <Number> 0 <= offset <= buf.length - byteLength byteLength <Number> 0 < byteLength <= 6 noAssert <Boolean> Default: false Return: <Number> Reads byteLength number of bytes from the Buffer at the specified offset and interprets the result as an unsigned integer. Supports up to 48 bits of accuracy. For example: const buf = Buffer.allocUnsafe(6); buf.writeUInt16LE(0x90ab, 0); buf.writeUInt32LE(0x1234

buffer.readUIntBE()

buf.readUIntBE(offset, byteLength[, noAssert])

buffer.readUInt8()

buf.readUInt8(offset[, noAssert]) offset <Number> 0 <= offset <= buf.length - 1 noAssert <Boolean> Default: false Return: <Number> Reads an unsigned 8-bit integer from the Buffer at the specified offset. Setting noAssert to true skips validation of the offset. This allows the offset to be beyond the end of the Buffer. const buf = Buffer.from([1,-2,3,4]); buf.readUInt8(0); // returns 1 buf.readUInt8(1); // returns 254

buffer.readUInt32LE()

buf.readUInt32LE(offset[, noAssert]) offset <Number> 0 <= offset <= buf.length - 4 noAssert <Boolean> Default: false Return: <Number> Reads an unsigned 32-bit integer from the Buffer at the specified offset with specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian). Setting noAssert to true skips validation of the offset. This allows the offset to be beyond the end of the Buffer. Example: const buf = Buffer.from([0x3, 0x

buffer.readUInt32BE()

buf.readUInt32BE(offset[, noAssert])

buffer.readUInt16LE()

buf.readUInt16LE(offset[, noAssert]) offset <Number> 0 <= offset <= buf.length - 2 noAssert <Boolean> Default: false Return: <Number> Reads an unsigned 16-bit integer from the Buffer at the specified offset with specified endian format (readInt32BE() returns big endian, readInt32LE() returns little endian). Setting noAssert to true skips validation of the offset. This allows the offset to be beyond the end of the Buffer. Example: const buf = Buffer.from([0x3, 0x

buffer.readUInt16BE()

buf.readUInt16BE(offset[, noAssert])

buffer.readIntLE()

buf.readIntLE(offset, byteLength[, noAssert]) offset <Number> 0 <= offset <= buf.length - byteLength byteLength <Number> 0 < byteLength <= 6 noAssert <Boolean> Default: false Return: <Number> Reads byteLength number of bytes from the Buffer at the specified offset and interprets the result as a two's complement signed value. Supports up to 48 bits of accuracy. For example: const buf = Buffer.allocUnsafe(6); buf.writeUInt16LE(0x90ab, 0); buf.writeUInt