Generates a sequence of groups composed of elements of another sequence which share a common key.
3 by even/odd numbers like this:
var groupBy = ;var sequence = ;var toArray = ;var evenOdd = groupBy;var groups = toArray;var even = groups0;var odd = groups1;var result =evenKey: evenkeyeven: toArrayoddKey: oddkeyodd: toArray;result;
evenKey: 0even: 0 2oddKey: 0odd: 1 3
Group people by their age and project their names like this:
var groupBy = ;var sequence = ;var toArray = ;var people = groupBy;toArray;
'Under 18: true; Alice, Bob''Under 18: false; Chris'
Enumerable: See @kingjs/enumerable.define.
this: The sequence to partition.
keySelector: Selects key common to each group.
elementSelector: Maps an element before inclusion in a group.
resultSelector: Maps a group before returned.
group: Sequence of elements in the group.
Sequence of sub-sequences where each sub-sequence contains elements forming a group. Each group has a
key property whose value was selected by
keySelector and is shared by elements of the group.
With npm installed, run
$ npm install @kingjs/linq.group-by