param source param selector returns export const toMap = async < K , V > ( source , selector ) : Promise < Map < K , V [ ] > > => { const map = new Map < K , V [ ] > ( ) ; for await ( const value of source ) { const key = selector ( value ) ; const array = map . get ( key ) ; if ( array === undefined ) { map . set ( key , [ value ] ) ; } else { array . push ( value ) ; } } return map ; } ;