@foxglove/ulog
Version:
PX4 ULog file reader
21 lines • 712 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromHex = fromHex;
exports.toHex = toHex;
const LUT_HEX_4b = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
const LUT_HEX_8b = new Array(0x100);
for (let n = 0; n < 0x100; n++) {
LUT_HEX_8b[n] = `${LUT_HEX_4b[(n >>> 4) & 0xf]}${LUT_HEX_4b[n & 0xf]}`;
}
function fromHex(hex) {
const match = hex.match(/.{1,2}/g) ?? [];
return new Uint8Array(match.map((byte) => parseInt(byte, 16)));
}
function toHex(data) {
let out = "";
for (let idx = 0, edx = data.length; idx < edx; idx++) {
out += LUT_HEX_8b[data[idx]];
}
return out;
}
//# sourceMappingURL=hex.js.map