MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / intersection

Function intersection

lib/web/jshint.js:6564–6607  ·  view source on GitHub ↗

* Creates an array of unique values in all provided arrays using `SameValueZero` * for equality comparisons. * * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) * comparisons are like strict equality comparisons, e.g. `===`, ex

()

Source from the content-addressed store, hash-verified

6562 * // => [2]
6563 */
6564 function intersection() {
6565 var args = [],
6566 argsIndex = -1,
6567 argsLength = arguments.length,
6568 caches = [],
6569 indexOf = getIndexOf(),
6570 isCommon = indexOf == baseIndexOf,
6571 result = [];
6572
6573 while (++argsIndex < argsLength) {
6574 var value = arguments[argsIndex];
6575 if (isArray(value) || isArguments(value)) {
6576 args.push(value);
6577 caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
6578 }
6579 }
6580 argsLength = args.length;
6581 if (argsLength < 2) {
6582 return result;
6583 }
6584 var array = args[0],
6585 index = -1,
6586 length = array ? array.length : 0,
6587 seen = caches[0];
6588
6589 outer:
6590 while (++index < length) {
6591 value = array[index];
6592 if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
6593 argsIndex = argsLength;
6594 while (--argsIndex) {
6595 var cache = caches[argsIndex];
6596 if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) {
6597 continue outer;
6598 }
6599 }
6600 if (seen) {
6601 seen.push(value);
6602 }
6603 result.push(value);
6604 }
6605 }
6606 return result;
6607 }
6608
6609 /**
6610 * Gets the last element of `array`.

Callers

nothing calls this directly

Calls 6

getIndexOfFunction · 0.85
isArgumentsFunction · 0.85
cacheIndexOfFunction · 0.85
isArrayFunction · 0.70
indexOfFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected