import { IAsyncParallel , IParallelEnumerable , ParallelGeneratorType } from "../../types" ; import { BasicParallelEnumerable } from "../BasicParallelEnumerable" ; param first param second param resultSelector returns export const zipAsync = < TFirst , TSecond , TResult > ( first , second , resultSelector ) : IParallelEnumerable < TResult > => { const generator = async ( ) => { const [ left , right ] = await Promise . all ( [ first . toArray ( ) , second . toArray ( ) ] ) ; const maxLength = left . length > right . length ? left . length : right . length ; const resultPromises = new Array < Promise < TResult > > ( maxLength ) ; for ( let i = 0 ; i < maxLength ; i ++ ) { const a = left [ i ] ; const b = right [ i ] ; resultPromises [ i ] = resultSelector ( a , b ) ; } return Promise . all ( resultPromises ) ; } ; return new BasicParallelEnumerable ( { generator , type : ParallelGeneratorType . PromiseToArray , } ) ; } ;