@forchange/aui
Version:
ai-boss 业务 ui 组件库
23 lines (20 loc) • 431 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.debounce = debounce;
/**
* 防抖函数
* @param fn 事件触发的操作
* @param wait 多少毫秒内连续触发事件,不会执行
* @returns {Function}
*/
function debounce(fn, wait) {
let timeout = null;
return () => {
if (timeout !== null) {
clearTimeout(timeout);
}
timeout = setTimeout(fn, wait);
};
}