mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Bump to v3.0.0.
This commit is contained in:
27
internal/baseIndexOf.js
Normal file
27
internal/baseIndexOf.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import indexOfNaN from './indexOfNaN';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.indexOf` without support for binary searches.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {*} value The value to search for.
|
||||
* @param {number} [fromIndex=0] The index to search from.
|
||||
* @returns {number} Returns the index of the matched value, else `-1`.
|
||||
*/
|
||||
function baseIndexOf(array, value, fromIndex) {
|
||||
if (value !== value) {
|
||||
return indexOfNaN(array, fromIndex);
|
||||
}
|
||||
var index = (fromIndex || 0) - 1,
|
||||
length = array.length;
|
||||
|
||||
while (++index < length) {
|
||||
if (array[index] === value) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
export default baseIndexOf;
|
||||
Reference in New Issue
Block a user