mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +00:00
util: create throttle func
This commit is contained in:
parent
51ca1f5c80
commit
99537a8058
|
@ -24,3 +24,14 @@ export function currencyColor(currency) {
|
||||||
return '#4A7DED';
|
return '#4A7DED';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function throttle(fn, delayMillis) {
|
||||||
|
let permitted = true;
|
||||||
|
return () => {
|
||||||
|
if (permitted) {
|
||||||
|
fn.apply(this, arguments)
|
||||||
|
permitted = false
|
||||||
|
setTimeout(() => permitted = true, delayMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user