1var baseClone = require('../internal/baseClone'), 2 baseMatches = require('../internal/baseMatches'); 3 4/** 5 * Creates a function that performs a deep comparison between a given object 6 * and `source`, returning `true` if the given object has equivalent property 7 * values, else `false`. 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 Utility 17 * @param {Object} source The object of property values to match. 18 * @returns {Function} Returns the new function. 19 * @example 20 * 21 * var users = [ 22 * { 'user': 'barney', 'age': 36, 'active': true }, 23 * { 'user': 'fred', 'age': 40, 'active': false } 24 * ]; 25 * 26 * _.filter(users, _.matches({ 'age': 40, 'active': false })); 27 * // => [{ 'user': 'fred', 'age': 40, 'active': false }] 28 */ 29function matches(source) { 30 return baseMatches(baseClone(source, true)); 31} 32 33module.exports = matches; 34 35