diff --git a/lodash.src.js b/lodash.src.js index 70c18c009..c27435086 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -7376,7 +7376,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to debounce. - * @param {number} wait The number of milliseconds to delay. + * @param {number} [wait=0] The number of milliseconds to delay. * @param {Object} [options] The options object. * @param {boolean} [options.leading=false] Specify invoking on the leading * edge of the timeout. @@ -7434,7 +7434,7 @@ if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - wait = wait < 0 ? 0 : wait; + wait = wait < 0 ? 0 : (+wait || 0); if (options === true) { var leading = true; trailing = false; @@ -7955,7 +7955,7 @@ * @memberOf _ * @category Function * @param {Function} func The function to throttle. - * @param {number} wait The number of milliseconds to throttle invocations to. + * @param {number} [wait=0] The number of milliseconds to throttle invocations to. * @param {Object} [options] The options object. * @param {boolean} [options.leading=true] Specify invoking on the leading * edge of the timeout. diff --git a/test/test.js b/test/test.js index 61818fef0..de75388fc 100644 --- a/test/test.js +++ b/test/test.js @@ -13889,6 +13889,28 @@ ok(pass); }); + asyncTest('_.' + methodName + ' should have a default `wait` of `0`', 1, function() { + if (!(isRhino && isModularize)) { + var callCount = 0; + + var funced = func(function() { + callCount++; + }); + + funced(); + + setTimeout(function() { + funced(); + strictEqual(callCount, isDebounce ? 1 : 2); + QUnit.start(); + }, 32); + } + else { + skipTest(); + QUnit.start(); + } + }); + asyncTest('_.' + methodName + ' should call `func` with the correct `this` binding', 1, function() { if (!(isRhino && isModularize)) { var object = {