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