@@ -7,7 +7,9 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
7
7
export function mapAsyncIterator < T , U > (
8
8
iterable : AsyncIterable < T > | AsyncGenerator < T , void , void > ,
9
9
callback : ( T ) => PromiseOrValue < U > ,
10
- rejectCallback ?: ( any ) => PromiseOrValue < U > ,
10
+ rejectCallback : ( any ) => PromiseOrValue < U > = ( error ) => {
11
+ throw error ;
12
+ } ,
11
13
) : AsyncGenerator < U , void , void > {
12
14
// $FlowFixMe[prop-missing]
13
15
const iteratorMethod = iterable [ Symbol . asyncIterator ] ;
@@ -28,12 +30,11 @@ export function mapAsyncIterator<T, U>(
28
30
: asyncMapValue ( result . value , callback ) . then ( iteratorResult , abruptClose ) ;
29
31
}
30
32
31
- let mapReject ;
32
- if ( rejectCallback ) {
33
- // Capture rejectCallback to ensure it cannot be null.
34
- const reject = rejectCallback ;
35
- mapReject = ( error : mixed ) =>
36
- asyncMapValue ( error , reject ) . then ( iteratorResult , abruptClose ) ;
33
+ function mapReject ( error : mixed ) {
34
+ return asyncMapValue ( error , rejectCallback ) . then (
35
+ iteratorResult ,
36
+ abruptClose ,
37
+ ) ;
37
38
}
38
39
39
40
/* TODO: Flow doesn't support symbols as keys:
0 commit comments