MCPcopy Index your code
hub / github.com/Bistutu/FluentRead / throttle

Function throttle

userscripts.js:1633–1643  ·  view source on GitHub ↗
(fn, interval)

Source from the content-addressed store, hash-verified

1631
1632// 防抖限流函数
1633function throttle(fn, interval) {
1634 let last = 0; // 维护上次执行的时间
1635 return function () {
1636 const now = Date.now();
1637 // 根据当前时间和上次执行时间的差值判断是否频繁
1638 if (now - last >= interval) {
1639 last = now;
1640 fn();
1641 }
1642 };
1643}
1644
1645// 判断是否为空元素
1646function isEmpty(node) {

Callers 1

userscripts.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected