MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / contains

Function contains

MathBox/mathbox-bundle.js:38113–38132  ·  view source on GitHub ↗

* Checks if a given value is present in a collection using strict equality * for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the * offset from the end of the collection. * * @static * @memberOf _ * @alias include * @category Collections

(collection, target, fromIndex)

Source from the content-addressed store, hash-verified

38111 * // => true
38112 */
38113 function contains(collection, target, fromIndex) {
38114 var index = -1,
38115 indexOf = getIndexOf(),
38116 length = collection ? collection.length : 0,
38117 result = false;
38118
38119 fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0;
38120 if (isArray(collection)) {
38121 result = indexOf(collection, target, fromIndex) > -1;
38122 } else if (typeof length == 'number') {
38123 result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1;
38124 } else {
38125 forOwn(collection, function(value) {
38126 if (++index >= fromIndex) {
38127 return !(result = value === target);
38128 }
38129 });
38130 }
38131 return result;
38132 }
38133
38134 /**
38135 * Creates an object composed of keys generated from the results of running

Callers

nothing calls this directly

Calls 5

getIndexOfFunction · 0.85
isStringFunction · 0.85
forOwnFunction · 0.85
isArrayFunction · 0.70
indexOfFunction · 0.70

Tested by

no test coverage detected