1
- export interface Options {
2
- /**
3
- * Number of concurrent pending promises. Minimum: `1`.
4
- *
5
- * @default Infinity
6
- */
7
- concurrency ?: number ;
8
- }
1
+ declare namespace pAll {
2
+ interface Options {
3
+ /**
4
+ Number of concurrent pending promises. Minimum: `1`.
5
+
6
+ @default Infinity
7
+ */
8
+ concurrency ?: number ;
9
+ }
9
10
10
- export type PromiseFactory < T > = ( ) => PromiseLike < T > ;
11
+ type PromiseFactory < T > = ( ) => PromiseLike < T > ;
12
+ }
11
13
12
14
/**
13
- * Run promise-returning & async functions concurrently with optional limited concurrency.
14
- *
15
- * @param tasks - Iterable with promise-returning/async functions.
16
- * @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.
17
- */
18
- declare function pAll <
19
- Result1 ,
20
- Result2 ,
21
- Result3 ,
22
- Result4 ,
23
- Result5 ,
24
- Result6 ,
25
- Result7 ,
26
- Result8 ,
27
- Result9 ,
28
- Result10
29
- > (
30
- tasks : [
31
- PromiseFactory < Result1 > ,
32
- PromiseFactory < Result2 > ,
33
- PromiseFactory < Result3 > ,
34
- PromiseFactory < Result4 > ,
35
- PromiseFactory < Result5 > ,
36
- PromiseFactory < Result6 > ,
37
- PromiseFactory < Result7 > ,
38
- PromiseFactory < Result8 > ,
39
- PromiseFactory < Result9 > ,
40
- PromiseFactory < Result10 >
41
- ] ,
42
- options ?: Options
43
- ) : Promise <
44
- [
15
+ Run promise-returning & async functions concurrently with optional limited concurrency.
16
+
17
+ @param tasks - Iterable with promise-returning/async functions.
18
+ @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.
19
+
20
+ @example
21
+ ```
22
+ import pAll = require('p-all');
23
+ import got = require('got');
24
+
25
+ (async () => {
26
+ const actions = [
27
+ () => got('https://sindresorhus.com'),
28
+ () => got('https://ava.li'),
29
+ () => checkSomething(),
30
+ () => doSomethingElse()
31
+ ];
32
+
33
+ console.log(await pAll(actions, {concurrency: 2}));
34
+ })();
35
+ ```
36
+ */
37
+ declare const pAll : {
38
+ <
45
39
Result1 ,
46
40
Result2 ,
47
41
Result3 ,
@@ -52,33 +46,35 @@ declare function pAll<
52
46
Result8 ,
53
47
Result9 ,
54
48
Result10
55
- ]
56
- > ;
57
- declare function pAll <
58
- Result1 ,
59
- Result2 ,
60
- Result3 ,
61
- Result4 ,
62
- Result5 ,
63
- Result6 ,
64
- Result7 ,
65
- Result8 ,
66
- Result9
67
- > (
68
- tasks : [
69
- PromiseFactory < Result1 > ,
70
- PromiseFactory < Result2 > ,
71
- PromiseFactory < Result3 > ,
72
- PromiseFactory < Result4 > ,
73
- PromiseFactory < Result5 > ,
74
- PromiseFactory < Result6 > ,
75
- PromiseFactory < Result7 > ,
76
- PromiseFactory < Result8 > ,
77
- PromiseFactory < Result9 >
78
- ] ,
79
- options ?: Options
80
- ) : Promise <
81
- [
49
+ > (
50
+ tasks : [
51
+ pAll . PromiseFactory < Result1 > ,
52
+ pAll . PromiseFactory < Result2 > ,
53
+ pAll . PromiseFactory < Result3 > ,
54
+ pAll . PromiseFactory < Result4 > ,
55
+ pAll . PromiseFactory < Result5 > ,
56
+ pAll . PromiseFactory < Result6 > ,
57
+ pAll . PromiseFactory < Result7 > ,
58
+ pAll . PromiseFactory < Result8 > ,
59
+ pAll . PromiseFactory < Result9 > ,
60
+ pAll . PromiseFactory < Result10 >
61
+ ] ,
62
+ options ?: pAll . Options
63
+ ) : Promise <
64
+ [
65
+ Result1 ,
66
+ Result2 ,
67
+ Result3 ,
68
+ Result4 ,
69
+ Result5 ,
70
+ Result6 ,
71
+ Result7 ,
72
+ Result8 ,
73
+ Result9 ,
74
+ Result10
75
+ ]
76
+ > ;
77
+ <
82
78
Result1 ,
83
79
Result2 ,
84
80
Result3 ,
@@ -88,101 +84,112 @@ declare function pAll<
88
84
Result7 ,
89
85
Result8 ,
90
86
Result9
91
- ]
92
- > ;
93
- declare function pAll <
94
- Result1 ,
95
- Result2 ,
96
- Result3 ,
97
- Result4 ,
98
- Result5 ,
99
- Result6 ,
100
- Result7 ,
101
- Result8
102
- > (
103
- tasks : [
104
- PromiseFactory < Result1 > ,
105
- PromiseFactory < Result2 > ,
106
- PromiseFactory < Result3 > ,
107
- PromiseFactory < Result4 > ,
108
- PromiseFactory < Result5 > ,
109
- PromiseFactory < Result6 > ,
110
- PromiseFactory < Result7 > ,
111
- PromiseFactory < Result8 >
112
- ] ,
113
- options ?: Options
114
- ) : Promise <
115
- [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 , Result8 ]
116
- > ;
117
- declare function pAll <
118
- Result1 ,
119
- Result2 ,
120
- Result3 ,
121
- Result4 ,
122
- Result5 ,
123
- Result6 ,
124
- Result7
125
- > (
126
- tasks : [
127
- PromiseFactory < Result1 > ,
128
- PromiseFactory < Result2 > ,
129
- PromiseFactory < Result3 > ,
130
- PromiseFactory < Result4 > ,
131
- PromiseFactory < Result5 > ,
132
- PromiseFactory < Result6 > ,
133
- PromiseFactory < Result7 >
134
- ] ,
135
- options ?: Options
136
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 ] > ;
137
- declare function pAll < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 > (
138
- tasks : [
139
- PromiseFactory < Result1 > ,
140
- PromiseFactory < Result2 > ,
141
- PromiseFactory < Result3 > ,
142
- PromiseFactory < Result4 > ,
143
- PromiseFactory < Result5 > ,
144
- PromiseFactory < Result6 >
145
- ] ,
146
- options ?: Options
147
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 ] > ;
148
- declare function pAll < Result1 , Result2 , Result3 , Result4 , Result5 > (
149
- tasks : [
150
- PromiseFactory < Result1 > ,
151
- PromiseFactory < Result2 > ,
152
- PromiseFactory < Result3 > ,
153
- PromiseFactory < Result4 > ,
154
- PromiseFactory < Result5 >
155
- ] ,
156
- options ?: Options
157
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 ] > ;
158
- declare function pAll < Result1 , Result2 , Result3 , Result4 > (
159
- tasks : [
160
- PromiseFactory < Result1 > ,
161
- PromiseFactory < Result2 > ,
162
- PromiseFactory < Result3 > ,
163
- PromiseFactory < Result4 >
164
- ] ,
165
- options ?: Options
166
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 ] > ;
167
- declare function pAll < Result1 , Result2 , Result3 > (
168
- tasks : [
169
- PromiseFactory < Result1 > ,
170
- PromiseFactory < Result2 > ,
171
- PromiseFactory < Result3 >
172
- ] ,
173
- options ?: Options
174
- ) : Promise < [ Result1 , Result2 , Result3 ] > ;
175
- declare function pAll < Result1 , Result2 > (
176
- tasks : [ PromiseFactory < Result1 > , PromiseFactory < Result2 > ] ,
177
- options ?: Options
178
- ) : Promise < [ Result1 , Result2 ] > ;
179
- declare function pAll < Result1 > (
180
- tasks : [ PromiseFactory < Result1 > ] ,
181
- options ?: Options
182
- ) : Promise < [ Result1 ] > ;
183
- declare function pAll < TAll > (
184
- tasks : Iterable < PromiseFactory < TAll > > | PromiseFactory < TAll > [ ] ,
185
- options ?: Options
186
- ) : Promise < TAll [ ] > ;
87
+ > (
88
+ tasks : [
89
+ pAll . PromiseFactory < Result1 > ,
90
+ pAll . PromiseFactory < Result2 > ,
91
+ pAll . PromiseFactory < Result3 > ,
92
+ pAll . PromiseFactory < Result4 > ,
93
+ pAll . PromiseFactory < Result5 > ,
94
+ pAll . PromiseFactory < Result6 > ,
95
+ pAll . PromiseFactory < Result7 > ,
96
+ pAll . PromiseFactory < Result8 > ,
97
+ pAll . PromiseFactory < Result9 >
98
+ ] ,
99
+ options ?: pAll . Options
100
+ ) : Promise <
101
+ [
102
+ Result1 ,
103
+ Result2 ,
104
+ Result3 ,
105
+ Result4 ,
106
+ Result5 ,
107
+ Result6 ,
108
+ Result7 ,
109
+ Result8 ,
110
+ Result9
111
+ ]
112
+ > ;
113
+ < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 , Result8 > (
114
+ tasks : [
115
+ pAll . PromiseFactory < Result1 > ,
116
+ pAll . PromiseFactory < Result2 > ,
117
+ pAll . PromiseFactory < Result3 > ,
118
+ pAll . PromiseFactory < Result4 > ,
119
+ pAll . PromiseFactory < Result5 > ,
120
+ pAll . PromiseFactory < Result6 > ,
121
+ pAll . PromiseFactory < Result7 > ,
122
+ pAll . PromiseFactory < Result8 >
123
+ ] ,
124
+ options ?: pAll . Options
125
+ ) : Promise <
126
+ [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 , Result8 ]
127
+ > ;
128
+ < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 > (
129
+ tasks : [
130
+ pAll . PromiseFactory < Result1 > ,
131
+ pAll . PromiseFactory < Result2 > ,
132
+ pAll . PromiseFactory < Result3 > ,
133
+ pAll . PromiseFactory < Result4 > ,
134
+ pAll . PromiseFactory < Result5 > ,
135
+ pAll . PromiseFactory < Result6 > ,
136
+ pAll . PromiseFactory < Result7 >
137
+ ] ,
138
+ options ?: pAll . Options
139
+ ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 ] > ;
140
+ < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 > (
141
+ tasks : [
142
+ pAll . PromiseFactory < Result1 > ,
143
+ pAll . PromiseFactory < Result2 > ,
144
+ pAll . PromiseFactory < Result3 > ,
145
+ pAll . PromiseFactory < Result4 > ,
146
+ pAll . PromiseFactory < Result5 > ,
147
+ pAll . PromiseFactory < Result6 >
148
+ ] ,
149
+ options ?: pAll . Options
150
+ ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 ] > ;
151
+ < Result1 , Result2 , Result3 , Result4 , Result5 > (
152
+ tasks : [
153
+ pAll . PromiseFactory < Result1 > ,
154
+ pAll . PromiseFactory < Result2 > ,
155
+ pAll . PromiseFactory < Result3 > ,
156
+ pAll . PromiseFactory < Result4 > ,
157
+ pAll . PromiseFactory < Result5 >
158
+ ] ,
159
+ options ?: pAll . Options
160
+ ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 ] > ;
161
+ < Result1 , Result2 , Result3 , Result4 > (
162
+ tasks : [
163
+ pAll . PromiseFactory < Result1 > ,
164
+ pAll . PromiseFactory < Result2 > ,
165
+ pAll . PromiseFactory < Result3 > ,
166
+ pAll . PromiseFactory < Result4 >
167
+ ] ,
168
+ options ?: pAll . Options
169
+ ) : Promise < [ Result1 , Result2 , Result3 , Result4 ] > ;
170
+ < Result1 , Result2 , Result3 > (
171
+ tasks : [
172
+ pAll . PromiseFactory < Result1 > ,
173
+ pAll . PromiseFactory < Result2 > ,
174
+ pAll . PromiseFactory < Result3 >
175
+ ] ,
176
+ options ?: pAll . Options
177
+ ) : Promise < [ Result1 , Result2 , Result3 ] > ;
178
+ < Result1 , Result2 > (
179
+ tasks : [ pAll . PromiseFactory < Result1 > , pAll . PromiseFactory < Result2 > ] ,
180
+ options ?: pAll . Options
181
+ ) : Promise < [ Result1 , Result2 ] > ;
182
+ < Result1 > (
183
+ tasks : [ pAll . PromiseFactory < Result1 > ] ,
184
+ options ?: pAll . Options
185
+ ) : Promise < [ Result1 ] > ;
186
+ < TAll > (
187
+ tasks : Iterable < pAll . PromiseFactory < TAll > > | pAll . PromiseFactory < TAll > [ ] ,
188
+ options ?: pAll . Options
189
+ ) : Promise < TAll [ ] > ;
190
+
191
+ // TODO: Remove this for the next major release, refactor the whole definition back to multiple overloaded functions
192
+ default : typeof pAll ;
193
+ } ;
187
194
188
- export default pAll ;
195
+ export = pAll ;
0 commit comments