1 var baseClone = require('./_baseClone'),
2 baseMatches = require('./_baseMatches');
4 /** Used to compose bitmasks for cloning. */
5 var CLONE_DEEP_FLAG = 1;
8 * Creates a function that performs a partial deep comparison between a given
9 * object and `source`, returning `true` if the given object has equivalent
10 * property values, else `false`.
12 * **Note:** The created function is equivalent to `_.isMatch` with `source`
15 * Partial comparisons will match empty array and empty object `source`
16 * values against any array or object value, respectively. See `_.isEqual`
17 * for a list of supported value comparisons.
19 * **Note:** Multiple values can be checked by combining several matchers
26 * @param {Object} source The object of property values to match.
27 * @returns {Function} Returns the new spec function.
31 * { 'a': 1, 'b': 2, 'c': 3 },
32 * { 'a': 4, 'b': 5, 'c': 6 }
35 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
36 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
38 * // Checking for several possible values
39 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })]));
40 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }]
42 function matches(source) {
43 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
46 module.exports = matches;