Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Debounce
- */
- function debounce(f, ms) {
- let timer = null;
- return function (...args) {
- const onComplete = () => {
- f.apply(this, args);
- timer = null;
- }
- if (timer) {
- clearTimeout(timer);
- }
- timer = setTimeout(onComplete, ms);
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement