buffer.writeInt16BE()

buf.writeInt16BE(value, offset[, noAssert])

buffer.writeFloatLE()

buf.writeFloatLE(value, offset[, noAssert]) value <Number> Bytes to be written to Buffer offset <Number> 0 <= offset <= buf.length - 4 noAssert <Boolean> Default: false Return: <Number> The offset plus the number of written bytes Writes value to the Buffer at the specified offset with specified endian format (writeFloatBE() writes big endian, writeFloatLE() writes little endian). Behavior is not defined when value is anything other than a 32-bit float. Set n

buffer.writeFloatBE()

buf.writeFloatBE(value, offset[, noAssert])

buffer.writeDoubleLE()

buf.writeDoubleLE(value, offset[, noAssert]) value <Number> Bytes to be written to Buffer offset <Number> 0 <= offset <= buf.length - 8 noAssert <Boolean> Default: false Return: <Number> The offset plus the number of written bytes Writes value to the Buffer at the specified offset with specified endian format (writeDoubleBE() writes big endian, writeDoubleLE() writes little endian). The value argument should be a valid 64-bit double. Behavior is not defined w

buffer.writeDoubleBE()

buf.writeDoubleBE(value, offset[, noAssert])

buffer.write()

buf.write(string[, offset[, length]][, encoding]) string <String> Bytes to be written to buffer offset <Number> Default: 0 length <Number> Default: buffer.length - offset encoding <String> Default: 'utf8' Return: <Number> Numbers of bytes written Writes string to the Buffer at offset using the given encoding. The length parameter is the number of bytes to write. If the Buffer did not contain enough space to fit the entire string, only a partial amount of th

buffer.values()

buf.values() Return: <Iterator> Creates and returns an iterator for Buffer values (bytes). This function is called automatically when the Buffer is used in a for..of statement. const buf = Buffer.from('buffer'); for (var value of buf.values()) { console.log(value); } // prints: // 98 // 117 // 102 // 102 // 101 // 114 for (var value of buf) { console.log(value); } // prints: // 98 // 117 // 102 // 102 // 101 // 114

buffer.toString()

buf.toString([encoding[, start[, end]]]) encoding <String> Default: 'utf8' start <Number> Default: 0 end <Number> Default: buffer.length Return: <String> Decodes and returns a string from the Buffer data using the specified character set encoding. const buf = Buffer.allocUnsafe(26); for (var i = 0 ; i < 26 ; i++) { buf[i] = i + 97; // 97 is ASCII a } buf.toString('ascii'); // Returns: 'abcdefghijklmnopqrstuvwxyz' buf.toString('ascii',0,5); // Returns: '

buffer.toJSON()

buf.toJSON() Return: <Object> Returns a JSON representation of the Buffer instance. JSON.stringify() implicitly calls this function when stringifying a Buffer instance. Example: const buf = Buffer.from('test'); const json = JSON.stringify(buf); console.log(json); // Prints: '{"type":"Buffer","data":[116,101,115,116]}' const copy = JSON.parse(json, (key, value) => { return value && value.type === 'Buffer' ? Buffer.from(value.data) : value; }); console.l

buffer.swap32()

buf.swap32() Return: <Buffer> Interprets the Buffer as an array of unsigned 32-bit integers and swaps the byte-order in-place. Throws a RangeError if the Buffer length is not a multiple of 32 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.swap32(); console.log(buf); // Prints Buffer(0x4, 0x3, 0x2, 0x1, 0x8,