import { StrictEqualityComparer } from "../../shared" ; import { IAsyncParallel , IEqualityComparer , IParallelEnumerable , ParallelGeneratorType } from "../../types" ; import { BasicParallelEnumerable } from "../BasicParallelEnumerable" ; param source param comparer returns export const distinct = < TSource > ( source , comparer = StrictEqualityComparer ) : IParallelEnumerable < TSource > => { const generator = async ( ) => { const distinctElements = [ ] ; for ( const item of await source . toArray ( ) ) { const foundItem = distinctElements . find ( ( x ) => comparer ( x , item ) ) ; if ( ! foundItem ) { distinctElements . push ( item ) ; } } return distinctElements ; } ; return new BasicParallelEnumerable ( { generator , type : ParallelGeneratorType . PromiseToArray , } ) ; } ;