index.d.ts 1003 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Throttle the given function to only run `size` times in parallel.
  3. * Extra calls will be queued until one of the earlier calls completes.
  4. */
  5. declare function throat<TResult, TArgs extends any[]>(
  6. size: number,
  7. fn: (...args: TArgs) => Promise<TResult>
  8. ): (...args: TArgs) => Promise<TResult>;
  9. /**
  10. * Throttle the given function to only run `size` times in parallel.
  11. * Extra calls will be queued until one of the earlier calls completes.
  12. */
  13. declare function throat<TResult, TArgs extends any[]>(
  14. fn: (...args: TArgs) => Promise<TResult>,
  15. size: number
  16. ): (...args: TArgs) => Promise<TResult>;
  17. /**
  18. * Create a throttle that only allows `size` calls in parallel.
  19. * Extra calls will be queued until one of the earlier calls completes.
  20. *
  21. * To create an exclusive lock, just use a `size` of `1`.
  22. */
  23. declare function throat(
  24. size: number
  25. ): <TResult, TArgs extends any[] = []>(
  26. fn: (...args: TArgs) => Promise<TResult>,
  27. ...args: TArgs
  28. ) => Promise<TResult>;
  29. export default throat;