mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Fix failing _.debounce test.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -5728,14 +5728,15 @@
|
|||||||
if (!maxTimeoutId && !leading) {
|
if (!maxTimeoutId && !leading) {
|
||||||
lastCalled = stamp;
|
lastCalled = stamp;
|
||||||
}
|
}
|
||||||
var remaining = maxWait - (stamp - lastCalled);
|
var remaining = maxWait - (stamp - lastCalled),
|
||||||
if (remaining <= 0) {
|
isCalled = remaining <= 0;
|
||||||
|
|
||||||
|
if (isCalled) {
|
||||||
if (maxTimeoutId) {
|
if (maxTimeoutId) {
|
||||||
maxTimeoutId = clearTimeout(maxTimeoutId);
|
maxTimeoutId = clearTimeout(maxTimeoutId);
|
||||||
}
|
}
|
||||||
lastCalled = stamp;
|
lastCalled = stamp;
|
||||||
result = func.apply(thisArg, args);
|
result = func.apply(thisArg, args);
|
||||||
args = thisArg = null;
|
|
||||||
}
|
}
|
||||||
else if (!maxTimeoutId) {
|
else if (!maxTimeoutId) {
|
||||||
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
||||||
@@ -5745,7 +5746,10 @@
|
|||||||
timeoutId = setTimeout(delayed, wait);
|
timeoutId = setTimeout(delayed, wait);
|
||||||
}
|
}
|
||||||
if (leadingCall) {
|
if (leadingCall) {
|
||||||
|
isCalled = true;
|
||||||
result = func.apply(thisArg, args);
|
result = func.apply(thisArg, args);
|
||||||
|
}
|
||||||
|
if (isCalled && !timeoutId && !maxTimeoutId) {
|
||||||
args = thisArg = null;
|
args = thisArg = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user