export class CircularBuffer {
    capacity;
    values = [];
    constructor(capacity) {
        this.capacity = capacity;
        if (!Number.isInteger(capacity) || capacity <= 0) {
            throw new Error("CircularBuffer capacity must be a positive integer");
        }
    }
    push(value) {
        this.values.push(value);
        if (this.values.length > this.capacity)
            this.values.shift();
    }
    toArray() {
        return [...this.values];
    }
    clear() {
        this.values.length = 0;
    }
    get length() {
        return this.values.length;
    }
}
