Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / equalArrays.js
1 var arraySome = require('./arraySome');
2
3 /**
4  * A specialized version of `baseIsEqualDeep` for arrays with support for
5  * partial deep comparisons.
6  *
7  * @private
8  * @param {Array} array The array to compare.
9  * @param {Array} other The other array to compare.
10  * @param {Function} equalFunc The function to determine equivalents of values.
11  * @param {Function} [customizer] The function to customize comparing arrays.
12  * @param {boolean} [isLoose] Specify performing partial comparisons.
13  * @param {Array} [stackA] Tracks traversed `value` objects.
14  * @param {Array} [stackB] Tracks traversed `other` objects.
15  * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
16  */
17 function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
18   var index = -1,
19       arrLength = array.length,
20       othLength = other.length;
21
22   if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
23     return false;
24   }
25   // Ignore non-index properties.
26   while (++index < arrLength) {
27     var arrValue = array[index],
28         othValue = other[index],
29         result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
30
31     if (result !== undefined) {
32       if (result) {
33         continue;
34       }
35       return false;
36     }
37     // Recursively compare arrays (susceptible to call stack limits).
38     if (isLoose) {
39       if (!arraySome(other, function(othValue) {
40             return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
41           })) {
42         return false;
43       }
44     } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
45       return false;
46     }
47   }
48   return true;
49 }
50
51 module.exports = equalArrays;