buf.readUInt32BE()函数详解

buf.readUInt32BE(offset[, noAssert])
buf.readUInt32LE(offset[, noAssert])

  • offset {Number} 0 <= offset <= buf.length - 4
  • noAssert {Boolean} 默认:false
  • 返回:{Number}
从该 Buffer 指定的带有特定尾数格式(readUInt32BE() 返回一个较大的尾数,readUInt32LE() 返回一个较小的尾数)的 offset 位置开始读取一个无符号的32位整数值。 设置 noAssert 为 true ,将跳过对 offset 的验证。这将允许 offset 超出缓冲区的末尾。 例子: ``` const buf = Buffer.from([0x3, 0x4, 0x23, 0x42]);

buf.readUInt32BE(0);
// Returns: 0x03042342
console.log(buf.readUInt32LE(0));
// Returns: 0x42230403

原文地址:https://www.cnblogs.com/lalalagq/p/9908694.html