@@ -4,16 +4,16 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
4
4
* Given an AsyncIterable and a callback function, return an AsyncIterator
5
5
* which produces values mapped via calling the callback function.
6
6
*/
7
- export function mapAsyncIterator < T , U > (
8
- iterable : AsyncIterable < T > | AsyncGenerator < T , void , void > ,
7
+ export function mapAsyncIterator < T , U , R = void > (
8
+ iterable : AsyncGenerator < T , R , void > | AsyncIterable < T > ,
9
9
callback : ( T ) => PromiseOrValue < U > ,
10
- ) : AsyncGenerator < U , void , void > {
10
+ ) : AsyncGenerator < U , R , void > {
11
11
// $FlowIssue[incompatible-use]
12
12
const iterator = iterable [ Symbol . asyncIterator ] ( ) ;
13
13
14
14
async function mapResult (
15
- result : IteratorResult < T , void > ,
16
- ) : Promise < IteratorResult < U , void > > {
15
+ result : IteratorResult < T , R > ,
16
+ ) : Promise < IteratorResult < U , R > > {
17
17
if ( result . done ) {
18
18
return result ;
19
19
}
@@ -37,7 +37,7 @@ export function mapAsyncIterator<T, U>(
37
37
async next ( ) {
38
38
return mapResult ( await iterator . next ( ) ) ;
39
39
} ,
40
- async return ( ) : Promise < IteratorResult < U , void > > {
40
+ async return ( ) : Promise < IteratorResult < U , R > > {
41
41
return typeof iterator . return === 'function'
42
42
? mapResult ( await iterator . return ( ) )
43
43
: { value : undefined , done : true } ;
0 commit comments