From 557389c808de93b9534419a8f386f4c5e422edcc Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Fri, 18 Oct 2013 23:55:30 -0400 Subject: [PATCH] added _.partial definitions, more forgotten type castings in tests --- lodash/lodash-tests.ts | 10 +++- lodash/lodash.d.ts | 125 +++++++++++++++++++++-------------------- 2 files changed, 70 insertions(+), 65 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 5d086b9ce..d6d98230c 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -469,7 +469,7 @@ result = _.defer(function() { console.log('deferred'); }); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); -var fibonacci = _.memoize(function(n) { +var fibonacci = _.memoize(function(n) { return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); @@ -478,16 +478,20 @@ var data = { 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function(name) { return data[name]; }, _.identity); +var stooge = _.memoize(function(name) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; stooge('curly'); -var initialize = _.once(function(){ }); +var initialize = _.once(function(){ }); initialize(); initialize(); +var greetPartial = function(greeting, name) { return greeting + ' ' + name; }; +var hi = _.partial(greetPartial, 'hi'); +hi('moe'); + //////////////////////////////////////////////////////////////////////////////////////// //WHAT'S LEFT //////////////////////////////////////////////////////////////////////////////////////// diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3ea1b4813..c27b5ca9c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1868,74 +1868,75 @@ declare module _ { **/ export function once(func: Function): Function; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /** - * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. - * A close cousin of bind. - * @param fn Function to partially fill in arguments. - * @param arguments The partial arguments. - * @return `fn` with partially filled in arguments. + * Creates a function that, when called, invokes func with any additional partial arguments + * prepended to those provided to the new function. This method is similar to _.bind except + * it does not alter the this binding. + * @param func The function to partially apply arguments to. + * @param args Arguments to be partially applied. + * @return The new partially applied function. **/ export function partial( fn: Function, ...arguments: any[]): Function; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, * will only actually call the original function at most once per every wait milliseconds. Useful for