当前位置:网站首页>Simple handwritten debounce function
Simple handwritten debounce function
2022-06-28 05:49:00 【Joey_ Tribiani】
function debounce(cb, timeout = 300) {
// Closure a last trigger time
let lastEmitTime;
return function () {
// Each call updates the last trigger time
lastEmitTime = new Date().valueOf();
setTimeout(() => {
// Set up timeout After the time, compare whether the last call time has exceeded the setting timeout Call when it exceeds callback
const currentTime = new Date().valueOf();
if (currentTime - lastEmitTime >= timeout) {
cb(...arguments);
}
}, timeout);
};
}
边栏推荐
- 安装 Ffmpefg
- PS effect understanding record 2 color_ dodge color_ burn
- 博客登录框
- Jenkins continues integration 2
- Maskrcnn, fast RCNN, fast RCNN excellent video
- Data midrange: implementation and summary of AI midrange
- Jenkins继续集成2
- jsp连接oracle实现登录注册(简单)
- The windows environment redis uses AOF persistence and cannot generate an AOF file. After generation, the content of the AOF file cannot be loaded
- Typescript base type
猜你喜欢

Filecoin hacker song developer competition

5g network overall architecture
![[CAD drawing Video] AutoCAD 2014 master's way](/img/19/7013333c028d7db02e356661b9ffc3.jpg)
[CAD drawing Video] AutoCAD 2014 master's way

Jenkins continues integration 2

Binder面试之:内存管理单元

Jenkins continuous integration 1

Yin Yang master page

Linked list in JS (including leetcode examples) < continuous update ~>

JS中的链表(含leetcode例题)<持续更新~>

2022 new version NFT source code source code of China meta universe digital collection art trading platform
随机推荐
JSP
数据中台:一篇带你深入浅出了解数据中台
Qtcanpool q05: no border
Determine whether an attribute exists in an object
Typescript interface
ERP软件公司选型的重要根据
What does mysql---where 1=1 mean
Data center: Seven Swords of data governance
关系数据库与文档数据库对比
安装 Ffmpefg
开发者的时代红利在哪里?
阴阳师页面
RL 实践(0)—— 及第平台辛丑年冬赛季【Rule-based policy】
Data midrange: implementation and summary of AI midrange
Jenkins继续集成2
上海域格ASR CAT1 4g模块2路保活低功耗4G应用
Relevant implementation records of CSI and local disk
数据仓库:DWS层设计原则
5GgNB和ng-eNB的主要功能
Online yaml to JSON tool