function throttle(fn, wait) {
  let timer = null;
  let previous = 0;
  return function(...args) {
    const now = +new Date();
    if (!previous) {
      previous = now;
    }
    const remain = (previous + wait) - now;

    if (remain < 0) {
      if (timer) {
        clearTimeout(timer);
        timer = null;
      }
      previous = now;
      fn.call(this, ...args);
    } else if (!timer) {
      timer = setTimeout(function() {
        timer = null;
        previous = now;
        fn.call(this, ...args);
      }, wait)
    }
  }
}

export default throttle;

@@ -47,28 +47,8 @@
 ll;%0A
-  let previous = 0;%0A
   re
@@ -76,155 +76,8 @@
 ) %7B%0A
-    const now = +new Date();%0A    if (!previous) %7B%0A      previous = now;%0A    %7D%0A    const remain = (previous + wait) - now;%0A%0A    if (remain %3C 0) %7B%0A  
     
@@ -99,140 +99,22 @@
     
- 
- clearTimeout(timer);%0A        timer = null;%0A      %7D%0A      previous = now;%0A      fn.call(this, ...args);%0A    %7D else if (!timer) %7B%0A  
+return;%0A    %7D%0A
     
@@ -151,18 +151,16 @@
 %7B%0A      
-  
 timer = 
@@ -169,34 +169,8 @@
 ll;%0A
-        previous = now;%0A  
     
@@ -178,31 +178,27 @@
  fn.
-call
+apply
 (this, 
-...
 args);%0A
-  
     
@@ -209,43 +209,11 @@
 ait)
-%0A    %7D%0A  %7D%0A%7D%0A%0Aexport default throttle;%0A
+;%0A  %7D%0A%7D

modify throttle func