node函数buf.readDoubleBE详解
- offset {Number} 0 <= offset <= buf.length - 8
- noAssert {Boolean} 默认:false
- 返回:{Number}
设置 noAssert 为 true ,将跳过对 offset 的验证。这将允许 offset 超出缓冲区的末尾。
const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
buf.readDoubleBE();
// Returns: 8.20788039913184e-304
buf.readDoubleLE();
// Returns: 5.447603722011605e-270
buf.readDoubleLE(1);
// throws RangeError: Index out of range
buf.readDoubleLE(1, true); // Warning: reads passed end of buffer!
// Segmentation fault! don't do this!