debounce.js 239 B

123456789
  1. export default function debounce(fn, wait) {
  2. var timeout = null;
  3. return function (...arg) {
  4. if (timeout !== null)
  5. clearTimeout(timeout);
  6. timeout = setTimeout(() => fn.call(this, ...arg), wait);
  7. }
  8. }