import { IEnumerable , IEqualityComparer , IGrouping , SelectorKeyType } from "../../types" ; import { BasicEnumerable } from "../BasicEnumerable" ; import { groupBy_0 , groupBy_0_Simple } from "./groupByShared" ; type GroupByFunc = { param source param keySelector returns < TSource , TKey extends SelectorKeyType > ( source , keySelector ) : IEnumerable < IGrouping < TKey , TSource > > ; param source param keySelector param comparer < TSource , TKey > ( source , keySelector , comparer ) : IEnumerable < IGrouping < TKey , TSource > > ; } ; export const groupBy = < TSource , TKey > ( source , keySelector , comparer ? ) : IEnumerable < IGrouping < ReturnType < typeof keySelector > , TSource > > => { let iterable ; if ( comparer ) { iterable = groupBy_0 < TSource , TKey > ( source , keySelector as ( x : TSource ) => TKey , comparer ) ; } else { iterable = groupBy_0_Simple ( source , keySelector as ( x : TSource ) => SelectorKeyType ) ; } return new BasicEnumerable ( iterable ) ; } ;