|
buf.readUInt16BE(offset[, noAssert])- offset Number 类型
- noAssert Boolean, 可选参数, 默认值: false
- 返回: Number 类型
- 从 buffer 对象里,根据指定的偏移量,使用特殊的 endian 字节序格式读取一个有符号 16 位整数。
- 若参数 noAssert 为 true 将不会验证 offset 偏移量参数。 这意味着 offset 可能会超出 buffer 的末尾。默认是 false。
- 例如:
复制代码- var buf = new Buffer(4);
- buf[0] = 0x3;
- buf[1] = 0x4;
- buf[2] = 0x23;
- buf[3] = 0x42;
- console.log(buf.readUInt16BE(0));
- console.log(buf.readUInt16LE(0));
- console.log(buf.readUInt16BE(1));
- console.log(buf.readUInt16LE(1));
- console.log(buf.readUInt16BE(2));
- console.log(buf.readUInt16LE(2));
- // 0x0304
- // 0x0403
- // 0x0423
- // 0x2304
- // 0x2342
- // 0x4223
复制代码
|
|