const buf1 = Buffer.from('buffer');
buf1.toString()
//buffer
Buffer.from(object[, offsetOrEncoding[, length]])
const obj2 = { name: 'hhh', age: 23 }
console.log("🚀 ~ file: buffer.js ~ line 43 ~ obj2", obj2.valueOf())
const bufferObj = Buffer.from(JSON.stringify(obj2));
console.log("🚀 ~ file: buffer.js ~ line 42 ~ bufferObj", bufferObj.toString())
//🚀 ~ file: buffer.js ~ line 42 ~ bufferObj {"name":"hhh","age":23}
buf.readUIntBE(offset, byteLength) //读取整型通用方法
buf.writeUIntBE(value, offset, byteLength) //写整型通用方法 byteLength 为[0, 6]
buf.writeDoubleLE(value[, offset]) //写double的通用方法 默认字节为8个
buf.readUInt16BE([offset])
buf.readUInt32BE([offset])
buf.toString()
buf.readDoubleLE([offset])
buf.length
const a = bufArr.slice(1, 2);
const b = Buffer.allocUnsafe(2);
b.writeUInt16BE(299, 0);
console.log("🚀 ~ file: buffer.js ~ line 52 ~ bufArr.readUInt16BE()", b.readUInt16BE(0))