UNPKG

z-util-page

Version:
40 lines (39 loc) 902 B
/** * 函数节流配置 */ export interface throttleOptions { leading: boolean; trailing: boolean; } /** * 函数节流 * @category 辅助函数 * @example * ```ts * interface throttleOptions { * // 首次是否执行 * leading: boolean, * // 结束是否执行 * trailing: boolean * } * let throttle = throttle(function(){ * console.log('身体和心灵,总有一个在路上。'); * return '身体和心灵,总有一个在路上。'; * }, 1000, { * leading: true, * trailing: true * }); * throttle(); * throttle.cancel(); * ``` * @param func 待处理函数 * @param wait 函数执行最短间隔时间 * @param option 函数执行配置 */ export declare function throttle(func: Function, wait: number, option?: throttleOptions): { (this: any, ...argList: any[]): any; /** * 取消节流函数执行 */ cancel(): void; };