File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 9436
9436
timerId = setTimeout ( timerExpired , wait ) ;
9437
9437
return invokeFunc ( lastCallTime ) ;
9438
9438
}
9439
+ if ( timerId === undefined ) {
9440
+ timerId = setTimeout ( timerExpired , wait ) ;
9441
+ }
9439
9442
return result ;
9440
9443
}
9441
9444
debounced . cancel = cancel ;
Original file line number Diff line number Diff line change 4248
4248
}, 1);
4249
4249
});
4250
4250
4251
+ QUnit.test('should queue a trailing call for subsequent debounced calls after `maxWait`', function(assert) {
4252
+ assert.expect(1);
4253
+
4254
+ var done = assert.async();
4255
+
4256
+ var callCount = 0;
4257
+
4258
+ var debounced = _.debounce(function() {
4259
+ ++callCount;
4260
+ }, 64, { 'maxWait': 64 });
4261
+
4262
+ debounced();
4263
+
4264
+ lodashStable.times(20, function(index) {
4265
+ setTimeout(debounced, 54 + index);
4266
+ });
4267
+
4268
+ setTimeout(function() {
4269
+ assert.strictEqual(callCount, 2);
4270
+ done();
4271
+ }, 160);
4272
+ });
4273
+
4251
4274
QUnit.test('should cancel `maxDelayed` when `delayed` is invoked', function(assert) {
4252
4275
assert.expect(2);
4253
4276
You can’t perform that action at this time.
0 commit comments