UNPKG

965 BJavaScriptView Raw
1import baseIsMatch from './_baseIsMatch';
2import getMatchData from './_getMatchData';
3
4/**
5 * Performs a partial deep comparison between `object` and `source` to
6 * determine if `object` contains equivalent property values. This method is
7 * equivalent to a `_.matches` function when `source` is partially applied.
8 *
9 * **Note:** This method supports comparing the same values as `_.isEqual`.
10 *
11 * @static
12 * @memberOf _
13 * @since 3.0.0
14 * @category Lang
15 * @param {Object} object The object to inspect.
16 * @param {Object} source The object of property values to match.
17 * @returns {boolean} Returns `true` if `object` is a match, else `false`.
18 * @example
19 *
20 * var object = { 'user': 'fred', 'age': 40 };
21 *
22 * _.isMatch(object, { 'age': 40 });
23 * // => true
24 *
25 * _.isMatch(object, { 'age': 36 });
26 * // => false
27 */
28function isMatch(object, source) {
29 return object === source || baseIsMatch(object, source, getMatchData(source));
30}
31
32export default isMatch;