Files
lodash/matches.js
John-David Dalton 07c844053e Bump to v4.12.0.
2016-05-08 12:23:20 -07:00

33 lines
998 B
JavaScript

import baseClone from './_baseClone';
import baseMatches from './_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 spec 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;