Ensure _.debounce passes vendor/underscore unit tests.

This commit is contained in:
John-David Dalton
2013-09-07 16:49:10 -05:00
parent eeabb47fb6
commit 2f1d8cc196

View File

@@ -5489,7 +5489,9 @@
thisArg = this;
trailingCall = trailing && (timeoutId || !leading);
if (maxWait !== false) {
if (maxWait === false) {
var leadingCall = leading && !timeoutId;
} else {
if (!maxTimeoutId && !leading) {
lastCalled = stamp;
}
@@ -5505,12 +5507,12 @@
maxTimeoutId = setTimeout(maxDelayed, remaining);
}
}
else if (leading && !timeoutId) {
result = func.apply(thisArg, args);
}
if (!timeoutId && wait !== maxWait) {
timeoutId = setTimeout(delayed, wait);
}
if (leadingCall) {
result = func.apply(thisArg, args);
}
return result;
};
}