mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Bump to v3.2.0.
This commit is contained in:
33
utility/matchesProperty.js
Normal file
33
utility/matchesProperty.js
Normal file
@@ -0,0 +1,33 @@
|
||||
define(['../internal/baseClone', '../internal/baseMatchesProperty'], function(baseClone, baseMatchesProperty) {
|
||||
|
||||
/**
|
||||
* Creates a function which compares the property value of `key` on a given
|
||||
* object to `value`.
|
||||
*
|
||||
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
|
||||
* numbers, `Object` objects, regexes, and strings. Objects are compared by
|
||||
* their own, not inherited, enumerable properties.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {string} key The key of the property to get.
|
||||
* @param {*} value The value to compare.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'barney' },
|
||||
* { 'user': 'fred' },
|
||||
* { 'user': 'pebbles' }
|
||||
* ];
|
||||
*
|
||||
* _.find(users, _.matchesProperty('user', 'fred'));
|
||||
* // => { 'user': 'fred', 'age': 40 }
|
||||
*/
|
||||
function matchesProperty(key, value) {
|
||||
return baseMatchesProperty(key + '', baseClone(value, true));
|
||||
}
|
||||
|
||||
return matchesProperty;
|
||||
});
|
||||
Reference in New Issue
Block a user