added _(...).debounce def

This commit is contained in:
Brian Zengel
2013-10-21 00:56:55 -04:00
parent ea6d2a70de
commit 48b80da5d0
2 changed files with 23 additions and 4 deletions

View File

@@ -518,19 +518,29 @@ result = <_.LoDashWrapper<Function>>_(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 = <Function>_.debounce(function() {}, 150);
jQuery('#postbox').on('click', <Function>_.debounce(function() {}, 300, {
'leading': true,
'trailing': false
}));
declare var source;
source.addEventListener('message', <Function>_.debounce(function() {}, 250, {
'maxWait': 1000
}), false);
result = <_.LoDashWrapper<Function>>_(function() {}).debounce(150);
jQuery('#postbox').on('click', <_.LoDashWrapper<Function>>_(function() {}).debounce(300, {
'leading': true,
'trailing': false
}));
source.addEventListener('message', <_.LoDashWrapper<Function>>_(function() {}).debounce(250, {
'maxWait': 1000
}), false);
result = <number>_.defer(function() { console.log('deferred'); });
var log = _.bind(console.log, console);

11
lodash/lodash.d.ts vendored
View File

@@ -2107,7 +2107,16 @@ declare module _ {
export function debounce(
func: Function,
wait: number,
options?: DebounceSettings): Function;
options?: DebounceSettings): Function;
interface LoDashWrapper<T> {
/**
* @see _.debounce
**/
debounce(
wait: number,
options?: DebounceSettings): LoDashWrapper<Function>;
}
/**
* Defers executing the func function until the current call stack has cleared. Additional