import { asyncIterable } from '../utils/asyncIterable' ; export function distinct < TElement , TKey > ( source , keySelector ) { return asyncIterable ( async function * ( ) { const set = new Set < TKey > ( ) ; for await ( const element of source ) { const key = keySelector ( element ) ; if ( ! set . has ( key ) ) { set . add ( key ) ; yield await element ; } } } ) ; }