vite-uni-dev-tool
Version:
vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试
28 lines • 1.28 kB
TypeScript
type ThrottleOptions = {
leading?: boolean;
trailing?: boolean;
};
/**
* 创建一个节流函数,在指定时间间隔内只执行一次原函数
* @param func 需要节流的函数
* @param wait 等待时间(毫秒)
* @param options 配置选项
* @param options.leading 是否在开始时立即执行
* @param options.trailing 是否在延迟结束后执行最后一次调用
* @returns 节流后的函数
*/
export declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number, options?: ThrottleOptions): (...args: Parameters<T>) => ReturnType<T> | undefined;
type DebouncedFunction<T extends (...args: any[]) => any> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {
cancel: () => void;
flush: () => ReturnType<T> | undefined;
};
/**
* 创建一个防抖函数,该函数在最后一次调用后等待指定时间才执行。
* @param func 需要防抖的函数
* @param wait 等待时间(毫秒)
* @param immediate 是否在第一次调用时立即执行
* @returns 防抖后的函数
*/
export declare function debounce<T extends (...args: any[]) => any>(func: T, wait: number, immediate?: boolean): DebouncedFunction<T>;
export {};
//# sourceMappingURL=function.d.ts.map