import { Reducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { groupBy } = Reducer;
Returns a Reducer
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[]>
.
Examples
Example 1
Example 1
Stream.of(1, 2, 3).groupBy((v) => v % 2)
// => Map {0 => [2], 1 => [1, 3]}