@bugspotter/sdk
Version:
Professional bug reporting SDK with screenshots, session replay, and automatic error capture for web applications
43 lines (42 loc) • 1.06 kB
TypeScript
/**
* A generic circular buffer implementation for storing a fixed number of items.
* When the buffer is full, new items overwrite the oldest items.
*
* @template T The type of items stored in the buffer
*/
export declare class CircularBuffer<T> {
private maxSize;
private items;
private index;
private count;
constructor(maxSize: number);
/**
* Add an item to the buffer. If the buffer is full, the oldest item is overwritten.
*/
add(item: T): void;
/**
* Get all items in chronological order (oldest to newest).
* Returns a copy of the internal array.
*/
getAll(): T[];
/**
* Clear all items from the buffer.
*/
clear(): void;
/**
* Get the current number of items in the buffer.
*/
get size(): number;
/**
* Get the maximum capacity of the buffer.
*/
get capacity(): number;
/**
* Check if the buffer is empty.
*/
get isEmpty(): boolean;
/**
* Check if the buffer is full.
*/
get isFull(): boolean;
}