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

Function includes

lib/web/jshint.js:8031–8048  ·  view source on GitHub ↗

* Checks if `value` is in `collection` using `SameValueZero` for equality * comparisons. If `fromIndex` is negative, it is used as the offset from * the end of `collection`. * * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)

(collection, target, fromIndex, guard)

Source from the content-addressed store, hash-verified

8029 * // => true
8030 */
8031 function includes(collection, target, fromIndex, guard) {
8032 var length = collection ? getLength(collection) : 0;
8033 if (!isLength(length)) {
8034 collection = values(collection);
8035 length = collection.length;
8036 }
8037 if (!length) {
8038 return false;
8039 }
8040 if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
8041 fromIndex = 0;
8042 } else {
8043 fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
8044 }
8045 return (typeof collection == 'string' || !isArray(collection) && isString(collection))
8046 ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)
8047 : (getIndexOf(collection, target, fromIndex) > -1);
8048 }
8049
8050 /**
8051 * Creates an object composed of keys generated from the results of running

Callers

nothing calls this directly

Calls 7

isLengthFunction · 0.85
valuesFunction · 0.85
isIterateeCallFunction · 0.85
isStringFunction · 0.85
getIndexOfFunction · 0.85
indexOfMethod · 0.80
isArrayFunction · 0.70

Tested by

no test coverage detected