-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.d.ts
33 lines (26 loc) · 1015 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {type Options} from 'p-map';
type PromiseFactory<T> = () => PromiseLike<T>;
/**
Run promise-returning & async functions concurrently with optional limited concurrency.
@param tasks - Iterable with promise-returning/async functions.
@returns A `Promise` that is fulfilled when all promises returned from calling the functions in `tasks` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values in `tasks` order.
@example
```
import pAll from 'p-all';
import got from 'got';
const actions = [
() => got('https://sindresorhus.com'),
() => got('https://avajs.dev'),
() => checkSomething(),
() => doSomethingElse()
];
console.log(await pAll(actions, {concurrency: 2}));
```
*/
export default function pAll<Task extends Array<PromiseFactory<unknown>>>(
tasks: readonly [...Task],
options?: Options,
): Promise<{
[P in keyof Task]: Task[P] extends () => unknown ? Awaited<ReturnType<Task[P]>> : Task[P]
}>;
export {type Options} from 'p-map';