diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 2eb95da46..c1c978a2b 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -501,13 +501,19 @@ var optionsPartialRight = { defaultsDeep(optionsPartialRight, _.templateSettings); -var throttled = _.throttle(updatePosition, 100); +var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { 'trailing': false })); +var helloWrap = function(name) { return 'hello ' + name; }; +var helloWrap2 = _.wrap(helloWrap, function(func) { + return 'before, ' + func('moe') + ', after'; +}); +helloWrap2(); + @@ -559,36 +565,6 @@ _.merge(mergeFood, mergeOtherFood, function(a, b) { -/////////////////////////////////////////////////////////////////////////////////////// - - - -var updatePosition = () => alert('updating position...'); -var throttled = _.throttle(updatePosition, 100); -$(window).scroll(throttled); - -var createApplication = () => alert('creating application...'); -var initialize = _.once(createApplication); -initialize(); -initialize(); - -// var notes: any[]; -// var render = () => alert("rendering..."); -// var renderNotes = _.after(notes.length, render); -// _.each(notes, (note) => note.asyncSave({ success: renderNotes })); - -var hello = function (name) { return "hello: " + name; }; -// can't use the same "hello" var otherwise typescript fails -var hello2 = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; }); -hello2(); - -var greet = function (name) { return "hi: " + name; }; -var exclaim = function (statement) { return statement + "!"; }; -var welcome = _.compose(exclaim, greet); -welcome('moe'); - -/////////////////////////////////////////////////////////////////////////////////////// - _.keys({ one: 1, two: 2, three: 3 }); _.values({ one: 1, two: 2, three: 3 }); _.pairs({ one: 1, two: 2, three: 3 }); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 287a9dcb3..46bde9b54 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1925,7 +1925,17 @@ declare module _ { wait: number, options?: ThrottleSettings): Function; - + /** + * Creates a function that provides value to the wrapper function as its first argument. + * Additional arguments provided to the function are appended to those provided to the + * wrapper function. The wrapper is executed with the this binding of the created function. + * @param value The value to wrap. + * @param wrapper The wrapper function. + * @return The new function. + **/ + export function wrap( + value: any, + wrapper: (func: Function, ...args: any[]) => any): Function; @@ -2089,26 +2099,6 @@ declare module _ { - - - - - - - - - - /** - * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows - * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it - * conditionally. - * @param fn Function to wrap. - * @param wrapper The function that will wrap `fn`. - * @return Wrapped version of `fn. - **/ - export function wrap( - fn: Function, - wrapper: (fn: Function, ...args: any[]) => any): Function;