mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Bump to v4.0.0.
This commit is contained in:
30
matches.js
Normal file
30
matches.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import baseClone from './internal/baseClone';
|
||||
import baseMatches from './internal/baseMatches';
|
||||
|
||||
/**
|
||||
* Creates a function that performs a deep partial comparison between a given
|
||||
* object and `source`, returning `true` if the given object has equivalent
|
||||
* property values, else `false`.
|
||||
*
|
||||
* **Note:** This method supports comparing the same values as `_.isEqual`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @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));
|
||||
}
|
||||
|
||||
export default matches;
|
||||
Reference in New Issue
Block a user