mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #5993 from chrootsu/lodash-indexOf
lodash: changed _.indexOf() method
This commit is contained in:
+19
-3
@@ -317,9 +317,25 @@ module TestHead {
|
||||
result = _(list).head<TResult>();
|
||||
}
|
||||
|
||||
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2);
|
||||
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
||||
result = <number>_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
||||
// _.indexOf
|
||||
module TestIndexOf {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let value: TResult;
|
||||
let result: number;
|
||||
result = _.indexOf<TResult>(array, value);
|
||||
result = _.indexOf<TResult>(array, value, true);
|
||||
result = _.indexOf<TResult>(array, value, 42);
|
||||
result = _.indexOf<TResult>(list, value);
|
||||
result = _.indexOf<TResult>(list, value, true);
|
||||
result = _.indexOf<TResult>(list, value, 42);
|
||||
result = _(array).indexOf(value);
|
||||
result = _(array).indexOf(value, true);
|
||||
result = _(array).indexOf(value, 42);
|
||||
result = _(list).indexOf<TResult>(value);
|
||||
result = _(list).indexOf<TResult>(value, true);
|
||||
result = _(list).indexOf<TResult>(value, 42);
|
||||
}
|
||||
|
||||
//_.initial
|
||||
{
|
||||
|
||||
Vendored
+26
-46
@@ -762,60 +762,40 @@ declare module _ {
|
||||
//_.indexOf
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Gets the index at which the first occurrence of value is found using strict equality
|
||||
* for comparisons, i.e. ===. If the array is already sorted providing true for fromIndex
|
||||
* will run a faster binary search.
|
||||
* @param array The array to search.
|
||||
* @param value The value to search for.
|
||||
* @param fromIndex The index to search from.
|
||||
* @return The index of `value` within `array`.
|
||||
**/
|
||||
indexOf<T>(
|
||||
array: Array<T>,
|
||||
value: T): number;
|
||||
|
||||
/**
|
||||
* @see _.indexOf
|
||||
**/
|
||||
indexOf<T>(
|
||||
array: List<T>,
|
||||
value: T): number;
|
||||
|
||||
/**
|
||||
* @see _.indexOf
|
||||
* @param fromIndex The index to search from
|
||||
**/
|
||||
indexOf<T>(
|
||||
array: Array<T>,
|
||||
value: T,
|
||||
fromIndex: number): number;
|
||||
|
||||
/**
|
||||
* @see _.indexOf
|
||||
* @param fromIndex The index to search from
|
||||
**/
|
||||
* Gets the index at which the first occurrence of value is found in array using SameValueZero for equality
|
||||
* comparisons. If fromIndex is negative, it’s used as the offset from the end of array. If array is sorted
|
||||
* providing true for fromIndex performs a faster binary search.
|
||||
*
|
||||
* @param array The array to search.
|
||||
* @param value The value to search for.
|
||||
* @param fromIndex The index to search from or true to perform a binary search on a sorted array.
|
||||
* @return The index to search from or true to perform a binary search on a sorted array.
|
||||
*/
|
||||
indexOf<T>(
|
||||
array: List<T>,
|
||||
value: T,
|
||||
fromIndex: number): number;
|
||||
fromIndex?: boolean|number
|
||||
): number;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.indexOf
|
||||
* @param isSorted True to perform a binary search on a sorted array.
|
||||
**/
|
||||
indexOf<T>(
|
||||
array: Array<T>,
|
||||
* @see _.indexOf
|
||||
*/
|
||||
indexOf(
|
||||
value: T,
|
||||
isSorted: boolean): number;
|
||||
fromIndex?: boolean|number
|
||||
): number;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.indexOf
|
||||
* @param isSorted True to perform a binary search on a sorted array.
|
||||
**/
|
||||
indexOf<T>(
|
||||
array: List<T>,
|
||||
value: T,
|
||||
isSorted: boolean): number;
|
||||
* @see _.indexOf
|
||||
*/
|
||||
indexOf<TValue>(
|
||||
value: TValue,
|
||||
fromIndex?: boolean|number
|
||||
): number;
|
||||
}
|
||||
|
||||
//_.initial
|
||||
|
||||
Reference in New Issue
Block a user