1 var baseFindKey = require('./_baseFindKey'),
2 baseForOwn = require('./_baseForOwn'),
3 baseIteratee = require('./_baseIteratee');
6 * This method is like `_.find` except that it returns the key of the first
7 * element `predicate` returns truthy for instead of the element itself.
13 * @param {Object} object The object to inspect.
14 * @param {Function} [predicate=_.identity] The function invoked per iteration.
15 * @returns {string|undefined} Returns the key of the matched element,
20 * 'barney': { 'age': 36, 'active': true },
21 * 'fred': { 'age': 40, 'active': false },
22 * 'pebbles': { 'age': 1, 'active': true }
25 * _.findKey(users, function(o) { return o.age < 40; });
26 * // => 'barney' (iteration order is not guaranteed)
28 * // The `_.matches` iteratee shorthand.
29 * _.findKey(users, { 'age': 1, 'active': true });
32 * // The `_.matchesProperty` iteratee shorthand.
33 * _.findKey(users, ['active', false]);
36 * // The `_.property` iteratee shorthand.
37 * _.findKey(users, 'active');
40 function findKey(object, predicate) {
41 return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn);
44 module.exports = findKey;