徐总多门店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
800 B

5 months ago
var helperEqualCompare = require('./helperEqualCompare')
var helperDefaultCompare = require('./helperDefaultCompare')
var isFunction = require('./isFunction')
var isUndefined = require('./isUndefined')
/**
* 深度比较两个对象之间的值是否相等使用自定义比较函数
*
* @param {Object} obj1 值1
* @param {Object} obj2 值2
* @param {Function} func 自定义函数
* @return {Boolean}
*/
function isEqualWith (obj1, obj2, func) {
if (isFunction(func)) {
return helperEqualCompare(obj1, obj2, function (v1, v2, key, obj1, obj2) {
var result = func(v1, v2, key, obj1, obj2)
return isUndefined(result) ? helperDefaultCompare(v1, v2) : !!result
}, func)
}
return helperEqualCompare(obj1, obj2, helperDefaultCompare)
}
module.exports = isEqualWith