mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Ensure _.debounce and _.throttle reset lastCall after cancelling.
This commit is contained in:
@@ -7792,6 +7792,7 @@
|
|||||||
if (maxTimeoutId) {
|
if (maxTimeoutId) {
|
||||||
clearTimeout(maxTimeoutId);
|
clearTimeout(maxTimeoutId);
|
||||||
}
|
}
|
||||||
|
lastCalled = 0;
|
||||||
maxTimeoutId = timeoutId = trailingCall = undefined;
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
test/test.js
23
test/test.js
@@ -15889,6 +15889,29 @@
|
|||||||
QUnit.start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
asyncTest('_.' + methodName + ' should reset `lastCalled` after cancelling', 3, function() {
|
||||||
|
if (!(isRhino && isModularize)) {
|
||||||
|
var callCount = 0;
|
||||||
|
|
||||||
|
var funced = func(function() {
|
||||||
|
return ++callCount;
|
||||||
|
}, 32, { 'leading': true });
|
||||||
|
|
||||||
|
strictEqual(funced(), 1);
|
||||||
|
funced.cancel();
|
||||||
|
strictEqual(funced(), 2);
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
strictEqual(callCount, 2);
|
||||||
|
QUnit.start();
|
||||||
|
}, 64);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(3);
|
||||||
|
QUnit.start();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user