mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1001 B
32 lines
1001 B
var baseClone = require('./_baseClone'),
|
|
baseMatches = require('./_baseMatches');
|
|
|
|
/**
|
|
* Creates a function that performs a partial deep comparison between a given
|
|
* object and `source`, returning `true` if the given object has equivalent
|
|
* property values, else `false`. The created function is equivalent to
|
|
* `_.isMatch` with a `source` partially applied.
|
|
*
|
|
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @since 3.0.0
|
|
* @category Util
|
|
* @param {Object} source The object of property values to match.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var users = [
|
|
* { 'user': 'barney', 'age': 36, 'active': true },
|
|
* { 'user': 'fred', 'age': 40, 'active': false }
|
|
* ];
|
|
*
|
|
* _.filter(users, _.matches({ 'age': 40, 'active': false }));
|
|
* // => [{ 'user': 'fred', 'age': 40, 'active': false }]
|
|
*/
|
|
function matches(source) {
|
|
return baseMatches(baseClone(source, true));
|
|
}
|
|
|
|
module.exports = matches;
|
|
|