CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
indexOf.js43 linesDownload Raw Back to lodash-es
1import baseIndexOf from './_baseIndexOf.js';2import toInteger from './toInteger.js';3 4/* Built-in method references for those with the same name as other `lodash` methods. */5var nativeMax = Math.max;6 7/**8 * Gets the index at which the first occurrence of `value` is found in `array`9 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)10 * for equality comparisons. If `fromIndex` is negative, it's used as the11 * offset from the end of `array`.12 *13 * @static14 * @memberOf _15 * @since 0.1.016 * @category Array17 * @param {Array} array The array to inspect.18 * @param {*} value The value to search for.19 * @param {number} [fromIndex=0] The index to search from.20 * @returns {number} Returns the index of the matched value, else `-1`.21 * @example22 *23 * _.indexOf([1, 2, 1, 2], 2);24 * // => 125 *26 * // Search from the `fromIndex`.27 * _.indexOf([1, 2, 1, 2], 2, 2);28 * // => 329 */30function indexOf(array, value, fromIndex) {31  var length = array == null ? 0 : array.length;32  if (!length) {33    return -1;34  }35  var index = fromIndex == null ? 0 : toInteger(fromIndex);36  if (index < 0) {37    index = nativeMax(length + index, 0);38  }39  return baseIndexOf(array, value, index);40}41 42export default indexOf;43 
basant307/AI_Governance_Project · CoolFace