/** * Managed timer that tracks a single setTimeout or setInterval. * Provides safe clear/replace semantics to prevent memory leaks. */ export declare class ManagedTimer { private timer; private isInterval; /** * Set a timeout (replaces any existing timer). * * @param callback - Function to call after delay * @param delay - Delay in milliseconds */ setTimeout(callback: () => void, delay: number): void; /** * Set an interval (replaces any existing timer). * * @param callback - Function to call repeatedly * @param interval - Interval in milliseconds */ setInterval(callback: () => void, interval: number): void; /** * Clear the current timer. */ clear(): void; /** * Check if a timer is currently active. */ isActive(): boolean; /** * Refresh the timer (restart from current time). * Only works for timeouts, not intervals. */ refresh(): void; } /** * Group of named managed timers. * Useful for components that need multiple timers. */ export declare class TimerGroup { private readonly timers; /** * Get or create a timer by name. * * @param name - Timer name * @returns ManagedTimer instance */ get(name: string): ManagedTimer; /** * Clear a specific timer by name. * * @param name - Timer name */ clear(name: string): void; /** * Clear all timers in the group. */ clearAll(): void; /** * Check if a specific timer is active. * * @param name - Timer name * @returns true if timer exists and is active */ isActive(name: string): boolean; /** * Get all timer names. */ getNames(): string[]; /** * Get count of active timers. */ getActiveCount(): number; } /** * Create a debounced function that delays execution until after * a period of inactivity. * * @param fn - Function to debounce * @param delay - Delay in milliseconds * @returns Debounced function with cancel method */ export declare function debounce void>(fn: T, delay: number): T & { cancel: () => void; }; /** * Create a throttled function that only executes at most once * per time period. * * @param fn - Function to throttle * @param limit - Minimum time between executions in milliseconds * @returns Throttled function */ export declare function throttle void>(fn: T, limit: number): T; /** * Sleep for a specified duration. * * @param ms - Duration in milliseconds * @returns Promise that resolves after the duration */ export declare function sleep(ms: number): Promise; /** * Create a timeout promise that rejects after a specified duration. * * @param ms - Timeout in milliseconds * @param message - Error message * @returns Promise that rejects after timeout */ export declare function timeout(ms: number, message?: string): Promise; /** * Race a promise against a timeout. * * @param promise - Promise to race * @param ms - Timeout in milliseconds * @param message - Timeout error message * @returns Promise result or timeout error */ export declare function withTimeout(promise: Promise, ms: number, message?: string): Promise; //# sourceMappingURL=timer.d.ts.map