Object Key Zipping?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Start with the existing zip entry point and compare its behavior with the before and after examples. Review the proposed zipObj behavior, add coverage for object keys and value arrays, and consider missing-value handling; done means the input object produces the demonstrated array of keyed objects.
Written by the indexing model from the issue text.
Description
I didn't find any other requests similar to this, so forgive me if there has been one already.
Underscore supplies a method called zip, which is great. What I'm wanting is the ability to zip objects by their keys.
var before = {
key1: ['val1', 'val2', 'val3'],
key2: ['val4', 'val5', 'val6'],
key3: ['val7', 'val8', 'val9']
};
var after = [
{ key1: "val1", key2: "val4", key3: "val7" },
{ key1: "val2", key2: "val5", key3: "val8" },
{ key1: "val3", key2: "val6", key3: "val9" }
]
I have something working for this, is there any interest in adding functionality like this to the repo? I can submit a PR if needed, just wanted to gauge interest before I start adding tests and getting my code styled correctly.
My first pass at implementation:
var zipObj = function( obj ) {
var keys = Object.keys(obj);
return _.zip.apply(_, keys.map(function(k, i) { return obj[k] || '' }))
.map(function(d) {
var obj = {};
keys.forEach(function(k, i) { obj[k] = d[i] });
return obj;
});
}
- Dominant language
- JavaScript
- Stars
- 622
- Forks
- 114
- PR merge metrics
- No merged PRs in 30d
Contributor 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 helper Open
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
-
bot:ai-assisted component:compact-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
midnightntwrk/midnight-sdk#403 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
DavidAnson/markdownlint-cli2#940 ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Difficulty 2/5 1-3 hours Newbie friendliness 90/100