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
903 B
32 lines
903 B
9 years ago
|
var baseClone = require('./_baseClone'),
|
||
|
baseMatchesProperty = require('./_baseMatchesProperty');
|
||
10 years ago
|
|
||
|
/**
|
||
9 years ago
|
* Creates a function that performs a deep partial comparison between the
|
||
|
* value at `path` of a given object to `srcValue`, returning `true` if the
|
||
|
* object value is equivalent, else `false`.
|
||
10 years ago
|
*
|
||
9 years ago
|
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||
10 years ago
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
9 years ago
|
* @category Util
|
||
10 years ago
|
* @param {Array|string} path The path of the property to get.
|
||
|
* @param {*} srcValue The value to match.
|
||
|
* @returns {Function} Returns the new function.
|
||
|
* @example
|
||
|
*
|
||
|
* var users = [
|
||
|
* { 'user': 'barney' },
|
||
|
* { 'user': 'fred' }
|
||
|
* ];
|
||
|
*
|
||
|
* _.find(users, _.matchesProperty('user', 'fred'));
|
||
|
* // => { 'user': 'fred' }
|
||
|
*/
|
||
|
function matchesProperty(path, srcValue) {
|
||
|
return baseMatchesProperty(path, baseClone(srcValue, true));
|
||
|
}
|
||
|
|
||
|
module.exports = matchesProperty;
|