import { StrictEqualityComparer } from "../../shared" ; import { IEnumerable , IEqualityComparer , SelectorKeyType } from "../../types" ; import { BasicEnumerable } from "../BasicEnumerable" ; import { groupBy_1 , groupBy_1_Simple } from "./groupByShared" ; param source param keySelector param elementSelector param resultSelector param comparer returns export const groupByWithResultAndSelector = < TSource , TKey extends SelectorKeyType , TElement , TResult > ( source , keySelector , elementSelector , resultSelector , comparer ? ) : IEnumerable < TResult > => { if ( comparer ) { return groupBy3 ( source , keySelector as ( x : TSource ) => TKey , elementSelector , resultSelector ) ; } else { return groupBy3Simple ( source , keySelector , elementSelector , resultSelector ) ; } } ; const groupBy3Simple = < TSource , TKey extends SelectorKeyType , TElement , TResult > ( source , keySelector , elementSelector , resultSelector ) => { function * iterator ( ) { const groupByResult = groupBy_1_Simple ( source , keySelector , elementSelector ) ; for ( const group of groupByResult ) { yield resultSelector ( group . key , group ) ; } } return new BasicEnumerable ( iterator ) ; } ; const groupBy3 = < TSource , TKey , TElement , TResult > ( source , keySelector , elementSelector , resultSelector , comparer = StrictEqualityComparer ) => { function * iterator ( ) { const groupByResult = groupBy_1 ( source , keySelector , elementSelector , comparer ) ; for ( const group of groupByResult ) { yield resultSelector ( group . key , group ) ; } } return new BasicEnumerable ( iterator ) ; } ;