1
|
var baseIsMatch = require('./_baseIsMatch'),
|
2
|
getMatchData = require('./_getMatchData');
|
3
|
|
4
|
/**
|
5
|
* This method is like `_.isMatch` except that it accepts `customizer` which
|
6
|
* is invoked to compare values. If `customizer` returns `undefined`, comparisons
|
7
|
* are handled by the method instead. The `customizer` is invoked with five
|
8
|
* arguments: (objValue, srcValue, index|key, object, source).
|
9
|
*
|
10
|
* @static
|
11
|
* @memberOf _
|
12
|
* @since 4.0.0
|
13
|
* @category Lang
|
14
|
* @param {Object} object The object to inspect.
|
15
|
* @param {Object} source The object of property values to match.
|
16
|
* @param {Function} [customizer] The function to customize comparisons.
|
17
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
18
|
* @example
|
19
|
*
|
20
|
* function isGreeting(value) {
|
21
|
* return /^h(?:i|ello)$/.test(value);
|
22
|
* }
|
23
|
*
|
24
|
* function customizer(objValue, srcValue) {
|
25
|
* if (isGreeting(objValue) && isGreeting(srcValue)) {
|
26
|
* return true;
|
27
|
* }
|
28
|
* }
|
29
|
*
|
30
|
* var object = { 'greeting': 'hello' };
|
31
|
* var source = { 'greeting': 'hi' };
|
32
|
*
|
33
|
* _.isMatchWith(object, source, customizer);
|
34
|
* // => true
|
35
|
*/
|
36
|
function isMatchWith(object, source, customizer) {
|
37
|
customizer = typeof customizer == 'function' ? customizer : undefined;
|
38
|
return baseIsMatch(object, source, getMatchData(source), customizer);
|
39
|
}
|
40
|
|
41
|
module.exports = isMatchWith;
|