Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var baseIsMatch = require('../internal/baseIsMatch'),
2
bindCallback = require('../internal/bindCallback'),
3
getMatchData = require('../internal/getMatchData');
4
5
/**
6
* Performs a deep comparison between `object` and `source` to determine if
7
* `object` contains equivalent property values. If `customizer` is provided
8
* it is invoked to compare values. If `customizer` returns `undefined`
9
* comparisons are handled by the method instead. The `customizer` is bound
10
* to `thisArg` and invoked with three arguments: (value, other, index|key).
11
*
12
* **Note:** This method supports comparing properties of arrays, booleans,
13
* `Date` objects, numbers, `Object` objects, regexes, and strings. Functions
14
* and DOM nodes are **not** supported. Provide a customizer function to extend
15
* support for comparing other values.
16
*
17
* @static
18
* @memberOf _
19
* @category Lang
20
* @param {Object} object The object to inspect.
21
* @param {Object} source The object of property values to match.
22
* @param {Function} [customizer] The function to customize value comparisons.
23
* @param {*} [thisArg] The `this` binding of `customizer`.
24
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
25
* @example
26
*
27
* var object = { 'user': 'fred', 'age': 40 };
28
*
29
* _.isMatch(object, { 'age': 40 });
30
* // => true
31
*
32
* _.isMatch(object, { 'age': 36 });
33
* // => false
34
*
35
* // using a customizer callback
36
* var object = { 'greeting': 'hello' };
37
* var source = { 'greeting': 'hi' };
38
*
39
* _.isMatch(object, source, function(value, other) {
40
* return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined;
41
* });
42
* // => true
43
*/
44
function isMatch(object, source, customizer, thisArg) {
45
customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
46
return baseIsMatch(object, getMatchData(source), customizer);
47
}
48
49
module.exports = isMatch;
50
51