mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Remove indexOfNaN in favor of baseFindIndex.
This commit is contained in:
37
lodash.js
37
lodash.js
@@ -721,7 +721,7 @@
|
||||
*/
|
||||
function baseIndexOf(array, value, fromIndex) {
|
||||
if (value !== value) {
|
||||
return indexOfNaN(array, fromIndex);
|
||||
return baseFindIndex(array, baseIsNaN, fromIndex);
|
||||
}
|
||||
var index = fromIndex - 1,
|
||||
length = array.length;
|
||||
@@ -756,6 +756,17 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.isNaN` without support for number objects.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
||||
*/
|
||||
function baseIsNaN(value) {
|
||||
return value !== value;
|
||||
}
|
||||
|
||||
/**
|
||||
* The base implementation of `_.mean` and `_.meanBy` without support for
|
||||
* iteratee shorthands.
|
||||
@@ -1019,28 +1030,6 @@
|
||||
return object == null ? undefined : object[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index at which the first occurrence of `NaN` is found in `array`.
|
||||
*
|
||||
* @private
|
||||
* @param {Array} array The array to search.
|
||||
* @param {number} fromIndex The index to search from.
|
||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||
* @returns {number} Returns the index of the matched `NaN`, else `-1`.
|
||||
*/
|
||||
function indexOfNaN(array, fromIndex, fromRight) {
|
||||
var length = array.length,
|
||||
index = fromIndex + (fromRight ? 1 : -1);
|
||||
|
||||
while ((fromRight ? index-- : ++index < length)) {
|
||||
var other = array[index];
|
||||
if (other !== other) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if `value` is a host object in IE < 9.
|
||||
*
|
||||
@@ -6919,7 +6908,7 @@
|
||||
) + 1;
|
||||
}
|
||||
if (value !== value) {
|
||||
return indexOfNaN(array, index - 1, true);
|
||||
return baseFindIndex(array, baseIsNaN, index - 1, true);
|
||||
}
|
||||
while (index--) {
|
||||
if (array[index] === value) {
|
||||
|
||||
Reference in New Issue
Block a user