@daysnap/utils
Version:
18 lines (16 loc) • 808 B
TypeScript
/**
* 节流函数,时间戳模式
* 减少事件执行次数,有规律的执行,事件触发后立即执行
*/
declare function throttleLeading<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
/**
* 节流函数,定时器模式
* 减少事件执行次数,有规律的执行,事件触发后延迟执行
*/
declare function throttleTrailing<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
/**
* 节流函数
* 减少事件执行次数,有规律的执行
*/
declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number, mode?: 'leading' | 'trailing'): (this: unknown, ...args: Parameters<T>) => void;
export { throttle, throttleLeading, throttleTrailing };