MCPcopy Index your code
hub / github.com/deployd/deployd / equalArrays

Function equalArrays

test-app/public/sinon.js:16244–16303  ·  view source on GitHub ↗

* 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 bitmas

(array, other, bitmask, customizer, equalFunc, stack)

Source from the content-addressed store, hash-verified

16242 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
16243 */
16244 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
16245 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
16246 arrLength = array.length,
16247 othLength = other.length;
16248
16249 if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
16250 return false;
16251 }
16252 // Assume cyclic values are equal.
16253 var stacked = stack.get(array);
16254 if (stacked && stack.get(other)) {
16255 return stacked == other;
16256 }
16257 var index = -1,
16258 result = true,
16259 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
16260
16261 stack.set(array, other);
16262 stack.set(other, array);
16263
16264 // Ignore non-index properties.
16265 while (++index < arrLength) {
16266 var arrValue = array[index],
16267 othValue = other[index];
16268
16269 if (customizer) {
16270 var compared = isPartial
16271 ? customizer(othValue, arrValue, index, other, array, stack)
16272 : customizer(arrValue, othValue, index, array, other, stack);
16273 }
16274 if (compared !== undefined) {
16275 if (compared) {
16276 continue;
16277 }
16278 result = false;
16279 break;
16280 }
16281 // Recursively compare arrays (susceptible to call stack limits).
16282 if (seen) {
16283 if (!arraySome(other, function(othValue, othIndex) {
16284 if (!cacheHas(seen, othIndex) &&
16285 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
16286 return seen.push(othIndex);
16287 }
16288 })) {
16289 result = false;
16290 break;
16291 }
16292 } else if (!(
16293 arrValue === othValue ||
16294 equalFunc(arrValue, othValue, bitmask, customizer, stack)
16295 )) {
16296 result = false;
16297 break;
16298 }
16299 }
16300 stack['delete'](array);
16301 stack['delete'](other);

Callers 2

baseIsEqualDeepFunction · 0.85
equalByTagFunction · 0.85

Calls 2

arraySomeFunction · 0.85
cacheHasFunction · 0.85

Tested by

no test coverage detected