lodash.indexof
Advanced tools
Comparing version 4.0.3 to 4.0.4
62
index.js
@@ -36,2 +36,25 @@ /** | ||
/** | ||
* The base implementation of `_.findIndex` and `_.findLastIndex` without | ||
* support for iteratee shorthands. | ||
* | ||
* @private | ||
* @param {Array} array The array to search. | ||
* @param {Function} predicate The function invoked per iteration. | ||
* @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 value, else `-1`. | ||
*/ | ||
function baseFindIndex(array, predicate, fromIndex, fromRight) { | ||
var length = array.length, | ||
index = fromIndex + (fromRight ? 1 : -1); | ||
while ((fromRight ? index-- : ++index < length)) { | ||
if (predicate(array[index], index, array)) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | ||
/** | ||
* The base implementation of `_.indexOf` without `fromIndex` bounds checks. | ||
@@ -47,3 +70,3 @@ * | ||
if (value !== value) { | ||
return indexOfNaN(array, fromIndex); | ||
return baseFindIndex(array, baseIsNaN, fromIndex); | ||
} | ||
@@ -62,21 +85,10 @@ var index = fromIndex - 1, | ||
/** | ||
* Gets the index at which the first occurrence of `NaN` is found in `array`. | ||
* The base implementation of `_.isNaN` without support for number objects. | ||
* | ||
* @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`. | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. | ||
*/ | ||
function indexOfNaN(array, fromIndex, fromRight) { | ||
var length = array.length, | ||
index = fromIndex + (fromRight ? 0 : -1); | ||
while ((fromRight ? index-- : ++index < length)) { | ||
var other = array[index]; | ||
if (other !== other) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
function baseIsNaN(value) { | ||
return value !== value; | ||
} | ||
@@ -125,7 +137,7 @@ | ||
} | ||
fromIndex = toInteger(fromIndex); | ||
if (fromIndex < 0) { | ||
fromIndex = nativeMax(length + fromIndex, 0); | ||
var index = fromIndex == null ? 0 : toInteger(fromIndex); | ||
if (index < 0) { | ||
index = nativeMax(length + index, 0); | ||
} | ||
return baseIndexOf(array, value, fromIndex); | ||
return baseIndexOf(array, value, index); | ||
} | ||
@@ -141,4 +153,3 @@ | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @returns {boolean} Returns `true` if `value` is a function, else `false`. | ||
* @example | ||
@@ -226,4 +237,3 @@ * | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
@@ -280,3 +290,3 @@ * | ||
* | ||
* **Note:** This function is loosely based on | ||
* **Note:** This method is loosely based on | ||
* [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). | ||
@@ -283,0 +293,0 @@ * |
{ | ||
"name": "lodash.indexof", | ||
"version": "4.0.3", | ||
"version": "4.0.4", | ||
"description": "The lodash method `_.indexOf` exported as a module.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://lodash.com/", |
@@ -1,2 +0,2 @@ | ||
# lodash.indexof v4.0.3 | ||
# lodash.indexof v4.0.4 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.indexOf` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#indexOf) or [package source](https://github.com/lodash/lodash/blob/4.0.3-npm-packages/lodash.indexof) for more details. | ||
See the [documentation](https://lodash.com/docs#indexOf) or [package source](https://github.com/lodash/lodash/blob/4.0.4-npm-packages/lodash.indexof) for more details. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12104
333