82c30de997729930fd9329d9e2c58dbddf8cd6aa
[yaffs-website] / node_modules / uncss / node_modules / lodash / findLastKey.js
1 var baseFind = require('./internal/baseFind'),
2     baseForOwnRight = require('./internal/baseForOwnRight'),
3     baseIteratee = require('./internal/baseIteratee');
4
5 /**
6  * This method is like `_.findKey` except that it iterates over elements of
7  * a collection in the opposite order.
8  *
9  * @static
10  * @memberOf _
11  * @category Object
12  * @param {Object} object The object to search.
13  * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
14  * @returns {string|undefined} Returns the key of the matched element, else `undefined`.
15  * @example
16  *
17  * var users = {
18  *   'barney':  { 'age': 36, 'active': true },
19  *   'fred':    { 'age': 40, 'active': false },
20  *   'pebbles': { 'age': 1,  'active': true }
21  * };
22  *
23  * _.findLastKey(users, function(o) { return o.age < 40; });
24  * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
25  *
26  * // using the `_.matches` iteratee shorthand
27  * _.findLastKey(users, { 'age': 36, 'active': true });
28  * // => 'barney'
29  *
30  * // using the `_.matchesProperty` iteratee shorthand
31  * _.findLastKey(users, ['active', false]);
32  * // => 'fred'
33  *
34  * // using the `_.property` iteratee shorthand
35  * _.findLastKey(users, 'active');
36  * // => 'pebbles'
37  */
38 function findLastKey(object, predicate) {
39   return baseFind(object, baseIteratee(predicate, 3), baseForOwnRight, true);
40 }
41
42 module.exports = findLastKey;