From 5878ecbd3e31ecff49a7363472c415de31d521c1 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Fri, 18 Oct 2013 23:06:21 -0400 Subject: [PATCH] added _.curry definition --- lodash/lodash-tests.ts | 8 ++++++++ lodash/lodash.d.ts | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5b60863f6..3b68208dd 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -443,6 +443,14 @@ var createCallbackObj = { name: 'Joe' }; var pluckCallback: () => any = _.createCallback('name'); var whereCallback: () => boolean = _.createCallback(createCallbackObj); +var curried: Function = _.curry(function(a, b, c) { + console.log(a + b + c); +}); + +curried(1)(2)(3); +curried(1, 2)(3); +curried(1, 2, 3); + //////////////////////////////////////////////////////////////////////////////////////// //WHAT'S LEFT diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index fa6a60e3e..9f070803c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1780,6 +1780,20 @@ declare module _ { thisArg?: any, argCount?: number): () => boolean; + /** + * Creates a function which accepts one or more arguments of func that when invoked either + * executes func returning its result, if all func arguments have been provided, or returns + * a function that accepts one or more of the remaining func arguments, and so on. The arity + * of func can be specified if func.length is not sufficient. + * @param func The function to curry. + * @param arity The arity of func. + * @return The new curried function. + **/ + export function curry( + func: Function, + arity?: number): Function; + +