util: create throttle func

This commit is contained in:
ycdesu 2022-06-14 12:36:31 +08:00
parent 51ca1f5c80
commit 99537a8058

View File

@ -24,3 +24,14 @@ export function currencyColor(currency) {
return '#4A7DED';
}
}
export function throttle(fn, delayMillis) {
let permitted = true;
return () => {
if (permitted) {
fn.apply(this, arguments)
permitted = false
setTimeout(() => permitted = true, delayMillis)
}
}
}