mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Merge pull request #2357 from bczengel/lodash
Lodash - Add chainable definitions for _(...).toArray as well as _.groupBy and varients when passed an object
This commit is contained in:
+16
-4
@@ -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); });
|
||||
@@ -556,7 +564,11 @@ result = <number[]>_([1, 2, 3]).sortBy(function (num) { return Math.sin(num); })
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value();
|
||||
result = <string[]>_(['banana', 'strawberry', 'apple']).sortBy('length').value();
|
||||
|
||||
(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
(function (a: number, b: number, c: number, d: number): Array<number> { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
result = <number[]>_.toArray([1, 2, 3, 4]);
|
||||
(function (a: number, b: number, c: number, d: number): Array<number> { return _(arguments).toArray<number>().slice(1).value(); })(1, 2, 3, 4);
|
||||
result = <number[]>_([1,2,3,4]).toArray().value();
|
||||
|
||||
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] });
|
||||
|
||||
Vendored
+62
-3
@@ -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
|
||||
@@ -4520,6 +4565,20 @@ declare module _ {
|
||||
toArray<T>(collection: Dictionary<T>): T[];
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.toArray
|
||||
**/
|
||||
toArray(): LoDashArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.toArray
|
||||
**/
|
||||
toArray<TValue>(): LoDashArrayWrapper<TValue>;
|
||||
}
|
||||
|
||||
//_.where
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user