/** * 节流函数的类型定义 * @template T - 原始函数的类型 */ interface ThrottledFunction any> { /** * 节流后的函数,参数类型与原函数一致 */ (...args: Parameters): void; /** * 取消节流函数的未执行部分 */ cancel: () => void; } /** * 创建一个节流函数。 * 节流函数的作用是限制一个函数在一定时间内最多执行一次,避免高频触发导致的性能问题。 * @param {T} callback - 需要节流的函数 * @param {number} delay - 节流的时间间隔(毫秒) * @returns {ThrottledFunction} 节流后的函数,包含原函数的参数类型和取消方法 */ declare function throttle any>(callback: T, delay: number): ThrottledFunction; export default throttle;