_.invoke definitions, removed underscore _.findWhere definition

This commit is contained in:
Brian Zengel
2013-10-18 19:58:34 -04:00
parent a951b7d410
commit 750bc30375
2 changed files with 26 additions and 11 deletions
+3
View File
@@ -289,6 +289,9 @@ result = <_.Dictionary<IKey>>_.indexBy(keys, 'dir');
result = <_.Dictionary<IKey>>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
result = <_.Dictionary<IKey>>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String);
result = <any[]>_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
result = <any[]>_.invoke([123, 456], String.prototype.split, '');
result = <any[]>_.map([1, 2, 3], function(num) { return num * 3; });
result = <any[]>_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
result = <any[]>_.map(stoogesAges, 'name');
+23 -11
View File
@@ -1257,6 +1257,28 @@ declare module _ {
collection: List<T>,
whereValue: Dictionary<any>): Dictionary<T>;
/**
* Invokes the method named by methodName on each element in the collection returning
* an array of the results of each invoked method. Additional arguments will be provided
* to each invoked method. If methodName is a function it will be invoked for, and this
* bound to, each element in the collection.
* @param collection The collection to iterate over.
* @param methodName The name of the method to invoke.
* @param args Arguments to invoke the method with.
**/
export function invoke<T extends {}>(
collection: Collection<T>,
methodName: string,
...args: any[]): any;
/**
* @see _.invoke
**/
export function invoke<T extends {}>(
collection: Collection<T>,
method: Function,
...args: any[]): any;
/**
* Creates an array of values by running each element in the collection through the callback.
* The callback is bound to thisArg and invoked with three arguments; (value, index|key,
@@ -1507,17 +1529,7 @@ declare module _ {
/**
* Calls the method named by methodName on each value in the list. Any extra arguments passed to
* invoke will be forwarded on to the method invocation.
* @param list The element's in this list will each have the method `methodName` invoked.
* @param methodName The method's name to call on each element within `list`.
* @param arguments Additional arguments to pass to the method `methodName`.
**/
export function invoke<T extends {}>(
list: Collection<T>,
methodName: string,
...arguments: any[]): any;
/**
* A convenient version of what is perhaps the most common use-case for map: extracting a list of