Extend _.groupBy to support multi-key objects
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- data
Research direction
Start with _.groupBy and the internal group helper described in the issue, then review the existing collection utility behavior. Verify that a collection object returned with multiple keys is included in every corresponding group while single-key behavior remains unchanged; the payload does not name a test file or command.
Written by the indexing model from the issue text.
Description
The current groupBy function only adds each Collection object to the returned hash only once.
In some case one might want to add the same object in multiple groups.
A concrete example is an object having an array property.
Basically this means replacing:
.groupBy = group(function(result, value, key) {
if (.has(result, key)) result[key].push(value); else result[key] = [value];
});
by
function addToGroup(result, value, key) {
if _.isArray(key) { .each(key, function(k) { addToGroup(result, value, k); }); return; }
if (.has(result, key)) result[key].push(value); else result[key] = [value];
});
_.groupBy = group(addToGroup);
I implemented this for my backbone collection as groupByMulti but that is rather cumbersome as I don't have access to the underscore internals, in particular the group function.
- Dominant language
- JavaScript
- Stars
- 622
- Forks
- 114
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from documentcloud/underscore-contrib
-
Boolean helperOpen
Difficulty 3/5 1-2 days Newbie friendliness 38/100
documentcloud/underscore-contrib#254 · 2 comments ·
-
breaking change bug
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
documentcloud/underscore-contrib#252 · 7 comments ·
-
after modules enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
after modules question
Difficulty 5/5 Over a week Newbie friendliness 25/100
documentcloud/underscore-contrib#234 · 1 comment ·
-
after modules docs enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in documentcloud/underscore-contrib
Similar issues
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
githubnext/gh-aw-workshop#3897 ·
Maintainers usually reply within 2 days
-
agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
check:failed feeds:add
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
iptv-org/database#36179 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day