mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-17 07:20:23 +00:00
lodash - Add _.nth
This commit is contained in:
Vendored
+51
@@ -2679,6 +2679,57 @@ declare namespace _ {
|
||||
): LoDashExplicitWrapper<number>;
|
||||
}
|
||||
|
||||
//_.nth
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Gets the element at index `n` of `array`. If `n` is negative, the nth element from the end is returned.
|
||||
*
|
||||
* @param array array The array to query.
|
||||
* @param value The index of the element to return.
|
||||
* @return Returns the nth element of `array`.
|
||||
*/
|
||||
nth<T>(
|
||||
array: List<T>,
|
||||
n?: number
|
||||
): T;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.nth
|
||||
*/
|
||||
nth(
|
||||
n?: number
|
||||
): T;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.nth
|
||||
*/
|
||||
nth<TResult>(
|
||||
n?:number
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.nth
|
||||
*/
|
||||
nth(
|
||||
n?:number
|
||||
): LoDashExplicitWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.nth
|
||||
*/
|
||||
nth<TResult>(
|
||||
n?:number
|
||||
): LoDashExplicitWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.pull
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
@@ -1289,6 +1289,37 @@ namespace TestLastIndexOf {
|
||||
}
|
||||
}
|
||||
|
||||
// _.nth
|
||||
namespace TestNth {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let value: number;
|
||||
|
||||
{
|
||||
let result: TResult;
|
||||
|
||||
result = _.nth<TResult>(array);
|
||||
|
||||
result = _.nth<TResult>(array, 42);
|
||||
|
||||
result = _(array).nth();
|
||||
result = _(array).nth(42);
|
||||
|
||||
result = _(list).nth<TResult>();
|
||||
result = _(list).nth<TResult>(42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().nth();
|
||||
result = _(array).chain().nth(42);
|
||||
|
||||
result = _(list).chain().nth<TResult>();
|
||||
result = _(list).chain().nth<TResult>(42);
|
||||
}
|
||||
}
|
||||
|
||||
// _.pull
|
||||
namespace TestPull {
|
||||
let array: TResult[];
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
import { nth } from "../index";
|
||||
export = nth;
|
||||
@@ -171,6 +171,7 @@
|
||||
"noConflict/index.d.ts",
|
||||
"noop/index.d.ts",
|
||||
"now/index.d.ts",
|
||||
"nth/index.d.ts",
|
||||
"nthArg/index.d.ts",
|
||||
"omit/index.d.ts",
|
||||
"omitBy/index.d.ts",
|
||||
@@ -306,4 +307,4 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user