added _(...).countBy defs

This commit is contained in:
Brian Zengel
2013-10-21 00:28:54 -04:00
parent 2f75466cc5
commit ff0358b638
2 changed files with 22 additions and 1 deletions
+4
View File
@@ -284,6 +284,10 @@ result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
result = <_.Dictionary<number>>_.countBy(['one', 'two', 'three'], 'length');
result = <_.LoDashWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); });
result = <_.LoDashWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math);
result = <_.LoDashWrapper<_.Dictionary<number>>>_(['one', 'two', 'three']).countBy('length');
result = <boolean>_.every([true, 1, null, 'yes'], Boolean);
result = <boolean>_.every(stoogesAges, 'age');
result = <boolean>_.every(stoogesAges, { 'age': 50 });
+18 -1
View File
@@ -1099,13 +1099,30 @@ declare module _ {
/**
* @see _.countBy
* @param iterator Function name
* @param callback Function name
**/
export function countBy<T>(
collection: Collection<T>,
callback: string,
thisArg?: any): Dictionary<number>;
interface LoDashWrapper<T> {
/**
* @see _.countBy
**/
countBy<T>(
callback?: ListIterator<T, any>,
thisArg?: any): LoDashWrapper<Dictionary<number>>;
/**
* @see _.countBy
* @param callback Function name
**/
countBy<T>(
callback: string,
thisArg?: any): LoDashWrapper<Dictionary<number>>;
}
/**
* 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,