Added _.findIndex and _.findLastIndex functions

This commit is contained in:
Daniel Furtado
2015-12-27 20:08:30 +01:00
parent af6a653112
commit 05774649a6
+44
View File
@@ -961,6 +961,30 @@ interface UnderscoreStatic {
array: _.List<T>,
value: T,
from?: number): number;
/**
* Returns the first index of an element in `array` where the predicate truth test passes
* @param array The array to search for the index of the first element where the predicate truth test passes.
* @param predicate Predicate function.
* @param context `this` object in `predicate`, optional.
* @return Returns the index of an element in `array` where the predicate truth test passes or -1.`
**/
findIndex<T>(
array: _.List<T>,
predicate: _.ListIterator<T, boolean>,
context?: any): number;
/**
* Returns the last index of an element in `array` where the predicate truth test passes
* @param array The array to search for the index of the last element where the predicate truth test passes.
* @param predicate Predicate function.
* @param context `this` object in `predicate`, optional.
* @return Returns the index of an element in `array` where the predicate truth test passes or -1.`
**/
findLastIndex<T>(
array: _.List<T>,
predicate: _.ListIterator<T, boolean>,
context?: any): number;
/**
* Uses a binary search to determine the index at which the value should be inserted into the list in order
@@ -2115,6 +2139,16 @@ interface Underscore<T> {
**/
lastIndexOf(value: T, from?: number): number;
/**
* @see _.findIndex
**/
findIndex<T>(array: _.List<T>, predicate: _.ListIterator<T, boolean>, context?: any): number;
/**
* @see _.findLastIndex
**/
findLastIndex<T>(array: _.List<T>, predicate: _.ListIterator<T, boolean>, context?: any): number;
/**
* Wrapped type `any[]`.
* @see _.sortedIndex
@@ -2999,6 +3033,16 @@ interface _Chain<T> {
**/
lastIndexOf(value: T, from?: number): _ChainSingle<T>;
/**
* @see _.findIndex
**/
findIndex<T>(predicate: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
/**
* @see _.findLastIndex
**/
findLastIndex<T>(predicate: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
/**
* Wrapped type `any[]`.
* @see _.sortedIndex