import { IParallelEnumerable } from "../../types" ; import { nextIterationAsync } from "./_nextIterationAsync" ; import { typeDataToArray } from "./_typeDataToArray" ; param source param selector returns export const toObjectAsync = async < TSource , TKey extends keyof any > ( source , selector ) : Promise < Record < TKey , TSource > > => { const dataFunc = nextIterationAsync ( source , async ( value ) => { const key = await selector ( value ) ; return [ key , value ] as [ TKey , TSource ] ; } ) ; const keyValues = await typeDataToArray ( dataFunc ) ; const map = { } ; for ( const [ key , value ] of keyValues ) { map [ key ] = value ; } return map as Record < TKey , TSource > ; } ;