@@ -2,6 +2,9 @@ declare namespace pAll {
2
2
type Options = import ( 'p-map' ) . Options ;
3
3
4
4
type PromiseFactory < T > = ( ) => PromiseLike < T > ;
5
+
6
+ // From: https://github.com/microsoft/TypeScript/blob/4f5b3299fee9a54b692aba9df7a9e894bd86e81d/src/lib/es2015.promise.d.ts#L1
7
+ type Awaited < T > = T extends undefined ? T : T extends PromiseLike < infer U > ? U : T ;
5
8
}
6
9
7
10
// TODO: Refactor the whole definition back to multiple overloaded functions
@@ -28,159 +31,9 @@ import got = require('got');
28
31
})();
29
32
```
30
33
*/
31
- declare const pAll : {
32
- <
33
- Result1 ,
34
- Result2 ,
35
- Result3 ,
36
- Result4 ,
37
- Result5 ,
38
- Result6 ,
39
- Result7 ,
40
- Result8 ,
41
- Result9 ,
42
- Result10
43
- > (
44
- tasks : [
45
- pAll . PromiseFactory < Result1 > ,
46
- pAll . PromiseFactory < Result2 > ,
47
- pAll . PromiseFactory < Result3 > ,
48
- pAll . PromiseFactory < Result4 > ,
49
- pAll . PromiseFactory < Result5 > ,
50
- pAll . PromiseFactory < Result6 > ,
51
- pAll . PromiseFactory < Result7 > ,
52
- pAll . PromiseFactory < Result8 > ,
53
- pAll . PromiseFactory < Result9 > ,
54
- pAll . PromiseFactory < Result10 >
55
- ] ,
56
- options ?: pAll . Options
57
- ) : Promise <
58
- [
59
- Result1 ,
60
- Result2 ,
61
- Result3 ,
62
- Result4 ,
63
- Result5 ,
64
- Result6 ,
65
- Result7 ,
66
- Result8 ,
67
- Result9 ,
68
- Result10
69
- ]
70
- > ;
71
- <
72
- Result1 ,
73
- Result2 ,
74
- Result3 ,
75
- Result4 ,
76
- Result5 ,
77
- Result6 ,
78
- Result7 ,
79
- Result8 ,
80
- Result9
81
- > (
82
- tasks : [
83
- pAll . PromiseFactory < Result1 > ,
84
- pAll . PromiseFactory < Result2 > ,
85
- pAll . PromiseFactory < Result3 > ,
86
- pAll . PromiseFactory < Result4 > ,
87
- pAll . PromiseFactory < Result5 > ,
88
- pAll . PromiseFactory < Result6 > ,
89
- pAll . PromiseFactory < Result7 > ,
90
- pAll . PromiseFactory < Result8 > ,
91
- pAll . PromiseFactory < Result9 >
92
- ] ,
93
- options ?: pAll . Options
94
- ) : Promise <
95
- [
96
- Result1 ,
97
- Result2 ,
98
- Result3 ,
99
- Result4 ,
100
- Result5 ,
101
- Result6 ,
102
- Result7 ,
103
- Result8 ,
104
- Result9
105
- ]
106
- > ;
107
- < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 , Result8 > (
108
- tasks : [
109
- pAll . PromiseFactory < Result1 > ,
110
- pAll . PromiseFactory < Result2 > ,
111
- pAll . PromiseFactory < Result3 > ,
112
- pAll . PromiseFactory < Result4 > ,
113
- pAll . PromiseFactory < Result5 > ,
114
- pAll . PromiseFactory < Result6 > ,
115
- pAll . PromiseFactory < Result7 > ,
116
- pAll . PromiseFactory < Result8 >
117
- ] ,
118
- options ?: pAll . Options
119
- ) : Promise <
120
- [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 , Result8 ]
121
- > ;
122
- < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 > (
123
- tasks : [
124
- pAll . PromiseFactory < Result1 > ,
125
- pAll . PromiseFactory < Result2 > ,
126
- pAll . PromiseFactory < Result3 > ,
127
- pAll . PromiseFactory < Result4 > ,
128
- pAll . PromiseFactory < Result5 > ,
129
- pAll . PromiseFactory < Result6 > ,
130
- pAll . PromiseFactory < Result7 >
131
- ] ,
132
- options ?: pAll . Options
133
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 , Result7 ] > ;
134
- < Result1 , Result2 , Result3 , Result4 , Result5 , Result6 > (
135
- tasks : [
136
- pAll . PromiseFactory < Result1 > ,
137
- pAll . PromiseFactory < Result2 > ,
138
- pAll . PromiseFactory < Result3 > ,
139
- pAll . PromiseFactory < Result4 > ,
140
- pAll . PromiseFactory < Result5 > ,
141
- pAll . PromiseFactory < Result6 >
142
- ] ,
143
- options ?: pAll . Options
144
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 , Result6 ] > ;
145
- < Result1 , Result2 , Result3 , Result4 , Result5 > (
146
- tasks : [
147
- pAll . PromiseFactory < Result1 > ,
148
- pAll . PromiseFactory < Result2 > ,
149
- pAll . PromiseFactory < Result3 > ,
150
- pAll . PromiseFactory < Result4 > ,
151
- pAll . PromiseFactory < Result5 >
152
- ] ,
153
- options ?: pAll . Options
154
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 , Result5 ] > ;
155
- < Result1 , Result2 , Result3 , Result4 > (
156
- tasks : [
157
- pAll . PromiseFactory < Result1 > ,
158
- pAll . PromiseFactory < Result2 > ,
159
- pAll . PromiseFactory < Result3 > ,
160
- pAll . PromiseFactory < Result4 >
161
- ] ,
162
- options ?: pAll . Options
163
- ) : Promise < [ Result1 , Result2 , Result3 , Result4 ] > ;
164
- < Result1 , Result2 , Result3 > (
165
- tasks : [
166
- pAll . PromiseFactory < Result1 > ,
167
- pAll . PromiseFactory < Result2 > ,
168
- pAll . PromiseFactory < Result3 >
169
- ] ,
170
- options ?: pAll . Options
171
- ) : Promise < [ Result1 , Result2 , Result3 ] > ;
172
- < Result1 , Result2 > (
173
- tasks : [ pAll . PromiseFactory < Result1 > , pAll . PromiseFactory < Result2 > ] ,
174
- options ?: pAll . Options
175
- ) : Promise < [ Result1 , Result2 ] > ;
176
- < Result1 > (
177
- tasks : [ pAll . PromiseFactory < Result1 > ] ,
178
- options ?: pAll . Options
179
- ) : Promise < [ Result1 ] > ;
180
- < TAll > (
181
- tasks : Iterable < pAll . PromiseFactory < TAll > > | Array < pAll . PromiseFactory < TAll > > ,
182
- options ?: pAll . Options
183
- ) : Promise < TAll [ ] > ;
184
- } ;
34
+ declare const pAll : < Task extends Array < pAll . PromiseFactory < unknown > > > (
35
+ tasks : readonly [ ...Task ] ,
36
+ options ?: pAll . Options ,
37
+ ) => Promise < { [ P in keyof Task ] : Task [ P ] extends ( ) => unknown ? pAll . Awaited < ReturnType < Task [ P ] > > : Task [ P ] } > ;
185
38
186
39
export = pAll ;
0 commit comments