diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index afaaf532d..13c943c23 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -451,7 +451,7 @@ curried(1)(2)(3); curried(1, 2)(3); curried(1, 2, 3); -var lazyLayout: Function = _.debounce(calculateLayout, 150); +var lazyLayout: Function = _.debounce(function() {}, 150); jQuery(window).on('resize', lazyLayout); jQuery('#postbox').on('click', _.debounce(function() {}, 300, { @@ -464,6 +464,8 @@ source.addEventListener('message', _.debounce(function() {}, 250, { 'maxWait': 1000 }), false); +result = _.defer(function() { console.log('deferred'); }); + //////////////////////////////////////////////////////////////////////////////////////// //WHAT'S LEFT @@ -494,19 +496,10 @@ var fibonacci = _.memoize(function (n) { return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); -var log = _.bind(console.log, console); -_.delay(log, 1000, 'logged later'); - -_.defer(function () { alert('deferred'); }); - var updatePosition = () => alert('updating position...'); var throttled = _.throttle(updatePosition, 100); $(window).scroll(throttled); -var calculateLayout = () => alert('calculating layout...'); -var lazyLayout = _.debounce(calculateLayout, 300); -$(window).resize(lazyLayout); - var createApplication = () => alert('creating application...'); var initialize = _.once(createApplication); initialize(); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 6af33434e..9e4f8dd4d 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -1821,6 +1821,18 @@ declare module _ { trailing?: boolean; } + /** + * Defers executing the func function until the current call stack has cleared. Additional + * arguments will be provided to func when it is invoked. + * @param func The function to defer. + * @param args Arguments to invoke the function with. + * @return The timer id. + **/ + export function defer( + func: Function, + ...args: any[]): number; + + @@ -1928,18 +1940,6 @@ declare module _ { func: Function, ...arguments: any[]): any; - /** - * Defers invoking the function until the current call stack has cleared, similar to using setTimeout - * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without - * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on - * to the function when it is invoked. - * @param fn The function to defer. - * @param arguments Additional arguments to pass to `fn`. - **/ - export function defer( - fn: Function, - ...arguments: any[]): void; - /** * 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