From 750bc303754d81385a9a60be3e0e282554a723c0 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Fri, 18 Oct 2013 19:58:34 -0400 Subject: [PATCH] _.invoke definitions, removed underscore _.findWhere definition --- lodash/lodash-tests.ts | 3 +++ lodash/lodash.d.ts | 34 +++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index a73cc6702..f786dbc2c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -289,6 +289,9 @@ result = <_.Dictionary>_.indexBy(keys, 'dir'); result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); +result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); +result = _.invoke([123, 456], String.prototype.split, ''); + result = _.map([1, 2, 3], function(num) { return num * 3; }); result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.map(stoogesAges, 'name'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ebf5d80a8..2f2a63e40 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1257,6 +1257,28 @@ declare module _ { collection: List, whereValue: Dictionary): Dictionary; + /** + * 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( + collection: Collection, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + export function invoke( + collection: Collection, + 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( - list: Collection, - methodName: string, - ...arguments: any[]): any; + /** * A convenient version of what is perhaps the most common use-case for map: extracting a list of