Skip to content

New function findKeys proposition #2676

Open
@FabriceGaudin

Description

@FabriceGaudin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    contribprobably belongs in Underscore-contribenhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions