@ton3/liteclient
Version:
TON Blockchain LiteClient
21 lines • 722 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.bytesToUint = exports.uintToBytes = void 0;
const uintToBytes = (value, length) => {
const buffer = new Uint8Array(length).fill(0);
buffer[length - 1] = value & 0xFF;
for (let i = length - 2, mul = 256; i >= 0; --i, mul *= 0x100) {
buffer[i] = (value / mul) & 0xFF;
}
return buffer;
};
exports.uintToBytes = uintToBytes;
const bytesToUint = (value) => {
let result = value[value.byteLength - 1];
for (let i = value.byteLength - 2, mul = 256; i >= 0; --i, mul *= 0x100) {
result += value[i] * mul;
}
return result;
};
exports.bytesToUint = bytesToUint;
//# sourceMappingURL=utils.js.map