utils.ts 202 B

123456789
  1. export function debounce(fn: Function, n = 100) {
  2. let handle: any
  3. return (...args: any[]) => {
  4. if (handle) clearTimeout(handle)
  5. handle = setTimeout(() => {
  6. fn(...args)
  7. }, n)
  8. }
  9. }