当前位置:网站首页>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);
};
}
边栏推荐
猜你喜欢

Lhasa accordion

Create NFS based storageclass on kubernetes

Solution of dam safety automatic monitoring system for medium and small reservoirs
![Video tutorial on website operation to achieve SEO operation [21 lectures]](/img/1f/9ae2ed5bfec5749c764630d1daccea.jpg)
Video tutorial on website operation to achieve SEO operation [21 lectures]

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

File foundation - read / write, storage

YYGH-8-预约挂号

線條動畫

JSP

数据中台:六问数据中台
随机推荐
Data middle office: construction ideas and implementation experience of data governance
5g network overall architecture
Main functions of 5ggnb and ng ENB
TypeScript基础类型
ipvs 导致syn 重传问题
Lhasa accordion
Filecoin hacker song developer competition
pkg打包node工程(express)
函数栈帧的创建和销毁
学术搜索相关论文
Shanghai Yuge ASR CAT1 4G module 2-way low power 4G application
Relevant implementation records of CSI and local disk
博客登录框
Mysql-17- create and manage tables
bash install.sh ********错误
Jenkins持续集成1
JSP
YYGH-8-预约挂号
Mysql-16-subquery
什么是WebRTC?