aaronpowell / linq-in-javascript

An implementation of LINQ in JavaScript use ES6 iterators for proper lazy evaluation
MIT License
81 stars 16 forks source link

GroupBy #3

Open bastienJS opened 9 years ago

bastienJS commented 9 years ago

Hello Aaron,

is it possible for you to implement a new GroupBy function like in .NET => https://msdn.microsoft.com/de-de/library/vstudio/bb534501%28v=vs.100%29.aspx

aaronpowell commented 9 years ago

GroupBy is tricky because it's changing the shape of the data in the return value and it's a multiple-pass of the original data source which isn't possible if it's a chained iterator.

I've done it in the past with just arrays - https://bitbucket.org/aaronpowell/linq-in-javascript/src/68da77525cb444977e16f283f7f42d40487ad697/linqInJavaScript.js?at=default#cl-206 so I'm sure it's possible but not quite sure how best to do it with an interator

bastienJS commented 9 years ago

Maybe this helps? https://github.com/dotnet/corefx/blob/master/src/System.Linq/src/System/Linq/Enumerable.cs

just search for GroupBy :-)