diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 38ef58113..93dd23ef7 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -423,6 +423,22 @@ objectBindKey.greet = function(greeting) { funcBindKey(); +var realNameMap = { + 'curly': 'jerome' +}; + +var format = function(name) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +}; + +var greet = function(formatted) { + return 'Hiya ' + formatted + '!'; +}; + +var welcome = _.compose(greet, format); +welcome('curly'); + diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index edabe3217..368dafaf4 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1746,6 +1746,15 @@ declare module _ { key: string, ...args: any[]): Function; + /** + * Creates a function that is the composition of the provided functions, where each function + * consumes the return value of the function that follows. For example, composing the functions + * f(), g(), and h() produces f(g(h())). Each function is executed with the this binding of the + * composed function. + * @param funcs Functions to compose. + * @return The new composed function. + **/ + export function compose(...funcs: Function[]): Function; @@ -1928,13 +1937,7 @@ declare module _ { fn: Function, wrapper: (fn: Function, ...args: any[]) => any): Function; - /** - * Returns the composition of a list of functions, where each function consumes the return value of the - * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())). - * @param functions List of functions to compose. - * @return Composition of `functions`. - **/ - export function compose(...functions: Function[]): Function; + /********** * Objects *