1 var baseMatches = require('../internal/baseMatches'),
2 find = require('./find');
5 * Performs a deep comparison between each element in `collection` and the
6 * source object, returning the first element that has equivalent property
9 * **Note:** This method supports comparing arrays, booleans, `Date` objects,
10 * numbers, `Object` objects, regexes, and strings. Objects are compared by
11 * their own, not inherited, enumerable properties. For comparing a single
12 * own or inherited property value see `_.matchesProperty`.
16 * @category Collection
17 * @param {Array|Object|string} collection The collection to search.
18 * @param {Object} source The object of property values to match.
19 * @returns {*} Returns the matched element, else `undefined`.
23 * { 'user': 'barney', 'age': 36, 'active': true },
24 * { 'user': 'fred', 'age': 40, 'active': false }
27 * _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');
30 * _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');
33 function findWhere(collection, source) {
34 return find(collection, baseMatches(source));
37 module.exports = findWhere;