MCPcopy Create free account
hub / github.com/outerbase/studio / throttleEvent

Function throttleEvent

src/lib/tracking-throttle.ts:12–30  ·  view source on GitHub ↗
(name: string, time: number, interval: number)

Source from the content-addressed store, hash-verified

10 * @returns
11 */
12export function throttleEvent(name: string, time: number, interval: number) {
13 console.log(
14 "throttleEvent",
15 THROTTLE_COUNT,
16 THROTTLE_TIMESTAMP,
17 name,
18 (THROTTLE_COUNT[name] ?? 0) > time
19 );
20
21 if (Date.now() - (THROTTLE_TIMESTAMP[name] ?? 0) < interval) {
22 THROTTLE_COUNT[name] = (THROTTLE_COUNT[name] ?? 0) + 1;
23 return (THROTTLE_COUNT[name] ?? 0) > time;
24 } else {
25 THROTTLE_COUNT[name] = 0;
26 THROTTLE_TIMESTAMP[name] = Date.now();
27 }
28
29 return false;
30}

Callers 1

sendAnalyticEventsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected