Open SamMousa opened 7 years ago
I was looking for a way to make GeneratorCollection a fluent interface, but did not find a good way yet, as it is returning a generator via yield. Thanks for the suggestion, will look into that.
I think the gold standard for collections is Laravel Collections, which have been working great for me.
Probably a good idea to use that as inspiration.
Framework agnostic laravel collections
They are not iterables though, so each operation duplicates memory usage (I think after a quick check from my phone)
i have a question, dose chaining mathod in this way and the way laravel does for collections now is the right way? because i think chaining method this way make extra loop in a chain of methods and mayby decrease performance, and mayby cause some impure functions as i see in other places like in some functions of ruby lang in a chain of functions on an object.
GeneratorCollection currently uses yield
which does not allow method chaining. Collection allows method chaining but is not efficient as it may do multiple cycles over an array. The purpose of this issue is to evaluate ways to enable method chaning with generators.
The current implementation of
GeneratorCollection
supports functions likefilter
andmap
.Doing something like I've proposed here: https://github.com/nikic/iter/issues/45 Would allow for a fluent interface allowing code like