1 var baseMatches = require('../internal/baseMatches'),
2 filter = require('./filter');
5 * Performs a deep comparison between each element in `collection` and the
6 * source object, returning an array of all elements that have equivalent
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 {Array} Returns the new filtered array.
23 * { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
24 * { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
27 * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
30 * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');
33 function where(collection, source) {
34 return filter(collection, baseMatches(source));
37 module.exports = where;