-
-
Notifications
You must be signed in to change notification settings - Fork 941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: improve groupBy #2532
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #2532 +/- ##
=======================================
Coverage 99.56% 99.57%
=======================================
Files 2805 2805
Lines 250097 250126 +29
Branches 1099 1103 +4
=======================================
+ Hits 249018 249054 +36
+ Misses 1051 1044 -7
Partials 28 28
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this missed the point of "grouping" by a key. This function would then break the single responsibility principle.
Note that the following polifills (which this function was inspired by) do not include a value mapper as well:
In the Java world they noticed quite early (Java 8), that there is a need to give the user the ability to also process/transform the value. groupBy(
[
[1, "someValue"],
[2, "blub"],
[1, "anotherone"]
],
(e) => e[0],
(e) => e[1]
); => {
1: ["someValue", "anotherone"],
2: ["blub"]
} I can explain this in more detail in the next team-meeting if you would like to. |
Please add the behaviour to the indended place as #2530 is already merged. I'm fine with keeping the additional utility. |
"Off-topic" question: Should we have tests for our internal function? |
Adds a value mapping function to
groupBy
.Intended for #2530