Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / matches.js
1 var baseClone = require('./_baseClone'),
2     baseMatches = require('./_baseMatches');
3
4 /**
5  * Creates a function that performs a partial deep comparison between a given
6  * object and `source`, returning `true` if the given object has equivalent
7  * property values, else `false`.
8  *
9  * **Note:** The created function is equivalent to `_.isMatch` with `source`
10  * partially applied.
11  *
12  * Partial comparisons will match empty array and empty object `source`
13  * values against any array or object value, respectively. See `_.isEqual`
14  * for a list of supported value comparisons.
15  *
16  * @static
17  * @memberOf _
18  * @since 3.0.0
19  * @category Util
20  * @param {Object} source The object of property values to match.
21  * @returns {Function} Returns the new spec function.
22  * @example
23  *
24  * var objects = [
25  *   { 'a': 1, 'b': 2, 'c': 3 },
26  *   { 'a': 4, 'b': 5, 'c': 6 }
27  * ];
28  *
29  * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
30  * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
31  */
32 function matches(source) {
33   return baseMatches(baseClone(source, true));
34 }
35
36 module.exports = matches;