import { IAsyncEqualityComparer , IAsyncParallel , IParallelEnumerable , ParallelGeneratorType } from "../../types" ; import { BasicParallelEnumerable } from "../BasicParallelEnumerable" ; param first param second param comparer returns export const unionAsync = < TSource > ( first , second , comparer ) : IParallelEnumerable < TSource > => { const generator = async ( ) => { const result = [ ] ; const values = await Promise . all ( [ first . toArray ( ) , second . toArray ( ) ] ) ; for ( const source of values ) { for ( const value of source ) { let exists = false ; for ( const resultValue of result ) { if ( await comparer ( value , resultValue ) === true ) { exists = true ; break ; } } if ( exists === false ) { result . push ( value ) ; } } } return result ; } ; return new BasicParallelEnumerable ( { generator , type : ParallelGeneratorType . PromiseToArray , } ) ; } ;