mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Bump to v3.0.0.
This commit is contained in:
28
collection/findLast.js
Normal file
28
collection/findLast.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import baseCallback from '../internal/baseCallback';
|
||||
import baseEachRight from '../internal/baseEachRight';
|
||||
import baseFind from '../internal/baseFind';
|
||||
|
||||
/**
|
||||
* This method is like `_.find` except that it iterates over elements of
|
||||
* `collection` from right to left.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Collection
|
||||
* @param {Array|Object|string} collection The collection to search.
|
||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
||||
* per iteration. If a property name or object is provided it is used to
|
||||
* create a "_.property" or "_.matches" style callback respectively.
|
||||
* @param {*} [thisArg] The `this` binding of `predicate`.
|
||||
* @returns {*} Returns the matched element, else `undefined`.
|
||||
* @example
|
||||
*
|
||||
* _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; });
|
||||
* // => 3
|
||||
*/
|
||||
function findLast(collection, predicate, thisArg) {
|
||||
predicate = baseCallback(predicate, thisArg, 3);
|
||||
return baseFind(collection, predicate, baseEachRight);
|
||||
}
|
||||
|
||||
export default findLast;
|
||||
Reference in New Issue
Block a user