Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let runing;
- let timmer;
- const throttle = fun => {
- if (runing) {
- return;
- }
- runing = true;
- setTimeout(() => {
- fun();
- runing = false;
- }, 2000);
- };
- const debounce = fun => {
- if (timmer) {
- clearTimeout(timmer);
- }
- timmer = setTimeout(() => {
- fun();
- }, 2000);
- };
- export { throttle, debounce };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement