Clear timeoutId if func is called in _.debounce.

This commit is contained in:
John-David Dalton
2013-11-05 21:41:13 -08:00
parent 06d12b376c
commit 1bb7c31ee4

View File

@@ -5737,21 +5737,22 @@
}
lastCalled = stamp;
result = func.apply(thisArg, args);
args = thisArg = null;
}
else if (!maxTimeoutId) {
maxTimeoutId = setTimeout(maxDelayed, remaining);
}
}
if (!timeoutId && wait !== maxWait) {
if (isCalled & timeoutId) {
timeoutId = clearTimeout(timeoutId);
}
else if (!timeoutId && wait !== maxWait) {
timeoutId = setTimeout(delayed, wait);
}
if (leadingCall) {
isCalled = true;
result = func.apply(thisArg, args);
}
if (isCalled && !timeoutId && !maxTimeoutId) {
args = thisArg = null;
}
return result;
};
}