"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ByteBuffer {
    constructor(buff) {
        this.offset = 0;
        this.buff = buff;
    }
    getRemainder() {
        return this.buff.slice(this.offset);
    }
    getRemainderLength() {
        return this.buff.length - this.offset;
    }
    getResult() {
        return this.buff.slice(0, this.offset);
    }
    getResultLength() {
        return this.offset;
    }
    reset() {
        this.offset = 0;
    }
    jump(length) {
        if (length < -this.offset || length > this.getRemainderLength()) {
            throw new Error("Jump over buffer boundary.");
        }
        this.offset += length;
    }
    writeInt8(value) {
        this.offset = this.buff.writeInt8(value, this.offset);
    }
    writeInt16BE(value) {
        this.offset = this.buff.writeInt16BE(value, this.offset);
    }
    writeInt16LE(value) {
        this.offset = this.buff.writeInt16LE(value, this.offset);
    }
    writeInt32BE(value) {
        this.offset = this.buff.writeInt32BE(value, this.offset);
    }
    writeInt32LE(value) {
        this.offset = this.buff.writeInt32LE(value, this.offset);
    }
    writeBigInt64BE(value) {
        this.offset = this.buff.writeBigInt64BE(value, this.offset);
    }
    writeBigInt64LE(value) {
        this.offset = this.buff.writeBigInt64LE(value, this.offset);
    }
    writeUInt8(value) {
        this.offset = this.buff.writeUInt8(value, this.offset);
    }
    writeUInt16BE(value) {
        this.offset = this.buff.writeUInt16BE(value, this.offset);
    }
    writeUInt16LE(value) {
        this.offset = this.buff.writeUInt16LE(value, this.offset);
    }
    writeUInt32BE(value) {
        this.offset = this.buff.writeUInt32BE(value, this.offset);
    }
    writeUInt32LE(value) {
        this.offset = this.buff.writeUInt32LE(value, this.offset);
    }
    writeBigUInt64BE(value) {
        this.offset = this.buff.writeBigUInt64BE(value, this.offset);
    }
    writeBigUInt64LE(value) {
        this.offset = this.buff.writeBigUInt64LE(value, this.offset);
    }
    writeBuffer(value) {
        if (value.length > this.getRemainderLength()) {
            throw new Error("Write over buffer boundary.");
        }
        this.offset += value.copy(this.buff, this.offset);
    }
    readInt8() {
        const value = this.buff.readInt8(this.offset);
        this.offset += 1;
        return value;
    }
    readInt16BE() {
        const value = this.buff.readInt16BE(this.offset);
        this.offset += 2;
        return value;
    }
    readInt16LE() {
        const value = this.buff.readInt16LE(this.offset);
        this.offset += 2;
        return value;
    }
    readInt32BE() {
        const value = this.buff.readInt32BE(this.offset);
        this.offset += 4;
        return value;
    }
    readInt32LE() {
        const value = this.buff.readInt32LE(this.offset);
        this.offset += 4;
        return value;
    }
    readBigInt64BE() {
        const value = this.buff.readBigInt64BE(this.offset);
        this.offset += 8;
        return value;
    }
    readBigInt64LE() {
        const value = this.buff.readBigInt64LE(this.offset);
        this.offset += 8;
        return value;
    }
    readUInt8() {
        const value = this.buff.readUInt8(this.offset);
        this.offset += 1;
        return value;
    }
    readUInt16BE() {
        const value = this.buff.readUInt16BE(this.offset);
        this.offset += 2;
        return value;
    }
    readUInt16LE() {
        const value = this.buff.readUInt16LE(this.offset);
        this.offset += 2;
        return value;
    }
    readUInt32BE() {
        const value = this.buff.readUInt32BE(this.offset);
        this.offset += 4;
        return value;
    }
    readUInt32LE() {
        const value = this.buff.readUInt32LE(this.offset);
        this.offset += 4;
        return value;
    }
    readBigUInt64BE() {
        const value = this.buff.readBigUInt64BE(this.offset);
        this.offset += 8;
        return value;
    }
    readBigUInt64LE() {
        const value = this.buff.readBigUInt64LE(this.offset);
        this.offset += 8;
        return value;
    }
    readBuffer(length) {
        if (length > this.getRemainderLength()) {
            throw new Error("Read over buffer boundary.");
        }
        const value = this.buff.slice(this.offset, this.offset + length);
        this.offset += length;
        return value;
    }
}
exports.ByteBuffer = ByteBuffer;
//# sourceMappingURL=byte-buffer.js.map