export function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => ReturnType<T> {
    let lastCall = 0;
    let lastResult: ReturnType<T>;
    return function (...args: Parameters<T>): ReturnType<T> {
        const now = Date.now();
        if (now - lastCall >= delay) {
            lastCall = now;
            lastResult = fn.apply(this, args);
        }
        return lastResult;
    };
}
