react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / object / findKey.js
80742 viewsvar baseForOwn = require('../internal/baseForOwn'),1createFindKey = require('../internal/createFindKey');23/**4* This method is like `_.find` except that it returns the key of the first5* element `predicate` returns truthy for instead of the element itself.6*7* If a property name is provided for `predicate` the created `_.property`8* style callback returns the property value of the given element.9*10* If a value is also provided for `thisArg` the created `_.matchesProperty`11* style callback returns `true` for elements that have a matching property12* value, else `false`.13*14* If an object is provided for `predicate` the created `_.matches` style15* callback returns `true` for elements that have the properties of the given16* object, else `false`.17*18* @static19* @memberOf _20* @category Object21* @param {Object} object The object to search.22* @param {Function|Object|string} [predicate=_.identity] The function invoked23* per iteration.24* @param {*} [thisArg] The `this` binding of `predicate`.25* @returns {string|undefined} Returns the key of the matched element, else `undefined`.26* @example27*28* var users = {29* 'barney': { 'age': 36, 'active': true },30* 'fred': { 'age': 40, 'active': false },31* 'pebbles': { 'age': 1, 'active': true }32* };33*34* _.findKey(users, function(chr) {35* return chr.age < 40;36* });37* // => 'barney' (iteration order is not guaranteed)38*39* // using the `_.matches` callback shorthand40* _.findKey(users, { 'age': 1, 'active': true });41* // => 'pebbles'42*43* // using the `_.matchesProperty` callback shorthand44* _.findKey(users, 'active', false);45* // => 'fred'46*47* // using the `_.property` callback shorthand48* _.findKey(users, 'active');49* // => 'barney'50*/51var findKey = createFindKey(baseForOwn);5253module.exports = findKey;545556