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

Function baseDifference

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

* The base implementation of methods like `_.difference` without support * for excluding multiple arrays or iteratee shorthands. * * @private * @param {Array} array The array to inspect. * @param {Array} values The values to exclude. * @param {Fu

(array, values, iteratee, comparator)

Source from the content-addressed store, hash-verified

13393 * @returns {Array} Returns the new array of filtered values.
13394 */
13395 function baseDifference(array, values, iteratee, comparator) {
13396 var index = -1,
13397 includes = arrayIncludes,
13398 isCommon = true,
13399 length = array.length,
13400 result = [],
13401 valuesLength = values.length;
13402
13403 if (!length) {
13404 return result;
13405 }
13406 if (iteratee) {
13407 values = arrayMap(values, baseUnary(iteratee));
13408 }
13409 if (comparator) {
13410 includes = arrayIncludesWith;
13411 isCommon = false;
13412 }
13413 else if (values.length >= LARGE_ARRAY_SIZE) {
13414 includes = cacheHas;
13415 isCommon = false;
13416 values = new SetCache(values);
13417 }
13418 outer:
13419 while (++index < length) {
13420 var value = array[index],
13421 computed = iteratee == null ? value : iteratee(value);
13422
13423 value = (comparator || value !== 0) ? value : 0;
13424 if (isCommon && computed === computed) {
13425 var valuesIndex = valuesLength;
13426 while (valuesIndex--) {
13427 if (values[valuesIndex] === computed) {
13428 continue outer;
13429 }
13430 }
13431 result.push(value);
13432 }
13433 else if (!includes(values, computed, comparator)) {
13434 result.push(value);
13435 }
13436 }
13437 return result;
13438 }
13439
13440 /**
13441 * The base implementation of `_.forEach` without support for iteratee shorthands.

Callers 2

baseXorFunction · 0.85
sinon.jsFile · 0.85

Calls 4

arrayMapFunction · 0.85
baseUnaryFunction · 0.85
iterateeFunction · 0.85
includesFunction · 0.85

Tested by

no test coverage detected