mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #5422 from chrootsu/lodash-thru
lodash: added _.thru() method
This commit is contained in:
+39
-3
@@ -403,9 +403,45 @@ result = <number[]>_([1, 2]).zipWith<number>(testZipWithFn, any).value();
|
||||
result = <number[]>_([1, 2]).zipWith<number>([1, 2], testZipWithFn, any).value();
|
||||
result = <number[]>_([1, 2]).zipWith<number>([1, 2], [1, 2], [1, 2], [1, 2], [1, 2], testZipWithFn, any).value();
|
||||
|
||||
// /* *************
|
||||
// * Collections *
|
||||
// ************* */
|
||||
/*********
|
||||
* Chain *
|
||||
*********/
|
||||
|
||||
// _.thru
|
||||
{
|
||||
let result: number;
|
||||
result = _.thru<number, number>(1, (value: number) => value);
|
||||
result = _.thru<number, number>(1, (value: number) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashWrapper<number>;
|
||||
result = _(1).thru<number>((value: number) => value);
|
||||
result = _(1).thru<number>((value: number) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashWrapper<string>;
|
||||
result = _('').thru<string>((value: string) => value);
|
||||
result = _('').thru<string>((value: string) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashWrapper<boolean>;
|
||||
result = _(true).thru<boolean>((value: boolean) => value);
|
||||
result = _(true).thru<boolean>((value: boolean) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashObjectWrapper<any>;
|
||||
result = _({}).thru<Object>((value: Object) => value);
|
||||
result = _({}).thru<Object>((value: Object) => value, any);
|
||||
}
|
||||
{
|
||||
let result: _.LoDashArrayWrapper<number>;
|
||||
result = _([1, 2, 3]).thru<number>((value: number[]) => value);
|
||||
result = _([1, 2, 3]).thru<number>((value: number[]) => value, any);
|
||||
}
|
||||
|
||||
/**************
|
||||
* Collection *
|
||||
**************/
|
||||
|
||||
result = <string[]>_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
|
||||
result = <string[]>_.at(['moe', 'larry', 'curly'], 0, 2);
|
||||
|
||||
Vendored
+59
-3
@@ -2000,9 +2000,65 @@ declare module _ {
|
||||
zipWith<TResult>(...args: any[]): LoDashArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
/* *************
|
||||
* Collections *
|
||||
************* */
|
||||
/*********
|
||||
* Chain *
|
||||
*********/
|
||||
|
||||
//_.thru
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like _.tap except that it returns the result of interceptor.
|
||||
* @param value The value to provide to interceptor.
|
||||
* @param interceptor The function to invoke.
|
||||
* @param thisArg The this binding of interceptor.
|
||||
* @return Returns the result of interceptor.
|
||||
*/
|
||||
thru<T, TResult>(
|
||||
value: T,
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): TResult;
|
||||
}
|
||||
|
||||
interface LoDashWrapperBase<T, TWrapper> {
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends number>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): LoDashWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends string>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): LoDashWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends boolean>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): LoDashWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult extends Object>(
|
||||
interceptor: (value: T) => TResult,
|
||||
thisArg?: any): LoDashObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.thru
|
||||
*/
|
||||
thru<TResult>(
|
||||
interceptor: (value: T) => TResult[],
|
||||
thisArg?: any): LoDashArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
/**************
|
||||
* Collection *
|
||||
**************/
|
||||
|
||||
//_.at
|
||||
interface LoDashStatic {
|
||||
|
||||
Reference in New Issue
Block a user