buf.readUInt16BE()

buf.readUInt16BE(offset[, noAssert])
buf.readUInt16LE(offset[, noAssert])

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

buf.readUInt16BE(0);
// Returns: 0x0304
buf.readUInt16LE(0);
// Returns: 0x0403
buf.readUInt16BE(1);
// Returns: 0x0423
buf.readUInt16LE(1);
// Returns: 0x2304
buf.readUInt16BE(2);
// Returns: 0x2342
buf.readUInt16LE(2);
// Returns: 0x4223

posted @ 2018-11-05 13:40  sfornt  阅读(1034)  评论(0编辑  收藏  举报