CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
includes.js54 linesDownload Raw Back to lodash
1var baseIndexOf = require('./_baseIndexOf'),2    isArrayLike = require('./isArrayLike'),3    isString = require('./isString'),4    toInteger = require('./toInteger'),5    values = require('./values');6 7/* Built-in method references for those with the same name as other `lodash` methods. */8var nativeMax = Math.max;9 10/**11 * Checks if `value` is in `collection`. If `collection` is a string, it's12 * checked for a substring of `value`, otherwise13 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)14 * is used for equality comparisons. If `fromIndex` is negative, it's used as15 * the offset from the end of `collection`.16 *17 * @static18 * @memberOf _19 * @since 0.1.020 * @category Collection21 * @param {Array|Object|string} collection The collection to inspect.22 * @param {*} value The value to search for.23 * @param {number} [fromIndex=0] The index to search from.24 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.25 * @returns {boolean} Returns `true` if `value` is found, else `false`.26 * @example27 *28 * _.includes([1, 2, 3], 1);29 * // => true30 *31 * _.includes([1, 2, 3], 1, 2);32 * // => false33 *34 * _.includes({ 'a': 1, 'b': 2 }, 1);35 * // => true36 *37 * _.includes('abcd', 'bc');38 * // => true39 */40function includes(collection, value, fromIndex, guard) {41  collection = isArrayLike(collection) ? collection : values(collection);42  fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;43 44  var length = collection.length;45  if (fromIndex < 0) {46    fromIndex = nativeMax(length + fromIndex, 0);47  }48  return isString(collection)49    ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)50    : (!!length && baseIndexOf(collection, value, fromIndex) > -1);51}52 53module.exports = includes;54 
basant307/AI_Governance_Project · CoolFace