Merge pull request #9711 from nallwhy/underscore-find_index

[UnderScore] Update definitions of findIndex/findLastIndex
This commit is contained in:
Mohamed Hegazy 2016-06-21 13:02:09 -07:00 committed by GitHub
commit f9ff331cf9
2 changed files with 10 additions and 21 deletions

View File

@ -240,6 +240,10 @@ _.object([['moe', 30], ['larry', 40], ['curly', 50]]);
_.indexOf([1, 2, 3], 2);
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
_.sortedIndex([10, 20, 30, 40, 50], 35);
_.findIndex([1, 2, 3, 1, 2, 3], num => num % 2 === 0);
_.findIndex([{a: 'a'}, {a: 'b'}], {a: 'b'});
_.findLastIndex([1, 2, 3, 1, 2, 3], num => num % 2 === 0);
_.findLastIndex([{ a: 'a' }, { a: 'b' }], { a: 'b' });
_.range(10);
_.range(1, 11);
_.range(0, 30, 5);

View File

@ -305,21 +305,6 @@ interface UnderscoreStatic {
object: _.List<T>|_.Dictionary<T>,
iterator: string): T;
/**
* Looks through each value in the list, returning the index of the first one that passes a truth
* test (iterator). The function returns as soon as it finds an acceptable element,
* and doesn't traverse the entire list.
* @param list Searches for a value in this list.
* @param iterator Search iterator function for each element in `list`.
* @param context `this` object in `iterator`, optional.
* @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned.
**/
findIndex<T>(
list: _.List<T>,
iterator: _.ListIterator<T, boolean>,
context?: any): number;
/**
* Looks through each value in the list, returning an array of all the values that pass a truth
* test (iterator). Delegates to the native filter method, if it exists.
@ -1014,7 +999,7 @@ interface UnderscoreStatic {
**/
findIndex<T>(
array: _.List<T>,
predicate: _.ListIterator<T, boolean>,
predicate: _.ListIterator<T, boolean> | {},
context?: any): number;
/**
@ -1026,7 +1011,7 @@ interface UnderscoreStatic {
**/
findLastIndex<T>(
array: _.List<T>,
predicate: _.ListIterator<T, boolean>,
predicate: _.ListIterator<T, boolean> | {},
context?: any): number;
/**
@ -4499,12 +4484,12 @@ interface Underscore<T> {
/**
* @see _.findIndex
**/
findIndex<T>(array: _.List<T>, predicate: _.ListIterator<T, boolean>, context?: any): number;
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;
findLastIndex<T>(array: _.List<T>, predicate: _.ListIterator<T, boolean> | {}, context?: any): number;
/**
* Wrapped type `any[]`.
@ -5417,12 +5402,12 @@ interface _Chain<T> {
/**
* @see _.findIndex
**/
findIndex<T>(predicate: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
findIndex<T>(predicate: _.ListIterator<T, boolean> | {}, context?: any): _ChainSingle<number>;
/**
* @see _.findLastIndex
**/
findLastIndex<T>(predicate: _.ListIterator<T, boolean>, context?: any): _Chain<T>;
findLastIndex<T>(predicate: _.ListIterator<T, boolean> | {}, context?: any): _ChainSingle<number>;
/**
* Wrapped type `any[]`.