From a59dd92bf744ee0712c40ef4392fea2a36900e50 Mon Sep 17 00:00:00 2001 From: motemen Date: Sat, 18 Oct 2014 17:53:24 +0900 Subject: [PATCH 1/4] _(...).findLast --- lodash/lodash-tests.ts | 6 ++++++ lodash/lodash.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index bb4f464a7..28a6c1ebe 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -400,6 +400,12 @@ result = _.findLast([1, 2, 3, 4], function (num) { result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); +result = _([1, 2, 3, 4]).findLast(function (num) { + return num % 2 == 0; +}); +result = _(foodsCombined).findLast({ 'type': 'vegetable' }); +result = _(foodsCombined).findLast('organic'); + result = _.forEach([1, 2, 3], function (num) { console.log(num); }); result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); result = _.forEach({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3e3fd43d7..e3b73adaa 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2940,6 +2940,28 @@ declare module _ { pluckValue: string): T; } + interface LoDashArrayWrapper { + /** + * @see _.findLast + */ + findLast( + callback: ListIterator, + thisArg?: any): T; + /** + * @see _.findLast + * @param _.where style callback + */ + findLast( + whereValue: W): T; + + /** + * @see _.findLast + * @param _.where style callback + */ + findLast( + pluckValue: string): T; + } + //_.forEach interface LoDashStatic { /** From 3653640a60c4b03c47696c35fb2267b2f76c69e3 Mon Sep 17 00:00:00 2001 From: motemen Date: Sat, 18 Oct 2014 17:57:10 +0900 Subject: [PATCH 2/4] _(...).zip and aliases --- lodash/lodash-tests.ts | 2 ++ lodash/lodash.d.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 28a6c1ebe..8fce20bb6 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -326,6 +326,8 @@ result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).xor([5, 2, 10], [4, 5, result = _.zip(['moe', 'larry'], [30, 40], [true, false]); result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); +result = _(['moe', 'larry']).zip([30, 40], [true, false]).value(); +result = _(['moe', 'larry']).unzip([30, 40], [true, false]).value(); // /* ************* // * Collections * diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index e3b73adaa..de604d818 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2027,6 +2027,18 @@ declare module _ { unzip(...arrays: any[]): any[]; } + interface LoDashArrayWrapper { + /** + * @see _.zip + **/ + zip(...arrays: any[][]): _.LoDashArrayWrapper; + + /** + * @see _.zip + **/ + unzip(...arrays: any[]): _.LoDashArrayWrapper; + } + //_.zipObject interface LoDashStatic { /** From 824029abf47d9cca8700aa0e72f90de2e689e9b1 Mon Sep 17 00:00:00 2001 From: motemen Date: Sat, 18 Oct 2014 18:04:12 +0900 Subject: [PATCH 3/4] _(...).max, min --- lodash/lodash-tests.ts | 6 ++++++ lodash/lodash.d.ts | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8fce20bb6..2d6335d70 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -476,10 +476,16 @@ result = _(stoogesAges).collect('name').value(); result = _.max([4, 2, 8, 6]); result = _.max(stoogesAges, function (stooge) { return stooge.age; }); result = _.max(stoogesAges, 'age'); +result = <_.LoDashWrapper>_([4, 2, 8, 6]).max(); +result = <_.LoDashWrapper>_(stoogesAges).max(function (stooge) { return stooge.age; }); +result = <_.LoDashWrapper>_(stoogesAges).max('age'); result = _.min([4, 2, 8, 6]); result = _.min(stoogesAges, function (stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); +result = <_.LoDashWrapper>_([4, 2, 8, 6]).min(); +result = <_.LoDashWrapper>_(stoogesAges).min(function (stooge) { return stooge.age; }); +result = <_.LoDashWrapper>_(stoogesAges).min('age'); result = _.pluck(stoogesAges, 'name'); result = _(stoogesAges).pluck('name').value(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index de604d818..85a406e38 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -3654,6 +3654,29 @@ declare module _ { whereValue: W): T; } + interface LoDashArrayWrapper { + /** + * @see _.max + **/ + max( + callback?: ListIterator, + thisArg?: any): LoDashWrapper; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + pluckValue: string): LoDashWrapper; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + whereValue: W): LoDashWrapper; + } + //_.min interface LoDashStatic { /** @@ -3742,6 +3765,29 @@ declare module _ { whereValue: W): T; } + interface LoDashArrayWrapper { + /** + * @see _.min + **/ + min( + callback?: ListIterator, + thisArg?: any): LoDashWrapper; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + pluckValue: string): LoDashWrapper; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + whereValue: W): LoDashWrapper; + } + //_.pluck interface LoDashStatic { /** From 2507e73a5fcc59f504fd5c70d23c230cfa0458d6 Mon Sep 17 00:00:00 2001 From: motemen Date: Sat, 18 Oct 2014 18:07:02 +0900 Subject: [PATCH 4/4] _(...).find --- lodash/lodash-tests.ts | 5 +++++ lodash/lodash.d.ts | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2d6335d70..cb1e0fa0a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -383,6 +383,11 @@ result = _.find([1, 2, 3, 4], function (num) { }); result = _.find(foodsCombined, { 'type': 'vegetable' }); result = _.find(foodsCombined, 'organic'); +result = _([1, 2, 3, 4]).find(function (num) { + return num % 2 == 0; +}); +result = _(foodsCombined).find({ 'type': 'vegetable' }); +result = _(foodsCombined).find('organic'); result = _.detect([1, 2, 3, 4], function (num) { return num % 2 == 0; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 85a406e38..93c6b6ee4 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2872,6 +2872,28 @@ declare module _ { pluckValue: string): T; } + interface LoDashArrayWrapper { + /** + * @see _.find + */ + find( + callback: ListIterator, + thisArg?: any): T; + /** + * @see _.find + * @param _.where style callback + */ + find( + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + */ + find( + pluckValue: string): T; + } + //_.findLast interface LoDashStatic { /**