@@ -4,16 +4,16 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
44 * Given an AsyncIterable and a callback function, return an AsyncIterator
55 * which produces values mapped via calling the callback function.
66 */
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 > ,
99 callback : ( T ) => PromiseOrValue < U > ,
10- ) : AsyncGenerator < U , void , void > {
10+ ) : AsyncGenerator < U , R , void > {
1111 // $FlowIssue[incompatible-use]
1212 const iterator = iterable [ Symbol . asyncIterator ] ( ) ;
1313
1414 async function mapResult (
15- result : IteratorResult < T , void > ,
16- ) : Promise < IteratorResult < U , void > > {
15+ result : IteratorResult < T , R > ,
16+ ) : Promise < IteratorResult < U , R > > {
1717 if ( result . done ) {
1818 return result ;
1919 }
@@ -37,7 +37,7 @@ export function mapAsyncIterator<T, U>(
3737 async next ( ) {
3838 return mapResult ( await iterator . next ( ) ) ;
3939 } ,
40- async return ( ) : Promise < IteratorResult < U , void > > {
40+ async return ( ) : Promise < IteratorResult < U , R > > {
4141 return typeof iterator . return === 'function'
4242 ? mapResult ( await iterator . return ( ) )
4343 : { value : undefined , done : true } ;
0 commit comments