* A specialized version of `baseIsEqualDeep` for arrays with support for * partial deep comparisons. * * @private * @param {Array} array The array to compare. * @param {Array} other The other array to compare. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more detail
(array, other, bitmask, customizer, equalFunc, stack)
| 28308 | * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. |
| 28309 | */ |
| 28310 | function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { |
| 28311 | var isPartial = bitmask & COMPARE_PARTIAL_FLAG, |
| 28312 | arrLength = array.length, |
| 28313 | othLength = other.length; |
| 28314 | |
| 28315 | if (arrLength != othLength && !(isPartial && othLength > arrLength)) { |
| 28316 | return false; |
| 28317 | } |
| 28318 | // Assume cyclic values are equal. |
| 28319 | var stacked = stack.get(array); |
| 28320 | if (stacked && stack.get(other)) { |
| 28321 | return stacked == other; |
| 28322 | } |
| 28323 | var index = -1, |
| 28324 | result = true, |
| 28325 | seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : undefined; |
| 28326 | |
| 28327 | stack.set(array, other); |
| 28328 | stack.set(other, array); |
| 28329 | |
| 28330 | // Ignore non-index properties. |
| 28331 | while (++index < arrLength) { |
| 28332 | var arrValue = array[index], |
| 28333 | othValue = other[index]; |
| 28334 | |
| 28335 | if (customizer) { |
| 28336 | var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack); |
| 28337 | } |
| 28338 | if (compared !== undefined) { |
| 28339 | if (compared) { |
| 28340 | continue; |
| 28341 | } |
| 28342 | result = false; |
| 28343 | break; |
| 28344 | } |
| 28345 | // Recursively compare arrays (susceptible to call stack limits). |
| 28346 | if (seen) { |
| 28347 | if (!arraySome(other, function (othValue, othIndex) { |
| 28348 | if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { |
| 28349 | return seen.push(othIndex); |
| 28350 | } |
| 28351 | })) { |
| 28352 | result = false; |
| 28353 | break; |
| 28354 | } |
| 28355 | } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { |
| 28356 | result = false; |
| 28357 | break; |
| 28358 | } |
| 28359 | } |
| 28360 | stack['delete'](array); |
| 28361 | stack['delete'](other); |
| 28362 | return result; |
| 28363 | } |
| 28364 | |
| 28365 | module.exports = equalArrays; |
| 28366 |
no test coverage detected