From ff0358b638dfeeb31415d8b77201a16df9b80600 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Mon, 21 Oct 2013 00:28:12 -0400 Subject: [PATCH] added _(...).countBy defs --- lodash/lodash-tests.ts | 4 ++++ lodash/lodash.d.ts | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 24bf221182..dd07c61d19 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -284,6 +284,10 @@ result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); + result = <_.LoDashWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); }); + result = <_.LoDashWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math); + result = <_.LoDashWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); + result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index d72628d5aa..a2be37ee34 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1099,13 +1099,30 @@ declare module _ { /** * @see _.countBy - * @param iterator Function name + * @param callback Function name **/ export function countBy( collection: Collection, callback: string, thisArg?: any): Dictionary; + interface LoDashWrapper { + /** + * @see _.countBy + **/ + countBy( + callback?: ListIterator, + thisArg?: any): LoDashWrapper>; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + callback: string, + thisArg?: any): LoDashWrapper>; + } + /** * Checks if the given callback returns truey value for all elements of a collection. * The callback is bound to thisArg and invoked with three arguments; (value, index|key,