diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8a5df5676..7fbbcf3c6 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -420,15 +420,16 @@ result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); -result = _.reduce([1, 2, 3], function (sum: number, num: number) { - return sum + num; -}); interface ABC { [index: string]: number; a: number; b: number; c: number; } + +result = _.reduce([1, 2, 3], function (sum: number, num: number) { + return sum + num; +}); result = _.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 = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num: number return r; }, {}); +result = _([1, 2, 3]).reduce(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).reduce(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + +result = _([1, 2, 3]).foldl(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).foldl(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + +result = _([1, 2, 3]).inject(function (sum: number, num: number) { + return sum + num; +}); +result = _({ 'a': 1, 'b': 2, 'c': 3 }).inject(function (r: ABC, num: number, key: string) { + r[key] = num * 3; + return r; +}, {}); + result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index a05d1d68b..4cfeea09a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3609,6 +3609,100 @@ declare module _ { thisArg?: any): TResult; } + interface LoDashArrayWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + + interface LoDashObjectWrapper { + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + callback: MemoIterator, + thisArg?: any): TResult; + } + //_.reduceRight interface LoDashStatic { /**