From 336552c44fa16e5c745ece423f3183ca0f91e117 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Mon, 9 Nov 2015 09:49:13 +0500 Subject: [PATCH] lodash: signatures of the methods _.forEach and _.forEachRight have been changed --- lodash/lodash-tests.ts | 206 +++++++++++++++++++++++++++-- lodash/lodash.d.ts | 289 ++++++++++++++++++++++++++++------------- 2 files changed, 392 insertions(+), 103 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 876547fd6..2d156b0c1 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2427,9 +2427,9 @@ module TestEach { let list: _.List; let dictionary: _.Dictionary; - let stringIterator: (char: string, index: number, string: string) => boolean|void; - let listIterator: (value: TResult, index: number, collection: _.List) => boolean|void; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean|void; + let stringIterator: (char: string, index: number, string: string) => any; + let listIterator: (value: TResult, index: number, collection: _.List) => any; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; { let result: string; @@ -2516,6 +2516,101 @@ module TestEach { } } +// _.eachRight +module TestEachRight { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; + + let stringIterator: (char: string, index: number, string: string) => any; + let listIterator: (value: TResult, index: number, collection: _.List) => any; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + + { + let result: string; + + _.eachRight('', stringIterator); + _.eachRight('', stringIterator, any); + } + + { + let result: TResult[]; + + _.eachRight(array, listIterator); + _.eachRight(array, listIterator, any); + } + + { + let result: _.List; + + _.eachRight(list, listIterator); + _.eachRight(list, listIterator, any); + } + + { + let result: _.Dictionary; + + _.eachRight(dictionary, dictionaryIterator); + _.eachRight(dictionary, dictionaryIterator, any); + } + + { + let result: _.LoDashImplicitWrapper; + + _('').eachRight(stringIterator); + _('').eachRight(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + _(array).eachRight(listIterator); + _(array).eachRight(listIterator, any); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.List>; + + _(list).eachRight(listIterator); + _(list).eachRight(listIterator, any); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; + + _(dictionary).eachRight(dictionaryIterator); + _(dictionary).eachRight(dictionaryIterator, any); + } + + { + let result: _.LoDashExplicitWrapper; + + _('').chain().eachRight(stringIterator); + _('').chain().eachRight(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + _(array).chain().eachRight(listIterator); + _(array).chain().eachRight(listIterator, any); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.List>; + + _(list).chain().eachRight(listIterator); + _(list).chain().eachRight(listIterator, any); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; + + _(dictionary).chain().eachRight(dictionaryIterator); + _(dictionary).chain().eachRight(dictionaryIterator, any); + } +} + // _.every module TestEvery { let array: TResult[]; @@ -2677,9 +2772,9 @@ module TestForEach { let list: _.List; let dictionary: _.Dictionary; - let stringIterator: (char: string, index: number, string: string) => boolean|void; - let listIterator: (value: TResult, index: number, collection: _.List) => boolean|void; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean|void; + let stringIterator: (char: string, index: number, string: string) => any; + let listIterator: (value: TResult, index: number, collection: _.List) => any; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; { let result: string; @@ -2766,17 +2861,100 @@ module TestForEach { } } -result = _.forEachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +// _.forEachRight +module TestForEachRight { + let array: TResult[]; + let list: _.List; + let dictionary: _.Dictionary; -result = _.eachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); + let stringIterator: (char: string, index: number, string: string) => any; + let listIterator: (value: TResult, index: number, collection: _.List) => any; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; -result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); -result = <_.LoDashImplicitObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); + { + let result: string; -result = <_.LoDashImplicitArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); -result = <_.LoDashImplicitObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); + _.forEachRight('', stringIterator); + _.forEachRight('', stringIterator, any); + } + + { + let result: TResult[]; + + _.forEachRight(array, listIterator); + _.forEachRight(array, listIterator, any); + } + + { + let result: _.List; + + _.forEachRight(list, listIterator); + _.forEachRight(list, listIterator, any); + } + + { + let result: _.Dictionary; + + _.forEachRight(dictionary, dictionaryIterator); + _.forEachRight(dictionary, dictionaryIterator, any); + } + + { + let result: _.LoDashImplicitWrapper; + + _('').forEachRight(stringIterator); + _('').forEachRight(stringIterator, any); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + _(array).forEachRight(listIterator); + _(array).forEachRight(listIterator, any); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.List>; + + _(list).forEachRight(listIterator); + _(list).forEachRight(listIterator, any); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; + + _(dictionary).forEachRight(dictionaryIterator); + _(dictionary).forEachRight(dictionaryIterator, any); + } + + { + let result: _.LoDashExplicitWrapper; + + _('').chain().forEachRight(stringIterator); + _('').chain().forEachRight(stringIterator, any); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + _(array).chain().forEachRight(listIterator); + _(array).chain().forEachRight(listIterator, any); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.List>; + + _(list).chain().forEachRight(listIterator); + _(list).chain().forEachRight(listIterator, any); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; + + _(dictionary).chain().forEachRight(dictionaryIterator); + _(dictionary).chain().forEachRight(dictionaryIterator, any); + } +} result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); }); result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 359cc0fb9..a0827098d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4031,7 +4031,7 @@ declare module _ { */ each( collection: string, - iteratee?: StringIterator, + iteratee?: StringIterator, thisArg?: any ): string; @@ -4040,7 +4040,7 @@ declare module _ { */ each( collection: T[], - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): T[]; @@ -4049,7 +4049,7 @@ declare module _ { */ each( collection: List, - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): List; @@ -4058,7 +4058,7 @@ declare module _ { */ each( collection: Dictionary, - iteratee?: DictionaryIterator, + iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; } @@ -4068,7 +4068,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4078,7 +4078,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitArrayWrapper; } @@ -4088,7 +4088,7 @@ declare module _ { * @see _.forEach */ each( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashImplicitObjectWrapper; } @@ -4098,7 +4098,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -4108,7 +4108,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitArrayWrapper; } @@ -4118,7 +4118,106 @@ declare module _ { * @see _.forEach */ each( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper; + } + + //_.eachRight + interface LoDashStatic { + /** + * @see _.forEachRight + */ + eachRight( + collection: string, + iteratee?: StringIterator, + thisArg?: any + ): string; + + /** + * @see _.forEachRight + */ + eachRight( + collection: T[], + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.forEachRight + */ + eachRight( + collection: List, + iteratee?: ListIterator, + thisArg?: any + ): List; + + /** + * @see _.forEachRight + */ + eachRight( + collection: Dictionary, + iteratee?: DictionaryIterator, + thisArg?: any + ): Dictionary; + } + + interface LoDashImplicitWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee: StringIterator, + thisArg?: any + ): LoDashImplicitWrapper; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee: StringIterator, + thisArg?: any + ): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.forEachRight + */ + eachRight( + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashExplicitObjectWrapper; } @@ -4854,7 +4953,7 @@ declare module _ { */ forEach( collection: string, - iteratee?: StringIterator, + iteratee?: StringIterator, thisArg?: any ): string; @@ -4863,7 +4962,7 @@ declare module _ { */ forEach( collection: T[], - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): T[]; @@ -4872,7 +4971,7 @@ declare module _ { */ forEach( collection: List, - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): List; @@ -4881,7 +4980,7 @@ declare module _ { */ forEach( collection: Dictionary, - iteratee?: DictionaryIterator, + iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; } @@ -4891,7 +4990,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4901,7 +5000,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitArrayWrapper; } @@ -4911,7 +5010,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashImplicitObjectWrapper; } @@ -4921,7 +5020,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -4931,7 +5030,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitArrayWrapper; } @@ -4941,7 +5040,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashExplicitObjectWrapper; } @@ -4949,94 +5048,106 @@ declare module _ { //_.forEachRight interface LoDashStatic { /** - * This method is like _.forEach except that it iterates over elements of a - * collection from right to left. - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - forEachRight( - collection: Array, - callback: ListIterator, - thisArg?: any): Array; + * This method is like _.forEach except that it iterates over elements of collection from right to left. + * + * @alias _.eachRight + * + * @param collection The collection to iterate over. + * @param iteratee The function called per iteration. + * @param thisArg The this binding of callback. + */ + forEachRight( + collection: string, + iteratee?: StringIterator, + thisArg?: any + ): string; /** - * @see _.forEachRight - **/ + * @see _.forEachRight + */ + forEachRight( + collection: T[], + iteratee?: ListIterator, + thisArg?: any + ): T[]; + + /** + * @see _.forEachRight + */ forEachRight( collection: List, - callback: ListIterator, - thisArg?: any): List; + iteratee?: ListIterator, + thisArg?: any + ): List; /** - * @see _.forEachRight - **/ - forEachRight( - object: Dictionary, - callback: DictionaryIterator, - thisArg?: any): Dictionary; + * @see _.forEachRight + */ + forEachRight( + collection: Dictionary, + iteratee?: DictionaryIterator, + thisArg?: any + ): Dictionary; + } + interface LoDashImplicitWrapper { /** - * @see _.forEachRight - **/ - eachRight( - collection: Array, - callback: ListIterator, - thisArg?: any): Array; - - /** - * @see _.forEachRight - **/ - eachRight( - collection: List, - callback: ListIterator, - thisArg?: any): List; - - /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - object: Dictionary, - callback: DictionaryIterator, - thisArg?: any): Dictionary; + * @see _.forEachRight + */ + forEachRight( + iteratee: StringIterator, + thisArg?: any + ): LoDashImplicitWrapper; } interface LoDashImplicitArrayWrapper { /** - * @see _.forEachRight - **/ + * @see _.forEachRight + */ forEachRight( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; - - /** - * @see _.forEachRight - **/ - eachRight( - callback: ListIterator, - thisArg?: any): LoDashImplicitArrayWrapper; + iteratee: ListIterator, + thisArg?: any + ): LoDashImplicitArrayWrapper; } interface LoDashImplicitObjectWrapper { /** - * @see _.forEachRight - **/ - forEachRight( - callback: ObjectIterator, - thisArg?: any): LoDashImplicitObjectWrapper>; + * @see _.forEachRight + */ + forEachRight( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper; + } + interface LoDashExplicitWrapper { /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - callback: ObjectIterator, - thisArg?: any): LoDashImplicitObjectWrapper>; + * @see _.forEachRight + */ + forEachRight( + iteratee: StringIterator, + thisArg?: any + ): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.forEachRight + */ + forEachRight( + iteratee: ListIterator, + thisArg?: any + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.forEachRight + */ + forEachRight( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper; } //_.groupBy