mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
Added chainable definition for _(...).reduce and aliases.
This commit is contained in:
+28
-3
@@ -420,15 +420,16 @@ result = <IStoogesAge>_.min(stoogesAges, 'age');
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
|
||||
result = <number>_.reduce<number, number>([1, 2, 3], function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
interface ABC {
|
||||
[index: string]: number;
|
||||
a: number;
|
||||
b: number;
|
||||
c: number;
|
||||
}
|
||||
|
||||
result = <number>_.reduce<number, number>([1, 2, 3], function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <ABC>_.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
@@ -450,6 +451,30 @@ result = <ABC>_.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <number>_([1, 2, 3]).reduce<number>(function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).reduce<number, ABC>(function (r: ABC, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <number>_([1, 2, 3]).foldl<number>(function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).foldl<number, ABC>(function (r: ABC, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <number>_([1, 2, 3]).inject<number>(function (sum: number, num: number) {
|
||||
return sum + num;
|
||||
});
|
||||
result = <ABC>_({ 'a': 1, 'b': 2, 'c': 3 }).inject<number, ABC>(function (r: ABC, num: number, key: string) {
|
||||
r[key] = num * 3;
|
||||
return r;
|
||||
}, {});
|
||||
|
||||
result = <number[]>_.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, <number[]>[]);
|
||||
result = <number[]>_.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, <number[]>[]);
|
||||
|
||||
|
||||
Vendored
+94
@@ -3609,6 +3609,100 @@ declare module _ {
|
||||
thisArg?: any): TResult;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
reduce<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
reduce<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
inject<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
inject<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
foldl<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
foldl<TResult>(
|
||||
callback: MemoIterator<T, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
reduce<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
reduce<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
inject<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
inject<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
foldl<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
accumulator: TResult,
|
||||
thisArg?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
**/
|
||||
foldl<TValue, TResult>(
|
||||
callback: MemoIterator<TValue, TResult>,
|
||||
thisArg?: any): TResult;
|
||||
}
|
||||
|
||||
//_.reduceRight
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user