Groups an array into a Map-based multimap using a key extractor.
Map
Element type.
Key type.
The array to group.
Extracts a key from each element.
A Map grouping elements by key.
Creates N groups, not just two as in a binary partition.
const nums = [1, 2, 3, 4, 5];const parity = partitionToMultimap(nums, (n) => n % 2 === 0 ? "even" : "odd");parity.get("odd"); // [1, 3, 5]parity.get("even"); // [2, 4] Copy
const nums = [1, 2, 3, 4, 5];const parity = partitionToMultimap(nums, (n) => n % 2 === 0 ? "even" : "odd");parity.get("odd"); // [1, 3, 5]parity.get("even"); // [2, 4]
Groups an array into a
Map-based multimap using a key extractor.