Skip to content

Commit 0373592

Browse files
committed
Use DictionaryIterator for Dictionary functions
Without DictionaryIterator the simplest code is impossible to write: var myDictionary : {[x:string]: string;} _.filter(myDictionary, (v, k, c) => { return k == "A"; })
1 parent d259bac commit 0373592

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

lodash/lodash.d.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ declare module _ {
22292229
**/
22302230
countBy<T>(
22312231
collection: Dictionary<T>,
2232-
callback?: ListIterator<T, any>,
2232+
callback?: DictionaryIterator<T, any>,
22332233
thisArg?: any): Dictionary<number>;
22342234

22352235
/**
@@ -2314,7 +2314,7 @@ declare module _ {
23142314
**/
23152315
every<T>(
23162316
collection: Dictionary<T>,
2317-
callback?: ListIterator<T, boolean>,
2317+
callback?: DictionaryIterator<T, boolean>,
23182318
thisArg?: any): boolean;
23192319

23202320
/**
@@ -2386,7 +2386,7 @@ declare module _ {
23862386
**/
23872387
all<T>(
23882388
collection: Dictionary<T>,
2389-
callback?: ListIterator<T, boolean>,
2389+
callback?: DictionaryIterator<T, boolean>,
23902390
thisArg?: any): boolean;
23912391

23922392
/**
@@ -2473,7 +2473,7 @@ declare module _ {
24732473
**/
24742474
filter<T>(
24752475
collection: Dictionary<T>,
2476-
callback: ListIterator<T, boolean>,
2476+
callback: DictionaryIterator<T, boolean>,
24772477
thisArg?: any): T[];
24782478

24792479
/**
@@ -2545,7 +2545,7 @@ declare module _ {
25452545
**/
25462546
select<T>(
25472547
collection: Dictionary<T>,
2548-
callback: ListIterator<T, boolean>,
2548+
callback: DictionaryIterator<T, boolean>,
25492549
thisArg?: any): T[];
25502550

25512551
/**
@@ -2685,7 +2685,7 @@ declare module _ {
26852685
**/
26862686
find<T>(
26872687
collection: Dictionary<T>,
2688-
callback: ListIterator<T, boolean>,
2688+
callback: DictionaryIterator<T, boolean>,
26892689
thisArg?: any): T;
26902690

26912691
/**
@@ -2757,7 +2757,7 @@ declare module _ {
27572757
**/
27582758
detect<T>(
27592759
collection: Dictionary<T>,
2760-
callback: ListIterator<T, boolean>,
2760+
callback: DictionaryIterator<T, boolean>,
27612761
thisArg?: any): T;
27622762

27632763
/**
@@ -2829,7 +2829,7 @@ declare module _ {
28292829
**/
28302830
findWhere<T>(
28312831
collection: Dictionary<T>,
2832-
callback: ListIterator<T, boolean>,
2832+
callback: DictionaryIterator<T, boolean>,
28332833
thisArg?: any): T;
28342834

28352835
/**
@@ -2931,7 +2931,7 @@ declare module _ {
29312931
**/
29322932
findLast<T>(
29332933
collection: Dictionary<T>,
2934-
callback: ListIterator<T, boolean>,
2934+
callback: DictionaryIterator<T, boolean>,
29352935
thisArg?: any): T;
29362936

29372937
/**
@@ -3033,7 +3033,7 @@ declare module _ {
30333033
**/
30343034
forEach<T extends {}>(
30353035
object: Dictionary<T>,
3036-
callback: ObjectIterator<T, void>,
3036+
callback: DictionaryIterator<T, void>,
30373037
thisArg?: any): Dictionary<T>;
30383038

30393039
/**
@@ -3068,7 +3068,7 @@ declare module _ {
30683068
**/
30693069
each<T extends {}>(
30703070
object: Dictionary<T>,
3071-
callback: ObjectIterator<T, void>,
3071+
callback: DictionaryIterator<T, void>,
30723072
thisArg?: any): Dictionary<T>;
30733073

30743074
/**
@@ -3139,7 +3139,7 @@ declare module _ {
31393139
**/
31403140
forEachRight<T extends {}>(
31413141
object: Dictionary<T>,
3142-
callback: ObjectIterator<T, void>,
3142+
callback: DictionaryIterator<T, void>,
31433143
thisArg?: any): Dictionary<T>;
31443144

31453145
/**
@@ -3166,7 +3166,7 @@ declare module _ {
31663166
**/
31673167
eachRight<T extends {}>(
31683168
object: Dictionary<T>,
3169-
callback: ObjectIterator<T, void>,
3169+
callback: DictionaryIterator<T, void>,
31703170
thisArg?: any): Dictionary<T>;
31713171
}
31723172

@@ -3272,7 +3272,7 @@ declare module _ {
32723272
**/
32733273
groupBy<T>(
32743274
collection: Dictionary<T>,
3275-
callback?: ListIterator<T, any>,
3275+
callback?: DictionaryIterator<T, any>,
32763276
thisArg?: any): Dictionary<T[]>;
32773277

32783278
/**
@@ -3494,7 +3494,7 @@ declare module _ {
34943494
**/
34953495
map<T extends {}, TResult>(
34963496
object: Dictionary<T>,
3497-
callback: ObjectIterator<T, TResult>,
3497+
callback: DictionaryIterator<T, TResult>,
34983498
thisArg?: any): TResult[];
34993499

35003500
/**
@@ -3534,7 +3534,7 @@ declare module _ {
35343534
**/
35353535
collect<T extends {}, TResult>(
35363536
object: Dictionary<T>,
3537-
callback: ObjectIterator<T, TResult>,
3537+
callback: DictionaryIterator<T, TResult>,
35383538
thisArg?: any): TResult[];
35393539

35403540
/**
@@ -3633,7 +3633,7 @@ declare module _ {
36333633
**/
36343634
max<T>(
36353635
collection: Dictionary<T>,
3636-
callback?: ListIterator<T, any>,
3636+
callback?: DictionaryIterator<T, any>,
36373637
thisArg?: any): T;
36383638

36393639
/**
@@ -4266,7 +4266,7 @@ declare module _ {
42664266
**/
42674267
reject<T>(
42684268
collection: Dictionary<T>,
4269-
callback: ListIterator<T, boolean>,
4269+
callback: DictionaryIterator<T, boolean>,
42704270
thisArg?: any): T[];
42714271

42724272
/**
@@ -4463,7 +4463,7 @@ declare module _ {
44634463
**/
44644464
some<T>(
44654465
collection: Dictionary<T>,
4466-
callback?: ListIterator<T, boolean>,
4466+
callback?: DictionaryIterator<T, boolean>,
44674467
thisArg?: any): boolean;
44684468

44694469
/**
@@ -4543,7 +4543,7 @@ declare module _ {
45434543
**/
45444544
any<T>(
45454545
collection: Dictionary<T>,
4546-
callback?: ListIterator<T, boolean>,
4546+
callback?: DictionaryIterator<T, boolean>,
45474547
thisArg?: any): boolean;
45484548

45494549
/**
@@ -5486,7 +5486,7 @@ declare module _ {
54865486
**/
54875487
forIn<T>(
54885488
object: Dictionary<T>,
5489-
callback?: ObjectIterator<T, void>,
5489+
callback?: DictionaryIterator<T, void>,
54905490
thisArg?: any): Dictionary<T>;
54915491

54925492
/**
@@ -5519,7 +5519,7 @@ declare module _ {
55195519
**/
55205520
forInRight<T extends {}>(
55215521
object: Dictionary<T>,
5522-
callback?: ObjectIterator<T, void>,
5522+
callback?: DictionaryIterator<T, void>,
55235523
thisArg?: any): Dictionary<T>;
55245524

55255525
/**
@@ -5553,7 +5553,7 @@ declare module _ {
55535553
**/
55545554
forOwn<T extends {}>(
55555555
object: Dictionary<T>,
5556-
callback?: ObjectIterator<T, void>,
5556+
callback?: DictionaryIterator<T, void>,
55575557
thisArg?: any): Dictionary<T>;
55585558

55595559
/**
@@ -5586,7 +5586,7 @@ declare module _ {
55865586
**/
55875587
forOwnRight<T extends {}>(
55885588
object: Dictionary<T>,
5589-
callback?: ObjectIterator<T, void>,
5589+
callback?: DictionaryIterator<T, void>,
55905590
thisArg?: any): Dictionary<T>;
55915591
/**
55925592
* @see _.forOwnRight
@@ -6380,11 +6380,15 @@ declare module _ {
63806380
}
63816381

63826382
interface ListIterator<T, TResult> {
6383-
(value: T, index: number, list: T[]): TResult;
6383+
(value: T, index: number, collection: T[]): TResult;
6384+
}
6385+
6386+
interface DictionaryIterator<T, TResult> {
6387+
(value: T, key: string, collection: Dictionary<T>): TResult;
63846388
}
63856389

63866390
interface ObjectIterator<T, TResult> {
6387-
(element: T, key: string, list: any): TResult;
6391+
(element: T, key: string, collection: any): TResult;
63886392
}
63896393

63906394
interface MemoVoidIterator<T, TResult> {

0 commit comments

Comments
 (0)