您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. declare namespace pLimit {
  2. interface Limit {
  3. /**
  4. The number of promises that are currently running.
  5. */
  6. readonly activeCount: number;
  7. /**
  8. The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
  9. */
  10. readonly pendingCount: number;
  11. /**
  12. Discard pending promises that are waiting to run.
  13. This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
  14. Note: This does not cancel promises that are already running.
  15. */
  16. clearQueue: () => void;
  17. /**
  18. @param fn - Promise-returning/async function.
  19. @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions.
  20. @returns The promise returned by calling `fn(...arguments)`.
  21. */
  22. <Arguments extends unknown[], ReturnType>(
  23. fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
  24. ...arguments: Arguments
  25. ): Promise<ReturnType>;
  26. }
  27. }
  28. /**
  29. Run multiple promise-returning & async functions with limited concurrency.
  30. @param concurrency - Concurrency limit. Minimum: `1`.
  31. @returns A `limit` function.
  32. */
  33. declare function pLimit(concurrency: number): pLimit.Limit;
  34. export = pLimit;