UNPKG

667 BTypeScriptView Raw
1export interface DebounceOptions {
2 /**
3 * 是否在之前执行
4 */
5 leading?: boolean;
6 /**
7 * 是否在之后执行
8 */
9 trailing?: boolean;
10}
11
12/**
13 * 函数去抖;当被调用 n 毫秒后才会执行,如果在这时间内又被调用则将重新计算执行时间
14 * @param callback 回调
15 * @param wait 毫秒
16 * @param options 可选参数
17 */
18export declare function debounce<C>(callback: (this: C, ...args: any[]) => any, wait: number, options?: DebounceOptions): (this: C, ...args: any[]) => any;
19
20declare module './ctor' {
21 interface XEUtilsMethods {
22 debounce: typeof debounce;
23 }
24}
25
26export default debounce