MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / throttle

Function throttle

src/common/util.js:50–61  ·  view source on GitHub ↗
(func, time)

Source from the content-addressed store, hash-verified

48}
49
50export function throttle(func, time) {
51 let lastTime = 0;
52 time = Math.max(0, +time || 0);
53 function throttledFunction(...args) {
54 const now = performance.now();
55 if (lastTime + time < now) {
56 lastTime = now;
57 func.apply(this, args);
58 }
59 }
60 return throttledFunction;
61}
62
63export function noop() {}
64

Callers 1

index.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected