mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
lodash: signatures of _.groupBy have been changed
This commit is contained in:
+145
-12
@@ -3396,21 +3396,154 @@ module TestForEachRight {
|
||||
}
|
||||
}
|
||||
|
||||
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); });
|
||||
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');
|
||||
// _.groupBy
|
||||
module TestGroupBy {
|
||||
type SampleType = {a: number; b: string; c: boolean;};
|
||||
|
||||
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');
|
||||
let array: SampleType[];
|
||||
let list: _.List<SampleType>;
|
||||
let dictionary: _.Dictionary<SampleType>;
|
||||
|
||||
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();
|
||||
let stringIterator: (char: string, index: number, string: string) => number;
|
||||
let listIterator: (value: SampleType, index: number, collection: _.List<SampleType>) => number;
|
||||
let dictionaryIterator: (value: SampleType, key: string, collection: _.Dictionary<SampleType>) => number;
|
||||
|
||||
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();
|
||||
{
|
||||
let result: _.Dictionary<string[]>;
|
||||
|
||||
result = _.groupBy<string>('');
|
||||
result = _.groupBy<string>('', stringIterator);
|
||||
result = _.groupBy<string>('', stringIterator, any);
|
||||
result = _.groupBy<string, number>('', stringIterator);
|
||||
result = _.groupBy<string, number>('', stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.Dictionary<SampleType[]>;
|
||||
|
||||
result = _.groupBy<SampleType>(array);
|
||||
result = _.groupBy<SampleType>(array, listIterator);
|
||||
result = _.groupBy<SampleType>(array, listIterator, any);
|
||||
result = _.groupBy<SampleType>(array, '');
|
||||
result = _.groupBy<SampleType>(array, '', any);
|
||||
result = _.groupBy<SampleType>(array, {a: 42});
|
||||
|
||||
result = _.groupBy<SampleType, number>(array, listIterator);
|
||||
result = _.groupBy<SampleType, number>(array, listIterator, any);
|
||||
result = _.groupBy<SampleType, boolean>(array, '', true);
|
||||
result = _.groupBy<{a: number}, SampleType>(array, {a: 42});
|
||||
|
||||
result = _.groupBy<SampleType>(list);
|
||||
result = _.groupBy<SampleType>(list, listIterator);
|
||||
result = _.groupBy<SampleType>(list, listIterator, any);
|
||||
result = _.groupBy<SampleType>(list, '');
|
||||
result = _.groupBy<SampleType>(list, '', any);
|
||||
result = _.groupBy<SampleType>(list, {a: 42});
|
||||
|
||||
result = _.groupBy<SampleType, number>(list, listIterator);
|
||||
result = _.groupBy<SampleType, number>(list, listIterator, any);
|
||||
result = _.groupBy<SampleType, boolean>(list, '', true);
|
||||
result = _.groupBy<{a: number}, SampleType>(list, {a: 42});
|
||||
|
||||
result = _.groupBy<SampleType>(dictionary);
|
||||
result = _.groupBy<SampleType>(dictionary, dictionaryIterator);
|
||||
result = _.groupBy<SampleType>(dictionary, dictionaryIterator, any);
|
||||
result = _.groupBy<SampleType>(dictionary, '');
|
||||
result = _.groupBy<SampleType>(dictionary, '', any);
|
||||
result = _.groupBy<SampleType>(dictionary, {a: 42});
|
||||
|
||||
result = _.groupBy<SampleType, number>(dictionary, dictionaryIterator);
|
||||
result = _.groupBy<SampleType, number>(dictionary, dictionaryIterator, any);
|
||||
result = _.groupBy<SampleType, boolean>(dictionary, '', true);
|
||||
result = _.groupBy<{a: number}, SampleType>(dictionary, {a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<_.Dictionary<string[]>>;
|
||||
|
||||
result = _('').groupBy();
|
||||
result = _('').groupBy<number>(stringIterator);
|
||||
result = _('').groupBy<number>(stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<_.Dictionary<SampleType[]>>;
|
||||
|
||||
result = _(array).groupBy();
|
||||
result = _(array).groupBy<number>(listIterator);
|
||||
result = _(array).groupBy<number>(listIterator, any);
|
||||
result = _(array).groupBy('');
|
||||
result = _(array).groupBy<boolean>('', true);
|
||||
result = _(array).groupBy<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).groupBy<SampleType>();
|
||||
result = _(list).groupBy<SampleType>(listIterator);
|
||||
result = _(list).groupBy<SampleType>(listIterator, any);
|
||||
result = _(list).groupBy<SampleType>('');
|
||||
result = _(list).groupBy<SampleType>('', any);
|
||||
result = _(list).groupBy<SampleType>({a: 42});
|
||||
|
||||
result = _(list).groupBy<SampleType, number>(listIterator);
|
||||
result = _(list).groupBy<SampleType, number>(listIterator, any);
|
||||
result = _(list).groupBy<SampleType, boolean>('', true);
|
||||
result = _(list).groupBy<{a: number}, SampleType>({a: 42});
|
||||
|
||||
result = _(dictionary).groupBy<SampleType>();
|
||||
result = _(dictionary).groupBy<SampleType>(dictionaryIterator);
|
||||
result = _(dictionary).groupBy<SampleType>(dictionaryIterator, any);
|
||||
result = _(dictionary).groupBy<SampleType>('');
|
||||
result = _(dictionary).groupBy<SampleType>('', any);
|
||||
result = _(dictionary).groupBy<SampleType>({a: 42});
|
||||
|
||||
result = _(dictionary).groupBy<SampleType, number>(dictionaryIterator);
|
||||
result = _(dictionary).groupBy<SampleType, number>(dictionaryIterator, any);
|
||||
result = _(dictionary).groupBy<SampleType, boolean>('', true);
|
||||
result = _(dictionary).groupBy<{a: number}, SampleType>({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<_.Dictionary<string[]>>;
|
||||
|
||||
result = _('').chain().groupBy();
|
||||
result = _('').chain().groupBy<number>(stringIterator);
|
||||
result = _('').chain().groupBy<number>(stringIterator, any);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<_.Dictionary<SampleType[]>>;
|
||||
|
||||
result = _(array).chain().groupBy();
|
||||
result = _(array).chain().groupBy<number>(listIterator);
|
||||
result = _(array).chain().groupBy<number>(listIterator, any);
|
||||
result = _(array).chain().groupBy('');
|
||||
result = _(array).chain().groupBy<boolean>('', true);
|
||||
result = _(array).chain().groupBy<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).chain().groupBy<SampleType>();
|
||||
result = _(list).chain().groupBy<SampleType>(listIterator);
|
||||
result = _(list).chain().groupBy<SampleType>(listIterator, any);
|
||||
result = _(list).chain().groupBy<SampleType>('');
|
||||
result = _(list).chain().groupBy<SampleType>('', any);
|
||||
result = _(list).chain().groupBy<SampleType>({a: 42});
|
||||
|
||||
result = _(list).chain().groupBy<SampleType, number>(listIterator);
|
||||
result = _(list).chain().groupBy<SampleType, number>(listIterator, any);
|
||||
result = _(list).chain().groupBy<SampleType, boolean>('', true);
|
||||
result = _(list).chain().groupBy<{a: number}, SampleType>({a: 42});
|
||||
|
||||
result = _(dictionary).chain().groupBy<SampleType>();
|
||||
result = _(dictionary).chain().groupBy<SampleType>(dictionaryIterator);
|
||||
result = _(dictionary).chain().groupBy<SampleType>(dictionaryIterator, any);
|
||||
result = _(dictionary).chain().groupBy<SampleType>('');
|
||||
result = _(dictionary).chain().groupBy<SampleType>('', any);
|
||||
result = _(dictionary).chain().groupBy<SampleType>({a: 42});
|
||||
|
||||
result = _(dictionary).chain().groupBy<SampleType, number>(dictionaryIterator);
|
||||
result = _(dictionary).chain().groupBy<SampleType, number>(dictionaryIterator, any);
|
||||
result = _(dictionary).chain().groupBy<SampleType, boolean>('', true);
|
||||
result = _(dictionary).chain().groupBy<{a: number}, SampleType>({a: 42});
|
||||
}
|
||||
}
|
||||
|
||||
// _.include
|
||||
module TestInclude {
|
||||
|
||||
Vendored
+224
-97
@@ -5291,130 +5291,257 @@ declare module _ {
|
||||
//_.groupBy
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates an object composed of keys generated from the results of running each element
|
||||
* of a collection through the callback. The corresponding value of each key is an array
|
||||
* of the elements responsible for generating the key. The callback is bound to thisArg
|
||||
* and invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for callback the created "_.pluck" style callback will
|
||||
* return the property value of the given element.
|
||||
* If an object is provided for callback the created "_.where" style callback will return
|
||||
* true for elements that have the properties of the given object, else false
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
* @return Returns the composed aggregate object.
|
||||
**/
|
||||
groupBy<T>(
|
||||
collection: Array<T>,
|
||||
callback?: ListIterator<T, any>,
|
||||
thisArg?: any): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<T>(
|
||||
* Creates an object composed of keys generated from the results of running each element of collection through
|
||||
* iteratee. The corresponding value of each key is an array of the elements responsible for generating the
|
||||
* key. The iteratee is bound to thisArg and invoked with three arguments:
|
||||
* (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for iteratee the created _.property style callback returns the property
|
||||
* value of the given element.
|
||||
*
|
||||
* If a value is also provided for thisArg the created _.matchesProperty style callback returns true for
|
||||
* elements that have a matching property value, else false.
|
||||
*
|
||||
* If an object is provided for iteratee the created _.matches style callback returns true for elements that
|
||||
* have the properties of the given object, else false.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param iteratee The function invoked per iteration.
|
||||
* @param thisArg The this binding of iteratee.
|
||||
* @return Returns the composed aggregate object.
|
||||
*/
|
||||
groupBy<T, TKey>(
|
||||
collection: List<T>,
|
||||
callback?: ListIterator<T, any>,
|
||||
thisArg?: any): Dictionary<T[]>;
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): Dictionary<T[]>;
|
||||
collection: List<any>,
|
||||
iteratee?: ListIterator<T, any>,
|
||||
thisArg?: any
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
groupBy<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
groupBy<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
groupBy<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<T>(
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TKey>(
|
||||
collection: Dictionary<T>,
|
||||
callback?: DictionaryIterator<T, any>,
|
||||
thisArg?: any): Dictionary<T[]>;
|
||||
iteratee?: DictionaryIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
groupBy<TValue>(
|
||||
collection: Dictionary<TValue>,
|
||||
pluckValue: string): Dictionary<TValue[]>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
collection: Dictionary<any>,
|
||||
iteratee?: DictionaryIterator<T, any>,
|
||||
thisArg?: any
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
groupBy<W, TValue>(
|
||||
collection: Dictionary<TValue>,
|
||||
whereValue: W): Dictionary<TValue[]>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TValue>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
iteratee?: string,
|
||||
thisArg?: TValue
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
iteratee?: string,
|
||||
thisArg?: any
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TWhere, T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
iteratee?: TWhere
|
||||
): Dictionary<T[]>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
iteratee?: Object
|
||||
): Dictionary<T[]>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TKey>(
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy(
|
||||
callback: ListIterator<T, any>,
|
||||
thisArg?: any): _.LoDashImplicitObjectWrapper<_.Dictionary<T[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TKey>(
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy(
|
||||
pluckValue: string): _.LoDashImplicitObjectWrapper<_.Dictionary<T[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TValue>(
|
||||
iteratee?: string,
|
||||
thisArg?: TValue
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<W>(
|
||||
whereValue: W): _.LoDashImplicitObjectWrapper<_.Dictionary<T[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TWhere>(
|
||||
iteratee?: TWhere
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<TValue>(
|
||||
callback: ListIterator<TValue, any>,
|
||||
thisArg?: any): _.LoDashImplicitObjectWrapper<_.Dictionary<TValue[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TKey>(
|
||||
iteratee?: ListIterator<T, TKey>|DictionaryIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<TValue>(
|
||||
pluckValue: string): _.LoDashImplicitObjectWrapper<_.Dictionary<TValue[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: ListIterator<T, any>|DictionaryIterator<T, any>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
**/
|
||||
groupBy<W, TValue>(
|
||||
whereValue: W): _.LoDashImplicitObjectWrapper<_.Dictionary<TValue[]>>;
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TValue>(
|
||||
iteratee?: string,
|
||||
thisArg?: TValue
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: string,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TWhere, T>(
|
||||
iteratee?: TWhere
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: Object
|
||||
): LoDashImplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TKey>(
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TKey>(
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TValue>(
|
||||
iteratee?: string,
|
||||
thisArg?: TValue
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TWhere>(
|
||||
iteratee?: TWhere
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TKey>(
|
||||
iteratee?: ListIterator<T, TKey>|DictionaryIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: ListIterator<T, any>|DictionaryIterator<T, any>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T, TValue>(
|
||||
iteratee?: string,
|
||||
thisArg?: TValue
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<TWhere, T>(
|
||||
iteratee?: TWhere
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
|
||||
/**
|
||||
* @see _.groupBy
|
||||
*/
|
||||
groupBy<T>(
|
||||
iteratee?: Object
|
||||
): LoDashExplicitObjectWrapper<Dictionary<T[]>>;
|
||||
}
|
||||
|
||||
//_.include
|
||||
|
||||
Reference in New Issue
Block a user