mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Lodash: _.invokeMap more robust & consistent with _.method/_.methodOf
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+51
-2
@@ -3945,8 +3945,57 @@ module TestKeyBy {
|
||||
}
|
||||
}
|
||||
|
||||
result = <number[][]>_.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
|
||||
result = <string[][]>_.invokeMap([123, 456], String.prototype.split, '');
|
||||
//_.invokeMap
|
||||
module TestInvokeMap {
|
||||
let numArray = [4, 2, 1, 3]
|
||||
let numDict: _.Dictionary<number> = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3,
|
||||
d: 4
|
||||
}
|
||||
|
||||
{
|
||||
let result: string[];
|
||||
result = _.invokeMap<number, string>(numArray, 'toString');
|
||||
result = _.invokeMap<number, string>(numArray, 'toString', 2);
|
||||
result = _.invokeMap<string>(numArray, 'toString');
|
||||
result = _.invokeMap<string>(numArray, 'toString', 2);
|
||||
result = _(numArray).invokeMap<string>('toString').value();
|
||||
result = _(numArray).invokeMap<string>('toString', 2).value();
|
||||
result = _(numArray).chain().invokeMap<string>('toString').value();
|
||||
result = _(numArray).chain().invokeMap<string>('toString', 2).value();
|
||||
|
||||
result = _.invokeMap<number, string>(numArray, Number.prototype.toString);
|
||||
result = _.invokeMap<number, string>(numArray, Number.prototype.toString, 2);
|
||||
result = _.invokeMap<string>(numArray, Number.prototype.toString);
|
||||
result = _.invokeMap<string>(numArray, Number.prototype.toString, 2);
|
||||
result = _(numArray).invokeMap<string>(Number.prototype.toString).value();
|
||||
result = _(numArray).invokeMap<string>(Number.prototype.toString, 2).value();
|
||||
result = _(numArray).chain().invokeMap<string>(Number.prototype.toString).value();
|
||||
result = _(numArray).chain().invokeMap<string>(Number.prototype.toString, 2).value();
|
||||
}
|
||||
{
|
||||
let result: _.Dictionary<string>
|
||||
result = _.invokeMap<number, string>(numDict, 'toString');
|
||||
result = _.invokeMap<number, string>(numDict, 'toString', 2);
|
||||
result = _.invokeMap<string>(numDict, 'toString');
|
||||
result = _.invokeMap<string>(numDict, 'toString', 2);
|
||||
result = _(numDict).invokeMap<string>('toString').value();
|
||||
result = _(numDict).invokeMap<string>('toString', 2).value();
|
||||
result = _(numDict).chain().invokeMap<string>('toString').value();
|
||||
result = _(numDict).chain().invokeMap<string>('toString', 2).value();
|
||||
|
||||
result = _.invokeMap<number, string>(numDict, Number.prototype.toString);
|
||||
result = _.invokeMap<number, string>(numDict, Number.prototype.toString, 2);
|
||||
result = _.invokeMap<string>(numDict, Number.prototype.toString);
|
||||
result = _.invokeMap<string>(numDict, Number.prototype.toString, 2);
|
||||
result = _(numDict).invokeMap<string>(Number.prototype.toString).value();
|
||||
result = _(numDict).invokeMap<string>(Number.prototype.toString, 2).value();
|
||||
result = _(numDict).chain().invokeMap<string>(Number.prototype.toString).value();
|
||||
result = _(numDict).chain().invokeMap<string>(Number.prototype.toString, 2).value();
|
||||
}
|
||||
}
|
||||
|
||||
// _.map
|
||||
module TestMap {
|
||||
|
||||
Vendored
+101
-21
@@ -6782,50 +6782,130 @@ declare module _ {
|
||||
* @param methodName The name of the method to invoke.
|
||||
* @param args Arguments to invoke the method with.
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: Array<T>,
|
||||
invokeMap<TValue extends {}, TResult>(
|
||||
collection: TValue[],
|
||||
methodName: string,
|
||||
...args: any[]): any;
|
||||
...args: any[]): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: List<T>,
|
||||
invokeMap<TValue extends {}, TResult>(
|
||||
collection: Dictionary<TValue>,
|
||||
methodName: string,
|
||||
...args: any[]): any;
|
||||
...args: any[]): Dictionary<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: Dictionary<T>,
|
||||
invokeMap<TResult>(
|
||||
collection: {}[],
|
||||
methodName: string,
|
||||
...args: any[]): any;
|
||||
...args: any[]): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: Array<T>,
|
||||
method: Function,
|
||||
...args: any[]): any;
|
||||
invokeMap<TResult>(
|
||||
collection: Dictionary<{}>,
|
||||
methodName: string,
|
||||
...args: any[]): Dictionary<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: List<T>,
|
||||
method: Function,
|
||||
...args: any[]): any;
|
||||
invokeMap<TValue extends {}, TResult>(
|
||||
collection: TValue[],
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<T extends {}>(
|
||||
collection: Dictionary<T>,
|
||||
method: Function,
|
||||
...args: any[]): any;
|
||||
invokeMap<TValue extends {}, TResult>(
|
||||
collection: Dictionary<TValue>,
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): Dictionary<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
collection: {}[],
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
collection: Dictionary<{}>,
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): Dictionary<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
methodName: string,
|
||||
...args: any[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
methodName: string,
|
||||
...args: any[]): LoDashImplicitObjectWrapper<_.Dictionary<TResult>>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): LoDashImplicitObjectWrapper<_.Dictionary<TResult>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
methodName: string,
|
||||
...args: any[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
methodName: string,
|
||||
...args: any[]): LoDashExplicitObjectWrapper<_.Dictionary<TResult>>;
|
||||
|
||||
/**
|
||||
* @see _.invokeMap
|
||||
**/
|
||||
invokeMap<TResult>(
|
||||
method: (...args: any[]) => TResult,
|
||||
...args: any[]): LoDashExplicitObjectWrapper<_.Dictionary<TResult>>;
|
||||
}
|
||||
|
||||
//_.map
|
||||
|
||||
Reference in New Issue
Block a user