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