type Callback = (...args: any[]) => void; /** * 节流和防抖返回值类型 */ export interface DebounceAndThrottleReturnType { (...args: Parameters): void; cancel(): void; } /** 第二参数 */ export type debounce_throttle_options = { delay?: number; this?: null | unknown; } | number; /** * 防抖 * * @param callback 回调函数 * @param options 延迟时间(毫秒),默认 200 (ms) 或包含 this 的配置 * @returns 返回的闭包函数 * @example * * ```ts * const debounce = (callback: Function, delay = 300) => { * let timer: any = null * * return (...args: any[]) => clearTimeout(timer) * } * ``` */ export declare function debounce(callback: F, options?: debounce_throttle_options): DebounceAndThrottleReturnType; /** * 节流 * * @param callback 回调函数 * @param options 延迟时间(毫秒),默认 200 (ms) 或设置 this * @returns 返回的闭包函数 */ export declare function throttle(callback: F, options?: debounce_throttle_options): DebounceAndThrottleReturnType; export {};