import { AsyncMapper, Mapper } from 'augmentative-iterable'; import { AsyncKVGroupTransform, FluentGroup, KVGroupTransform } from '../base'; import { FluentAsyncIterable, FluentIterable } from '../base'; export interface GroupFunction { /** * Groups the elements of the iterable keyed by equality of data at the specified projection.
* Example: `fluent(['anchor', 'almond', 'bound', 'alpine']).group(word => word[0])` yields { key: 'a', values: ['anchor', 'almond', 'alpine'] } and { key: 'b', values: ['bound'] }. * @typeparam R The type of the groups' key. * @param mapper Projects the elements of the iterable into the group key they belong to. * @param transformValue Optional. Allows a transformation before adding the value to the group. The return must be an iterable * @returns The [[FluentIterable]] of the distinct groups. */ (mapper: Mapper, transformValue?: KVGroupTransform): FluentIterable>; /** * Groups the elements of the iterable keyed by equality of data at the specified projection.
* Example: `fluent(['anchor', 'almond', 'bound', 'alpine']).group(word => word[0])` yields { key: 'a', values: ['anchor', 'almond', 'alpine'] } and { key: 'b', values: ['bound'] }. * @typeparam R The type of the groups' key. * @param mapper Projects the elements of the iterable into the group key they belong to. * @param transformValue Optional. Allows a transformation before adding the value to the group. The return must be an iterable * @returns The [[FluentIterable]] of the distinct groups. */ (mapper: R, transformValue?: KVGroupTransform): FluentIterable>; } export interface AsyncGroupFunction { /** * Groups the elements of the iterable keyed by equality of data at the specified asynchronous projection. * @typeparam R The type of the groups key. * @param mapper Asynchronously projects the elements of the iterable into the group key they belong to. * @param transformValue Optional. Allows a transformation before adding the value to the group. The return must be an iterable or AsyncIterable * @returns The [[FluentAsyncIterable]] of the distinct groups. */ (mapper: AsyncMapper, transformValue?: AsyncKVGroupTransform): FluentAsyncIterable>; /** * Groups the elements of the iterable keyed by equality of data at the specified asynchronous projection. * @typeparam R The type of the groups key. * @param mapper A property name with value will be used as for comparison with the grouping key * @param transformValue Optional. Allows a transformation before adding the value to the group. The return must be an iterable or AsyncIterable * @returns The [[FluentAsyncIterable]] of the distinct groups. */ (mapper: R, transformValue?: AsyncKVGroupTransform): FluentAsyncIterable>; }