jashkenas / jashkenas/underscore
New function findKeys proposition
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
I'd like to use a function but it seems it's missing. I didn't find any issue for this, and I didn't find it in https://github.com/documentcloud/underscore-contrib (but I'm not sure how to search efficiently here)
function description:
### findKeys
`_.findKeys(object, predicate, [context])`
Returns an array of keys where the predicate truth test passes (or empty array).
`_.findKeys({ a: 1, b: 2, c: 3, d: 2}, function (val, key) {
return val === 2;
})`
` => ["b", "d"]`
`_.findKeys({ a: 1, b: 2, c: 3, d: 2}, function (val, key) {
return val === 4;
})`
` => []`
Am I the only one who would need this ? If not, i can do a PR
Contributor guide
Research direction
No file or test is named in the issue. Start by locating the object-iteration implementation and existing tests, then use the proposed _.findKeys signature and examples as the behavioral specification; done means matching keys are returned in an array and no matches return an empty array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100