fn.d.ts 740 B

12345678910111213141516171819202122232425262728293031323334353637
  1. export type DebouncedFunction = {
  2. (...args: any[]): any;
  3. flush: () => void;
  4. cancel: () => void;
  5. };
  6. /**
  7. * Debounce fn, calling it only once if
  8. * the given time elapsed between calls.
  9. *
  10. * @param fn
  11. * @param timeout
  12. *
  13. * @return debounced function
  14. */
  15. export function debounce(fn: Function, timeout: number): DebouncedFunction;
  16. /**
  17. * Throttle fn, calling at most once
  18. * in the given interval.
  19. *
  20. * @param fn
  21. * @param interval
  22. *
  23. * @return throttled function
  24. */
  25. export function throttle(fn: Function, interval: number): (...args: any[]) => void;
  26. /**
  27. * Bind function against target <this>.
  28. *
  29. * @param fn
  30. * @param target
  31. *
  32. * @return bound function
  33. */
  34. export function bind<T extends Function>(fn: T, target: object): T;