Creates a dictionary from a sequence where values are groups of elements keyed by a name common to all members of the group.
If the following people own the following pets
- Alice owns Fluffy
- Alice owns Spike
- Bob owns Tiger
then create a lookup from
- Alice to Fluffy and Spike
- Bob to Tiger
var toLookup = ;var sequence = ;var toArray = ;var lookup = toLookupfor var key in lookuplookupkey = toArray;lookup;
Alice: 'Fluffy' 'Spike'Bob: 'Tiger'
this: Sequence to partition into named sequences.
keySelector: Selects a partition key from an element.
valueSelector: Transforms an element before inclusion in a partition. By default, selects the entire element.
A partitioning of the sequence as a dictionary mapping partition names to partitions.
With npm installed, run
$ npm install @kingjs/linq.to-lookup