Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / collection / where.js
1 var baseMatches = require('../internal/baseMatches'),
2     filter = require('./filter');
3
4 /**
5  * Performs a deep comparison between each element in `collection` and the
6  * source object, returning an array of all elements that have equivalent
7  * property values.
8  *
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`.
13  *
14  * @static
15  * @memberOf _
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.
20  * @example
21  *
22  * var users = [
23  *   { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
24  *   { 'user': 'fred',   'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
25  * ];
26  *
27  * _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
28  * // => ['barney']
29  *
30  * _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');
31  * // => ['fred']
32  */
33 function where(collection, source) {
34   return filter(collection, baseMatches(source));
35 }
36
37 module.exports = where;