mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Bump to v3.0.0.
This commit is contained in:
32
utility/matches.js
Normal file
32
utility/matches.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import baseMatches from '../internal/baseMatches';
|
||||
|
||||
/**
|
||||
* Creates a function which performs a deep comparison between a given object
|
||||
* and `source`, returning `true` if the given object has equivalent property
|
||||
* values, else `false`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Utility
|
||||
* @param {Object} source The object of property values to match.
|
||||
* @returns {Function} Returns the new function.
|
||||
* @example
|
||||
*
|
||||
* var users = [
|
||||
* { 'user': 'fred', 'age': 40 },
|
||||
* { 'user': 'barney', 'age': 36 }
|
||||
* ];
|
||||
*
|
||||
* var matchesAge = _.matches({ 'age': 36 });
|
||||
*
|
||||
* _.filter(users, matchesAge);
|
||||
* // => [{ 'user': 'barney', 'age': 36 }]
|
||||
*
|
||||
* _.find(users, matchesAge);
|
||||
* // => { 'user': 'barney', 'age': 36 }
|
||||
*/
|
||||
function matches(source) {
|
||||
return baseMatches(source, true);
|
||||
}
|
||||
|
||||
export default matches;
|
||||
Reference in New Issue
Block a user