1 var baseEachRight = require('./_baseEachRight'),
2 baseFind = require('./_baseFind'),
3 baseFindIndex = require('./_baseFindIndex'),
4 baseIteratee = require('./_baseIteratee'),
5 isArray = require('./isArray');
8 * This method is like `_.find` except that it iterates over elements of
9 * `collection` from right to left.
13 * @category Collection
14 * @param {Array|Object} collection The collection to search.
15 * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
16 * @returns {*} Returns the matched element, else `undefined`.
19 * _.findLast([1, 2, 3, 4], function(n) {
24 function findLast(collection, predicate) {
25 predicate = baseIteratee(predicate, 3);
26 if (isArray(collection)) {
27 var index = baseFindIndex(collection, predicate, true);
28 return index > -1 ? collection[index] : undefined;
30 return baseFind(collection, predicate, baseEachRight);
33 module.exports = findLast;