diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fe08656c1..136a60f0a 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -2489,9 +2489,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; @@ -2578,6 +2578,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[]; @@ -2739,9 +2834,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; @@ -2828,17 +2923,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 c9b56c1e6..46cbbff08 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4109,7 +4109,7 @@ declare module _ { */ each( collection: string, - iteratee?: StringIterator, + iteratee?: StringIterator, thisArg?: any ): string; @@ -4118,7 +4118,7 @@ declare module _ { */ each( collection: T[], - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): T[]; @@ -4127,7 +4127,7 @@ declare module _ { */ each( collection: List, - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): List; @@ -4136,7 +4136,7 @@ declare module _ { */ each( collection: Dictionary, - iteratee?: DictionaryIterator, + iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; } @@ -4146,7 +4146,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4156,7 +4156,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitArrayWrapper; } @@ -4166,7 +4166,7 @@ declare module _ { * @see _.forEach */ each( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashImplicitObjectWrapper; } @@ -4176,7 +4176,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -4186,7 +4186,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitArrayWrapper; } @@ -4196,7 +4196,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; } @@ -4932,7 +5031,7 @@ declare module _ { */ forEach( collection: string, - iteratee?: StringIterator, + iteratee?: StringIterator, thisArg?: any ): string; @@ -4941,7 +5040,7 @@ declare module _ { */ forEach( collection: T[], - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): T[]; @@ -4950,7 +5049,7 @@ declare module _ { */ forEach( collection: List, - iteratee?: ListIterator, + iteratee?: ListIterator, thisArg?: any ): List; @@ -4959,7 +5058,7 @@ declare module _ { */ forEach( collection: Dictionary, - iteratee?: DictionaryIterator, + iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; } @@ -4969,7 +5068,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4979,7 +5078,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitArrayWrapper; } @@ -4989,7 +5088,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashImplicitObjectWrapper; } @@ -4999,7 +5098,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: StringIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -5009,7 +5108,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: ListIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitArrayWrapper; } @@ -5019,7 +5118,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee?: ListIterator|DictionaryIterator, + iteratee?: ListIterator|DictionaryIterator, thisArg?: any ): LoDashExplicitObjectWrapper; } @@ -5027,94 +5126,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