mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
28 lines
831 B
JavaScript
28 lines
831 B
JavaScript
define([], function() {
|
|
|
|
/**
|
|
* Gets the index at which the first occurrence of `NaN` is found in `array`.
|
|
* If `fromRight` is provided elements of `array` are iterated from right to left.
|
|
*
|
|
* @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 = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1);
|
|
|
|
while ((fromRight ? index-- : ++index < length)) {
|
|
var other = array[index];
|
|
if (other !== other) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
return indexOfNaN;
|
|
});
|