Add definitions for _.groupBy and _(...).groupBy when passed an object.

This commit is contained in:
Brian Zengel
2014-06-16 14:40:03 -04:00
parent a2d2e1b26d
commit 6f61e6419b
2 changed files with 59 additions and 6 deletions
+11 -3
View File
@@ -425,9 +425,17 @@ result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function (num) { ret
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math);
result = <_.Dictionary<string[]>>_.groupBy(['one', 'two', 'three'], 'length');
result = <_.LoDashObjectWrapper<_.Dictionary<number[]>>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number[]>>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math);
result = <_.LoDashObjectWrapper<_.Dictionary<string[]>>>_(['one', 'two', 'three']).groupBy('length');
result = <_.Dictionary<number[]>>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return Math.floor(num); });
result = <_.Dictionary<number[]>>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return this.floor(num); }, Math);
result = <_.Dictionary<string[]>>_.groupBy({ prop1: 'one', prop2: 'two', prop3: 'three'}, 'length');
result = <_.Dictionary<number[]>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }).value();
result = <_.Dictionary<number[]>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math).value();
result = <_.Dictionary<string[]>>_(['one', 'two', 'three']).groupBy('length').value();
result = <_.Dictionary<number[]>>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy<number>(function (num) { return Math.floor(num); }).value();
result = <_.Dictionary<number[]>>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy<number>(function (num) { return this.floor(num); }, Math).value();
result = <_.Dictionary<string[]>>_({ prop1: 'one', prop2: 'two', prop3: 'three'}).groupBy<string>('length').value();
result = <_.Dictionary<IKey>>_.indexBy(keys, 'dir');
result = <_.Dictionary<IKey>>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); });
+48 -3
View File
@@ -3169,6 +3169,30 @@ declare module _ {
groupBy<W, T>(
collection: List<T>,
whereValue: W): Dictionary<T[]>;
/**
* @see _.groupBy
**/
groupBy<T>(
collection: Dictionary<T>,
callback?: ListIterator<T, any>,
thisArg?: any): Dictionary<T[]>;
/**
* @see _.groupBy
* @param pluckValue _.pluck style callback
**/
groupBy<TValue>(
collection: Dictionary<TValue>,
pluckValue: string): Dictionary<TValue[]>;
/**
* @see _.groupBy
* @param whereValue _.where style callback
**/
groupBy<W, TValue>(
collection: Dictionary<TValue>,
whereValue: W): Dictionary<TValue[]>;
}
interface LoDashArrayWrapper<T> {
@@ -3177,19 +3201,40 @@ declare module _ {
**/
groupBy(
callback: ListIterator<T, any>,
thisArg?: any): _.LoDashObjectWrapper<Dictionary<T[]>>;
thisArg?: any): _.LoDashObjectWrapper<_.Dictionary<T[]>>;
/**
* @see _.groupBy
**/
groupBy(
pluckValue: string): _.LoDashObjectWrapper<Dictionary<T[]>>;
pluckValue: string): _.LoDashObjectWrapper<_.Dictionary<T[]>>;
/**
* @see _.groupBy
**/
groupBy<W>(
whereValue: W): _.LoDashObjectWrapper<Dictionary<T[]>>;
whereValue: W): _.LoDashObjectWrapper<_.Dictionary<T[]>>;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.groupBy
**/
groupBy<TValue>(
callback: ListIterator<TValue, any>,
thisArg?: any): _.LoDashObjectWrapper<_.Dictionary<TValue[]>>;
/**
* @see _.groupBy
**/
groupBy<TValue>(
pluckValue: string): _.LoDashObjectWrapper<_.Dictionary<TValue[]>>;
/**
* @see _.groupBy
**/
groupBy<W, TValue>(
whereValue: W): _.LoDashObjectWrapper<_.Dictionary<TValue[]>>;
}
//_.indexBy