"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readUint64BigEndian = exports.writeUint64BigEndian = exports.writeUint64LittleEndian = void 0;
const bytes_1 = require("./bytes");
// TODO handle bigger values than 32 bit
// For now it's good enough because we only use these functions
// sequential feed indexes.
function writeUint64LittleEndian(value, bytes = (0, bytes_1.makeBytes)(8)) {
    const dataView = new DataView(bytes.buffer);
    const valueLower32 = value & 0xffffffff;
    const littleEndian = true;
    dataView.setUint32(0, valueLower32, littleEndian);
    dataView.setUint32(4, 0, littleEndian);
    return bytes;
}
exports.writeUint64LittleEndian = writeUint64LittleEndian;
function writeUint64BigEndian(value, bytes = (0, bytes_1.makeBytes)(8)) {
    const dataView = new DataView(bytes.buffer);
    const valueLower32 = value & 0xffffffff;
    dataView.setUint32(0, 0);
    dataView.setUint32(4, valueLower32);
    return bytes;
}
exports.writeUint64BigEndian = writeUint64BigEndian;
function readUint64BigEndian(bytes) {
    const dataView = new DataView(bytes.buffer);
    return dataView.getUint32(4);
}
exports.readUint64BigEndian = readUint64BigEndian;
