mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Bump to v4.13.0.
This commit is contained in:
19
debounce.js
19
debounce.js
@@ -1,6 +1,6 @@
|
||||
import isObject from './isObject';
|
||||
import now from './now';
|
||||
import toNumber from './toNumber';
|
||||
import isObject from './isObject.js';
|
||||
import now from './now.js';
|
||||
import toNumber from './toNumber.js';
|
||||
|
||||
/** Used as the `TypeError` message for "Functions" methods. */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
@@ -65,7 +65,7 @@ function debounce(func, wait, options) {
|
||||
maxWait,
|
||||
result,
|
||||
timerId,
|
||||
lastCallTime = 0,
|
||||
lastCallTime,
|
||||
lastInvokeTime = 0,
|
||||
leading = false,
|
||||
maxing = false,
|
||||
@@ -116,7 +116,7 @@ function debounce(func, wait, options) {
|
||||
// Either this is the first call, activity has stopped and we're at the
|
||||
// trailing edge, the system time has gone backwards and we're treating
|
||||
// it as the trailing edge, or we've hit the `maxWait` limit.
|
||||
return (!lastCallTime || (timeSinceLastCall >= wait) ||
|
||||
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
||||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
||||
}
|
||||
|
||||
@@ -130,7 +130,6 @@ function debounce(func, wait, options) {
|
||||
}
|
||||
|
||||
function trailingEdge(time) {
|
||||
clearTimeout(timerId);
|
||||
timerId = undefined;
|
||||
|
||||
// Only invoke if we have `lastArgs` which means `func` has been
|
||||
@@ -143,11 +142,8 @@ function debounce(func, wait, options) {
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
if (timerId !== undefined) {
|
||||
clearTimeout(timerId);
|
||||
}
|
||||
lastCallTime = lastInvokeTime = 0;
|
||||
lastArgs = lastThis = timerId = undefined;
|
||||
lastInvokeTime = 0;
|
||||
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
||||
}
|
||||
|
||||
function flush() {
|
||||
@@ -168,7 +164,6 @@ function debounce(func, wait, options) {
|
||||
}
|
||||
if (maxing) {
|
||||
// Handle invocations in a tight loop.
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(timerExpired, wait);
|
||||
return invokeFunc(lastCallTime);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user