import { IAsyncEnumerable , IAsyncEqualityComparer } from "../../types" ; import { BasicAsyncEnumerable } from "../BasicAsyncEnumerable" ; param first param second param comparer returns export const unionAsync = < TSource > ( first , second , comparer ) : IAsyncEnumerable < TSource > => { async function * iterator ( ) { const result = [ ] ; for ( const source of [ first , second ] ) { for await ( const value of source ) { let exists = false ; for ( const resultValue of result ) { if ( await comparer ( value , resultValue ) === true ) { exists = true ; break ; } } if ( exists === false ) { yield value ; result . push ( value ) ; } } } } return new BasicAsyncEnumerable ( iterator ) ; } ;