diff --git a/lodash.src.js b/lodash.src.js index ee0fa43af..d4f74bd79 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2438,11 +2438,11 @@ * @returns {boolean} Returns `true` if `object` is a match, else `false`. */ function baseIsMatch(object, props, values, strictCompareFlags, customizer) { - var index = -1, - length = props.length, + var length = props.length, + index = length, noCustomizer = !customizer; - while (++index < length) { + while (index--) { if ((noCustomizer && strictCompareFlags[index]) ? values[index] !== object[props[index]] : !(props[index] in object) @@ -2450,22 +2450,20 @@ return false; } } - index = -1; while (++index < length) { var key = props[index], objValue = object[key], srcValue = values[index]; if (noCustomizer && strictCompareFlags[index]) { - var result = objValue !== undefined || (key in object); - } else { - result = customizer ? customizer(objValue, srcValue, key) : undefined; - if (result === undefined) { - result = baseIsEqual(srcValue, objValue, customizer, true); + if (objValue === undefined && !(key in object)) { + return false; + } + } else { + var result = customizer ? customizer(objValue, srcValue, key) : undefined; + if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) { + return false; } - } - if (!result) { - return false; } } return true; @@ -2562,7 +2560,7 @@ } return object[key] === value ? (value !== undefined || (key in object)) - : baseIsEqual(value, object[key], null, true); + : baseIsEqual(value, object[key], undefined, true); }; } @@ -3263,11 +3261,11 @@ customizer = bindCallback(customizer, thisArg, 5); length -= 2; } else { - customizer = typeof thisArg == 'function' ? thisArg : null; + customizer = typeof thisArg == 'function' ? thisArg : undefined; length -= (customizer ? 1 : 0); } if (guard && isIterateeCall(sources[0], sources[1], guard)) { - customizer = length < 3 ? null : customizer; + customizer = length < 3 ? undefined : customizer; length = 1; } while (++index < length) { @@ -3919,40 +3917,32 @@ function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { var index = -1, arrLength = array.length, - othLength = other.length, - result = true; + othLength = other.length; if (arrLength != othLength && !(isLoose && othLength > arrLength)) { return false; } - // Deep compare the contents, ignoring non-numeric properties. - while (result && ++index < arrLength) { + // Ignore non-index properties. + while (++index < arrLength) { var arrValue = array[index], - othValue = other[index]; + othValue = other[index], + result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined; - result = undefined; - if (customizer) { - result = isLoose - ? customizer(othValue, arrValue, index) - : customizer(arrValue, othValue, index); + if (result !== undefined && !result) { + return false; } - if (result === undefined) { - // Recursively compare arrays (susceptible to call stack limits). - if (isLoose) { - var othIndex = othLength; - while (othIndex--) { - othValue = other[othIndex]; - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); - if (result) { - break; - } - } - } else { - result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + // Recursively compare arrays (susceptible to call stack limits). + if (isLoose) { + if (!arraySome(other, function(othValue) { + return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB); + })) { + return false; } + } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) { + return false; } } - return !!result; + return true; } /** @@ -8567,7 +8557,7 @@ customizer = isDeep; isDeep = false; } - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 1) : undefined; return baseClone(value, isDeep, customizer); } @@ -8617,7 +8607,7 @@ * // => 20 */ function cloneDeep(value, customizer, thisArg) { - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 1) : undefined; return baseClone(value, true, customizer); } @@ -8817,7 +8807,7 @@ * // => true */ function isEqual(value, other, customizer, thisArg) { - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; if (!customizer && isStrictComparable(value) && isStrictComparable(other)) { return value === other; } @@ -8976,7 +8966,7 @@ if (object == null) { return false; } - customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); + customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined; object = toObject(object); if (!customizer && length == 1) { var key = props[0],