From 9dd9da44d51f90e64640d24c5c038f742be20c75 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Wed, 30 Oct 2013 10:38:29 -0700 Subject: [PATCH] fix tests and optional argument for reduce functions --- lodash/lodash-tests.ts | 33 +++++++++------------- lodash/lodash.d.ts | 62 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 24 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 1f2c9ca80..08f671a12 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -144,28 +144,21 @@ result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); -result = _.rest([1, 2, 3], function(num) { - return num < 3; -}); +result = _.rest([1, 2, 3], (num) => num < 3) result = _.rest(foodsOrganic, 'test'); -var result : any; -result = _.rest(foodsType, { 'test': 'value' }); +result = _.rest(foodsType, { 'type': 'value' }); - result = _.drop([1, 2, 3]); - result = _.drop([1, 2, 3], 2); - result = _.drop([1, 2, 3], function(num) { - return num < 3; - }); - result = _.drop(foodsOrganic, 'test'); - result = _.drop(foodsType, { 'test': 'value' }); +result = _.drop([1, 2, 3]); +result = _.drop([1, 2, 3], 2); +result = _.drop([1, 2, 3], (num) => num < 3) +result = _.drop(foodsOrganic, 'test'); +result = _.drop(foodsType, { 'type': 'value' }); - result = _.tail([1, 2, 3]); - result = _.tail([1, 2, 3], 2); - result = _.tail([1, 2, 3], function(num) { - return num < 3; - }); - result = _.tail(foodsOrganic, 'test'); - result = _.tail(foodsType, { 'test': 'value' }); +result = _.tail([1, 2, 3]) +result = _.tail([1, 2, 3], 2) +result = _.tail([1, 2, 3], (num) => num < 3) +result = _.tail(foodsOrganic, 'test') +result = _.tail(foodsType, { 'type': 'value' }) result = _.findIndex(['apple', 'banana', 'beet'], function(f) { return /^b/.test(f); @@ -203,9 +196,9 @@ result = _.first(foodsType, { 'type': 'fruit' }); result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); +var result: any result = _.flatten(stoogesQuotes, 'quotes'); -var result: any result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 0711d40e3..4d8116f94 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -780,7 +780,7 @@ declare module _ { **/ rest( array: List, - callback: (elem: T) => boolean, + callback: ListIterator, thisArg?: any): T[]; /** @@ -800,10 +800,13 @@ declare module _ { /** * @see _.rest **/ - rest( + rest( array: List, whereValue: W): T[]; + /** + * @see _.rest + **/ drop(array: List): T[]; /** @@ -811,7 +814,7 @@ declare module _ { **/ drop( array: List, - callback: (elem: T) => boolean, + callback: ListIterator, thisArg?: any): T[]; /** @@ -835,6 +838,9 @@ declare module _ { array: List, whereValue: W): T[]; + /** + * @see _.rest + **/ tail(array: List): T[]; /** @@ -842,7 +848,7 @@ declare module _ { **/ tail( array: List, - callback: (elem: T) => boolean, + callback: ListIterator, thisArg?: any): T[]; /** @@ -1916,6 +1922,14 @@ declare module _ { accumulator?: TResult, thisArg?: any): TResult; + /** + * @see _.reduce + **/ + reduce( + collection: Collection, + callback: MemoIterator, + thisArg?: any): TResult; + /** * @see _.reduce **/ @@ -1925,6 +1939,14 @@ declare module _ { accumulator?: TResult, thisArg?: any): TResult; + /** + * @see _.reduce + **/ + inject( + collection: Collection, + callback: MemoIterator, + thisArg?: any): TResult; + /** * @see _.reduce **/ @@ -1933,6 +1955,14 @@ declare module _ { callback: MemoIterator, accumulator?: TResult, thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Collection, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reduceRight @@ -1952,6 +1982,14 @@ declare module _ { accumulator?: TResult, thisArg?: any): TResult; + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Collection, + callback: MemoIterator, + thisArg?: any): TResult; + /** * @see _.reduceRight **/ @@ -1960,6 +1998,14 @@ declare module _ { callback: MemoIterator, accumulator?: TResult, thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Collection, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reject @@ -3621,6 +3667,14 @@ declare module _ { callback?: MemoIterator, accumulator?: any, thisArg?: any): any; + + /** + * @see _.transform + **/ + transform( + collection: Collection, + callback?: MemoIterator, + thisArg?: any): any; } //_.values