1 var baseFindIndex = require('./_baseFindIndex'),
2 baseIteratee = require('./_baseIteratee');
5 * This method is like `_.find` except that it returns the index of the first
6 * element `predicate` returns truthy for instead of the element itself.
11 * @param {Array} array The array to search.
12 * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration.
13 * @returns {number} Returns the index of the found element, else `-1`.
17 * { 'user': 'barney', 'active': false },
18 * { 'user': 'fred', 'active': false },
19 * { 'user': 'pebbles', 'active': true }
22 * _.findIndex(users, function(o) { return o.user == 'barney'; });
25 * // The `_.matches` iteratee shorthand.
26 * _.findIndex(users, { 'user': 'fred', 'active': false });
29 * // The `_.matchesProperty` iteratee shorthand.
30 * _.findIndex(users, ['active', false]);
33 * // The `_.property` iteratee shorthand.
34 * _.findIndex(users, 'active');
37 function findIndex(array, predicate) {
38 return (array && array.length)
39 ? baseFindIndex(array, baseIteratee(predicate, 3))
43 module.exports = findIndex;