From 03735927ae8d11c9c5a3ce23f430fc6fc5d644c8 Mon Sep 17 00:00:00 2001 From: NN Date: Tue, 24 Feb 2015 18:02:04 +0200 Subject: [PATCH] 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"; }) --- lodash/lodash.d.ts | 56 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index c43f27c5c1..4211539d3f 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2229,7 +2229,7 @@ declare module _ { **/ countBy( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -2314,7 +2314,7 @@ declare module _ { **/ every( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): boolean; /** @@ -2386,7 +2386,7 @@ declare module _ { **/ all( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): boolean; /** @@ -2473,7 +2473,7 @@ declare module _ { **/ filter( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T[]; /** @@ -2545,7 +2545,7 @@ declare module _ { **/ select( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T[]; /** @@ -2685,7 +2685,7 @@ declare module _ { **/ find( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T; /** @@ -2757,7 +2757,7 @@ declare module _ { **/ detect( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T; /** @@ -2829,7 +2829,7 @@ declare module _ { **/ findWhere( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T; /** @@ -2931,7 +2931,7 @@ declare module _ { **/ findLast( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T; /** @@ -3033,7 +3033,7 @@ declare module _ { **/ forEach( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -3068,7 +3068,7 @@ declare module _ { **/ each( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -3139,7 +3139,7 @@ declare module _ { **/ forEachRight( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -3166,7 +3166,7 @@ declare module _ { **/ eachRight( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): Dictionary; } @@ -3272,7 +3272,7 @@ declare module _ { **/ groupBy( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -3494,7 +3494,7 @@ declare module _ { **/ map( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): TResult[]; /** @@ -3534,7 +3534,7 @@ declare module _ { **/ collect( object: Dictionary, - callback: ObjectIterator, + callback: DictionaryIterator, thisArg?: any): TResult[]; /** @@ -3633,7 +3633,7 @@ declare module _ { **/ max( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): T; /** @@ -4266,7 +4266,7 @@ declare module _ { **/ reject( collection: Dictionary, - callback: ListIterator, + callback: DictionaryIterator, thisArg?: any): T[]; /** @@ -4463,7 +4463,7 @@ declare module _ { **/ some( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): boolean; /** @@ -4543,7 +4543,7 @@ declare module _ { **/ any( collection: Dictionary, - callback?: ListIterator, + callback?: DictionaryIterator, thisArg?: any): boolean; /** @@ -5486,7 +5486,7 @@ declare module _ { **/ forIn( object: Dictionary, - callback?: ObjectIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -5519,7 +5519,7 @@ declare module _ { **/ forInRight( object: Dictionary, - callback?: ObjectIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -5553,7 +5553,7 @@ declare module _ { **/ forOwn( object: Dictionary, - callback?: ObjectIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** @@ -5586,7 +5586,7 @@ declare module _ { **/ forOwnRight( object: Dictionary, - callback?: ObjectIterator, + callback?: DictionaryIterator, thisArg?: any): Dictionary; /** * @see _.forOwnRight @@ -6380,11 +6380,15 @@ declare module _ { } interface ListIterator { - (value: T, index: number, list: T[]): TResult; + (value: T, index: number, collection: T[]): TResult; + } + + interface DictionaryIterator { + (value: T, key: string, collection: Dictionary): TResult; } interface ObjectIterator { - (element: T, key: string, list: any): TResult; + (element: T, key: string, collection: any): TResult; } interface MemoVoidIterator {