vue3-game-analytics
Version:
Comprehensive analytics tracking system for Vue 3 game applications
42 lines (41 loc) • 1.85 kB
TypeScript
/**
* Utilities for performance optimization and monitoring
*/
/**
* Creates a throttled function that only invokes the provided function at most once per specified interval
* @param func The function to throttle
* @param wait The number of milliseconds to throttle invocations to
* @return The throttled function
*/
export declare function throttle<T extends (...args: any[]) => any>(func: T, wait?: number): (...args: Parameters<T>) => ReturnType<T> | undefined;
/**
* Creates a debounced function that delays invoking the provided function until after
* the specified wait time has elapsed since the last time it was invoked
* @param func The function to debounce
* @param wait The number of milliseconds to delay
* @param immediate If true, trigger the function on the leading edge instead of the trailing edge
* @return The debounced function
*/
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, immediate?: boolean): (...args: Parameters<T>) => void;
/**
* Measures the frames per second (FPS) of the application
* @param sampleDuration Duration in ms to measure FPS (default: 1000ms)
* @returns Function that returns the current FPS when called
*/
export declare function createFpsMonitor(sampleDuration?: number): () => number;
/**
* Gets memory usage information if available
* @returns Object with memory stats or undefined if not available
*/
export declare function getMemoryInfo(): {
totalJSHeapSize: number;
usedJSHeapSize: number;
jsHeapSizeLimit: number;
} | undefined;
/**
* Schedules a task to run when the browser is idle
* Falls back to setTimeout if requestIdleCallback is not supported
* @param callback Function to execute
* @param timeout Maximum timeout to wait
*/
export declare function runWhenIdle(callback: () => void, timeout?: number): void;