import { AsyncReducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { groupBy } = AsyncReducer;
Returns an AsyncReducer
that uses the valueToKey
function to calculate a key for each value, and feeds the tuple of the key and the value to the
collector
reducer. Finally, it returns the output of the collector
. If no collector is given, the default collector will return a JS multimap
of the type Map<K, V[]>
.
type
{ <T, K, R>(valueToKey: (value: T, index: number) => MaybePromise<K>, options: { collector: AsyncReducer.Accept<[K, T], R>; }): AsyncReducer<T, R>; <T, K>(valueToKey: (value: T, index: number) => MaybePromise<K>, options?: { collector?: undefined; }): AsyncReducer<T, Map<K, T[]>>; }
type
{ <T, K, R>(valueToKey: (value: T, index: number) => MaybePromise<K>, options: { collector: AsyncReducer.Accept<[K, T], R>; }): AsyncReducer<T, R>; <T, K>(valueToKey: (value: T, index: number) => MaybePromise<K>, options?: { collector?: undefined; }): AsyncReducer<T, Map<K, T[]>>; }