diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 66f0bf2ca..f46db5310 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -3979,8 +3979,53 @@ module TestKeyBy { } } -result = _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); -result = _.invokeMap([123, 456], String.prototype.split, ''); +//_.invokeMap +module TestInvokeMap { + let numArray = [4, 2, 1, 3] + let numDict: _.Dictionary = { + a: 1, + b: 2, + c: 3, + d: 4 + } + + let result: string[]; + result = _.invokeMap(numArray, 'toString'); + result = _.invokeMap(numArray, 'toString', 2); + result = _.invokeMap(numArray, 'toString'); + result = _.invokeMap(numArray, 'toString', 2); + result = _(numArray).invokeMap('toString').value(); + result = _(numArray).invokeMap('toString', 2).value(); + result = _(numArray).chain().invokeMap('toString').value(); + result = _(numArray).chain().invokeMap('toString', 2).value(); + + result = _.invokeMap(numArray, Number.prototype.toString); + result = _.invokeMap(numArray, Number.prototype.toString, 2); + result = _.invokeMap(numArray, Number.prototype.toString); + result = _.invokeMap(numArray, Number.prototype.toString, 2); + result = _(numArray).invokeMap(Number.prototype.toString).value(); + result = _(numArray).invokeMap(Number.prototype.toString, 2).value(); + result = _(numArray).chain().invokeMap(Number.prototype.toString).value(); + result = _(numArray).chain().invokeMap(Number.prototype.toString, 2).value(); + + result = _.invokeMap(numDict, 'toString'); + result = _.invokeMap(numDict, 'toString', 2); + result = _.invokeMap(numDict, 'toString'); + result = _.invokeMap(numDict, 'toString', 2); + result = _(numDict).invokeMap('toString').value(); + result = _(numDict).invokeMap('toString', 2).value(); + result = _(numDict).chain().invokeMap('toString').value(); + result = _(numDict).chain().invokeMap('toString', 2).value(); + + result = _.invokeMap(numDict, Number.prototype.toString); + result = _.invokeMap(numDict, Number.prototype.toString, 2); + result = _.invokeMap(numDict, Number.prototype.toString); + result = _.invokeMap(numDict, Number.prototype.toString, 2); + result = _(numDict).invokeMap(Number.prototype.toString).value(); + result = _(numDict).invokeMap(Number.prototype.toString, 2).value(); + result = _(numDict).chain().invokeMap(Number.prototype.toString).value(); + result = _(numDict).chain().invokeMap(Number.prototype.toString, 2).value(); +} // _.map module TestMap { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index aaa8dc7e3..f0c31d872 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6831,50 +6831,130 @@ declare module _ { * @param methodName The name of the method to invoke. * @param args Arguments to invoke the method with. **/ - invokeMap( - collection: Array, + invokeMap( + collection: TValue[], methodName: string, - ...args: any[]): any; + ...args: any[]): TResult[]; /** * @see _.invokeMap **/ - invokeMap( - collection: List, + invokeMap( + collection: Dictionary, methodName: string, - ...args: any[]): any; + ...args: any[]): TResult[]; /** * @see _.invokeMap **/ - invokeMap( - collection: Dictionary, + invokeMap( + collection: {}[], methodName: string, - ...args: any[]): any; + ...args: any[]): TResult[]; /** * @see _.invokeMap **/ - invokeMap( - collection: Array, - method: Function, - ...args: any[]): any; + invokeMap( + collection: Dictionary<{}>, + methodName: string, + ...args: any[]): TResult[]; /** * @see _.invokeMap **/ - invokeMap( - collection: List, - method: Function, - ...args: any[]): any; + invokeMap( + collection: TValue[], + method: (...args: any[]) => TResult, + ...args: any[]): TResult[]; /** * @see _.invokeMap **/ - invokeMap( - collection: Dictionary, - method: Function, - ...args: any[]): any; + invokeMap( + collection: Dictionary, + method: (...args: any[]) => TResult, + ...args: any[]): TResult[]; + + /** + * @see _.invokeMap + **/ + invokeMap( + collection: {}[], + method: (...args: any[]) => TResult, + ...args: any[]): TResult[]; + + /** + * @see _.invokeMap + **/ + invokeMap( + collection: Dictionary<{}>, + method: (...args: any[]) => TResult, + ...args: any[]): TResult[]; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.invokeMap + **/ + invokeMap( + methodName: string, + ...args: any[]): LoDashImplicitArrayWrapper; + + /** + * @see _.invokeMap + **/ + invokeMap( + method: (...args: any[]) => TResult, + ...args: any[]): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.invokeMap + **/ + invokeMap( + methodName: string, + ...args: any[]): LoDashImplicitArrayWrapper; + + /** + * @see _.invokeMap + **/ + invokeMap( + method: (...args: any[]) => TResult, + ...args: any[]): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.invokeMap + **/ + invokeMap( + methodName: string, + ...args: any[]): LoDashExplicitArrayWrapper; + + /** + * @see _.invokeMap + **/ + invokeMap( + method: (...args: any[]) => TResult, + ...args: any[]): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.invokeMap + **/ + invokeMap( + methodName: string, + ...args: any[]): LoDashExplicitArrayWrapper; + + /** + * @see _.invokeMap + **/ + invokeMap( + method: (...args: any[]) => TResult, + ...args: any[]): LoDashExplicitArrayWrapper; } //_.map