throttle 'tilts' from the server

This commit is contained in:
Gavin McDonald
2025-06-28 20:16:52 -04:00
parent 2ae4c6a77b
commit 1dbe6b7ec0
8 changed files with 66 additions and 28 deletions

12
tools/throttle.ts Normal file
View File

@@ -0,0 +1,12 @@
export default function throttle(func: Function, threshold: number) {
let lastCall = 0;
return (...args: any[]) => {
const now = Date.now();
if (now - lastCall >= threshold) {
lastCall = now;
func(...args);
}
};
}