File tree Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Expand file tree Collapse file tree 1 file changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -24,10 +24,16 @@ export function mapAsyncIterator<T, U>(
24
24
} ;
25
25
}
26
26
27
- function mapResult ( result : IteratorResult < T , void > ) {
28
- return result . done
29
- ? result
30
- : asyncMapValue ( result . value , callback ) . then ( iteratorResult , abruptClose ) ;
27
+ async function mapResult ( result : IteratorResult < T , void > ) {
28
+ if ( result . done ) {
29
+ return result ;
30
+ }
31
+
32
+ try {
33
+ return { value : await callback ( result . value ) , done : false } ;
34
+ } catch ( callbackError ) {
35
+ return abruptClose ( callbackError ) ;
36
+ }
31
37
}
32
38
33
39
function mapReject ( error : mixed ) {
@@ -60,14 +66,3 @@ export function mapAsyncIterator<T, U>(
60
66
} ,
61
67
} : $FlowFixMe ) ;
62
68
}
63
-
64
- function asyncMapValue < T , U > (
65
- value : T ,
66
- callback : ( T ) => PromiseOrValue < U > ,
67
- ) : Promise < U > {
68
- return new Promise ( ( resolve ) => resolve ( callback ( value ) ) ) ;
69
- }
70
-
71
- function iteratorResult < T > ( value : T ) : IteratorResult < T , void > {
72
- return { value , done : false } ;
73
- }
You can’t perform that action at this time.
0 commit comments