buf.readUIntLE(offset, byteLength)


  • offset <integer> 在开始读取前要跳过的字节数。必须满足 0 <= offset <= buf.length - byteLength
  • byteLength <integer> 要读取的字节数。必须满足 0 < byteLength <= 6
  • 返回值: <integer>

buf 的指定 offset 读取 byteLength 个字节,并将结果解释为一个无符号的小端整数,支持最多 48 位的精度。

【Reads byteLength number of bytes from buf at the specified offset and interprets the result as an unsigned, little-endian integer supporting up to 48 bits of accuracy.】

该函数也可以通过 readUintLE 别名使用。

【This function is also available under the readUintLE alias.】

import { Buffer } from 'node:buffer';

const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);

console.log(buf.readUIntLE(0, 6).toString(16));
// Prints: ab9078563412const { Buffer } = require('node:buffer');

const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);

console.log(buf.readUIntLE(0, 6).toString(16));
// Prints: ab9078563412