From 48b80da5d064c2424c2f154b92425fbe1afd06c7 Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Mon, 21 Oct 2013 00:56:55 -0400 Subject: [PATCH] added _(...).debounce def --- lodash/lodash-tests.ts | 16 +++++++++++++--- lodash/lodash.d.ts | 11 ++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index ebe2541424..3498507faa 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -518,19 +518,29 @@ result = <_.LoDashWrapper>_(function(a, b, c) { console.log(a + b + c); }).curry(); -var lazyLayout: Function = _.debounce(function() {}, 150); -jQuery(window).on('resize', lazyLayout); +declare var source; +result = _.debounce(function() {}, 150); jQuery('#postbox').on('click', _.debounce(function() {}, 300, { 'leading': true, 'trailing': false })); -declare var source; source.addEventListener('message', _.debounce(function() {}, 250, { 'maxWait': 1000 }), false); +result = <_.LoDashWrapper>_(function() {}).debounce(150); + +jQuery('#postbox').on('click', <_.LoDashWrapper>_(function() {}).debounce(300, { + 'leading': true, + 'trailing': false +})); + +source.addEventListener('message', <_.LoDashWrapper>_(function() {}).debounce(250, { + 'maxWait': 1000 +}), false); + result = _.defer(function() { console.log('deferred'); }); var log = _.bind(console.log, console); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 5d5b1b50d6..61c01a65b8 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2107,7 +2107,16 @@ declare module _ { export function debounce( func: Function, wait: number, - options?: DebounceSettings): Function; + options?: DebounceSettings): Function; + + interface LoDashWrapper { + /** + * @see _.debounce + **/ + debounce( + wait: number, + options?: DebounceSettings): LoDashWrapper; + } /** * Defers executing the func function until the current call stack has cleared. Additional