import { StrictEqualityComparer } from "../../shared" ; import { IEnumerable , IEqualityComparer } from "../../types" ; import { BasicEnumerable } from "../BasicEnumerable" ; param source param comparer returns export const distinct = < TSource > ( source , comparer = StrictEqualityComparer ) : IEnumerable < TSource > => { function * iterator ( ) { const distinctElements = [ ] ; for ( const item of source ) { const foundItem = distinctElements . find ( ( x ) => comparer ( x , item ) ) ; if ( ! foundItem ) { distinctElements . push ( item ) ; yield item ; } } } return new BasicEnumerable ( iterator ) ; } ;