$ npm install byte-list
const { ByteList } = require('byte-list');
const bytes = new ByteList();
const myNumber = 0xABCD1234;
console.log(myNumber);
// 2882343476 (0xABCD1234)
bytes.writeUInt32(myNumber);
bytes.index = 0;
console.log(bytes.readUInt32());
// 2882343476 (0xABCD1234)
bytes.index = 0;
console.log(bytes.readUInt16());
// 43981 (0xABCD)
console.log(bytes.readUInt16());
// 4660 (0x1234)
bytes.index = 0;
console.log(bytes.readByte());
// 171 (0xAB)
console.log(bytes.readByte());
// 205 (0xCD)
console.log(bytes.readByte());
// 18 (0x12)
console.log(bytes.readByte());
// 52 (0x34)
The static SetBit and GetBit methods assume the num parameter is a 32-bit integer and will only accept bit specification between 0 and 31.