chore: throttle exceptions counter increment (#29719)
parent
18c55b0bbe
commit
706561aa27
@ -0,0 +1,20 @@ |
||||
import { throttle } from 'underscore'; |
||||
|
||||
export function throttledCounter(fn: (counter: number) => unknown, wait: number) { |
||||
let counter = 0; |
||||
|
||||
const throttledFn = throttle( |
||||
() => { |
||||
fn(counter); |
||||
|
||||
counter = 0; |
||||
}, |
||||
wait, |
||||
{ leading: false }, |
||||
); |
||||
|
||||
return () => { |
||||
counter++; |
||||
throttledFn(); |
||||
}; |
||||
} |
||||
Loading…
Reference in new issue