source: imaps-frontend/node_modules/lodash-es/findKey.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import baseFindKey from './_baseFindKey.js';
2import baseForOwn from './_baseForOwn.js';
3import baseIteratee from './_baseIteratee.js';
4
5/**
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.
8 *
9 * @static
10 * @memberOf _
11 * @since 1.1.0
12 * @category Object
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,
16 * else `undefined`.
17 * @example
18 *
19 * var users = {
20 * 'barney': { 'age': 36, 'active': true },
21 * 'fred': { 'age': 40, 'active': false },
22 * 'pebbles': { 'age': 1, 'active': true }
23 * };
24 *
25 * _.findKey(users, function(o) { return o.age < 40; });
26 * // => 'barney' (iteration order is not guaranteed)
27 *
28 * // The `_.matches` iteratee shorthand.
29 * _.findKey(users, { 'age': 1, 'active': true });
30 * // => 'pebbles'
31 *
32 * // The `_.matchesProperty` iteratee shorthand.
33 * _.findKey(users, ['active', false]);
34 * // => 'fred'
35 *
36 * // The `_.property` iteratee shorthand.
37 * _.findKey(users, 'active');
38 * // => 'barney'
39 */
40function findKey(object, predicate) {
41 return baseFindKey(object, baseIteratee(predicate, 3), baseForOwn);
42}
43
44export default findKey;
Note: See TracBrowser for help on using the repository browser.