z-util-page
Version:
33 lines (32 loc) • 863 B
TypeScript
/**
* 将函数处理为防抖函数
* @category 辅助函数
* @example
* ```ts
* let debounced = debounce(function () {
* console.log('身体和心灵,总有一个在路上。');
* return '身体和心灵,总有一个在路上。';
* }, 1000, true);
* debounced.then(function (res) {
* console.log(res);
* });
* debounced();
* debounced.cancel();
* ```
* @param func 待处理函数
* @param wait 函数执行延迟时间
* @param immediatel 是否立刻执行
*/
export declare function debounce(func: Function, wait: number, immediatel?: boolean): {
(this: any, ...args: any[]): any;
/**
* 取消防抖函数执行
*/
cancel(): void;
/**
* 注册防抖函数执行后的回调
* @param callback 回调函数
* @returns 处理好的防抖函数
*/
then(callback: Function): any;
};