Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | declare namespace pLimit {
|
---|
2 | interface Limit {
|
---|
3 | /**
|
---|
4 | The number of promises that are currently running.
|
---|
5 | */
|
---|
6 | readonly activeCount: number;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | The number of promises that are waiting to run (i.e. their internal `fn` was not called yet).
|
---|
10 | */
|
---|
11 | readonly pendingCount: number;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | Discard pending promises that are waiting to run.
|
---|
15 |
|
---|
16 | 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.
|
---|
17 |
|
---|
18 | Note: This does not cancel promises that are already running.
|
---|
19 | */
|
---|
20 | clearQueue: () => void;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | @param fn - Promise-returning/async function.
|
---|
24 | @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.
|
---|
25 | @returns The promise returned by calling `fn(...arguments)`.
|
---|
26 | */
|
---|
27 | <Arguments extends unknown[], ReturnType>(
|
---|
28 | fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
|
---|
29 | ...arguments: Arguments
|
---|
30 | ): Promise<ReturnType>;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | /**
|
---|
35 | Run multiple promise-returning & async functions with limited concurrency.
|
---|
36 |
|
---|
37 | @param concurrency - Concurrency limit. Minimum: `1`.
|
---|
38 | @returns A `limit` function.
|
---|
39 | */
|
---|
40 | declare function pLimit(concurrency: number): pLimit.Limit;
|
---|
41 |
|
---|
42 | export = pLimit;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.