UNPKG

vue3-game-analytics

Version:

Comprehensive analytics tracking system for Vue 3 game applications

82 lines (80 loc) 2.21 kB
import { CircularBufferOptions } from '../types'; /** * Circular buffer implementation for efficient memory management of analytics events * Uses a fixed-size array and pointer-based approach to avoid frequent array resizing */ export declare class CircularBuffer<T> { private buffer; private head; private tail; private size; private readonly capacity; private readonly overflowStrategy; private overflowCount; /** * Creates a new circular buffer * @param options Configuration options for the buffer */ constructor(options: CircularBufferOptions); /** * Add an item to the buffer * @param item Item to add * @returns True if item was added, false if discarded due to overflow * @throws Error if overflowStrategy is 'error' and buffer is full */ push(item: T): boolean; /** * Remove and return the oldest item from the buffer * @returns The oldest item or null if buffer is empty */ dequeue(): T | null; /** * Get all items in the buffer without removing them * @returns Array of all items in insertion order */ getItems(): T[]; /** * Remove all items from the buffer and return them * @returns Array of all items that were in the buffer */ drain(): T[]; /** * Clear the buffer */ clear(): void; /** * Check if buffer is empty * @returns True if buffer is empty */ isEmpty(): boolean; /** * Check if buffer is full * @returns True if buffer is full */ isFull(): boolean; /** * Get the current size of the buffer * @returns Number of items in buffer */ getSize(): number; /** * Get the total capacity of the buffer * @returns Maximum capacity */ getCapacity(): number; /** * Get the number of items that were discarded due to overflow * @returns Overflow count */ getOverflowCount(): number; /** * Get buffer information for diagnostics */ getBufferInfo(): { capacity: number; size: number; overflowCount: number; isFull: boolean; isEmpty: boolean; }; }