Security update to Drupal 8.4.6
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / _equalArrays.js
1 var arraySome = require('./_arraySome');
2
3 /** Used to compose bitmasks for comparison styles. */
4 var UNORDERED_COMPARE_FLAG = 1,
5     PARTIAL_COMPARE_FLAG = 2;
6
7 /**
8  * A specialized version of `baseIsEqualDeep` for arrays with support for
9  * partial deep comparisons.
10  *
11  * @private
12  * @param {Array} array The array to compare.
13  * @param {Array} other The other array to compare.
14  * @param {Function} equalFunc The function to determine equivalents of values.
15  * @param {Function} [customizer] The function to customize comparisons.
16  * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details.
17  * @param {Object} [stack] Tracks traversed `array` and `other` objects.
18  * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
19  */
20 function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
21   var index = -1,
22       isPartial = bitmask & PARTIAL_COMPARE_FLAG,
23       isUnordered = bitmask & UNORDERED_COMPARE_FLAG,
24       arrLength = array.length,
25       othLength = other.length;
26
27   if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
28     return false;
29   }
30   // Assume cyclic values are equal.
31   var stacked = stack.get(array);
32   if (stacked) {
33     return stacked == other;
34   }
35   var result = true;
36   stack.set(array, other);
37
38   // Ignore non-index properties.
39   while (++index < arrLength) {
40     var arrValue = array[index],
41         othValue = other[index];
42
43     if (customizer) {
44       var compared = isPartial
45         ? customizer(othValue, arrValue, index, other, array, stack)
46         : customizer(arrValue, othValue, index, array, other, stack);
47     }
48     if (compared !== undefined) {
49       if (compared) {
50         continue;
51       }
52       result = false;
53       break;
54     }
55     // Recursively compare arrays (susceptible to call stack limits).
56     if (isUnordered) {
57       if (!arraySome(other, function(othValue) {
58             return arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack);
59           })) {
60         result = false;
61         break;
62       }
63     } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
64       result = false;
65       break;
66     }
67   }
68   stack['delete'](array);
69   return result;
70 }
71
72 module.exports = equalArrays;