1 var baseEach = require('../internal/baseEach'),
2 createFind = require('../internal/createFind');
5 * Iterates over elements of `collection`, returning the first element
6 * `predicate` returns truthy for. The predicate is bound to `thisArg` and
7 * invoked with three arguments: (value, index|key, collection).
9 * If a property name is provided for `predicate` the created `_.property`
10 * style callback returns the property value of the given element.
12 * If a value is also provided for `thisArg` the created `_.matchesProperty`
13 * style callback returns `true` for elements that have a matching property
14 * value, else `false`.
16 * If an object is provided for `predicate` the created `_.matches` style
17 * callback returns `true` for elements that have the properties of the given
18 * object, else `false`.
23 * @category Collection
24 * @param {Array|Object|string} collection The collection to search.
25 * @param {Function|Object|string} [predicate=_.identity] The function invoked
27 * @param {*} [thisArg] The `this` binding of `predicate`.
28 * @returns {*} Returns the matched element, else `undefined`.
32 * { 'user': 'barney', 'age': 36, 'active': true },
33 * { 'user': 'fred', 'age': 40, 'active': false },
34 * { 'user': 'pebbles', 'age': 1, 'active': true }
37 * _.result(_.find(users, function(chr) {
38 * return chr.age < 40;
42 * // using the `_.matches` callback shorthand
43 * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
46 * // using the `_.matchesProperty` callback shorthand
47 * _.result(_.find(users, 'active', false), 'user');
50 * // using the `_.property` callback shorthand
51 * _.result(_.find(users, 'active'), 'user');
54 var find = createFind(baseEach);
56 module.exports = find;