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.
23 * @param {Object} source The object of property values to match.
24 * @returns {Function} Returns the new spec function.
28 * { 'a': 1, 'b': 2, 'c': 3 },
29 * { 'a': 4, 'b': 5, 'c': 6 }
32 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
33 * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
35 function matches(source) {
36 return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
39 module.exports = matches;