@@ -24,7 +24,7 @@ type Timer = string | number;
24
24
const noop = function ( ) { } ;
25
25
26
26
const SET_TIMEOUT = setTimeout ;
27
- const DISABLE_SCHEDULE = { } ;
27
+ const DISABLE_SCHEDULE = Object . freeze ( [ ] ) ;
28
28
29
29
function parseArgs ( ...args : any [ ] ) ;
30
30
function parseArgs ( ) {
@@ -453,16 +453,16 @@ export default class Backburner {
453
453
let index = findTimerItem ( target , method , this . _timers ) ;
454
454
let timerId ;
455
455
if ( index === - 1 ) {
456
- wait = parseInt ( wait , 10 ) ;
457
456
timerId = this . _later ( target , method , isImmediate ? DISABLE_SCHEDULE : args , wait ) ;
458
457
459
458
if ( isImmediate ) {
460
459
this . _join ( target , method , args ) ;
461
460
}
462
461
} else {
463
462
timerId = this . _timers [ index + 1 ] ;
464
- if ( this . _timers [ index + 4 ] !== DISABLE_SCHEDULE ) {
465
- this . _timers [ index + 4 ] = args ;
463
+ let argIndex = index + 4 ;
464
+ if ( this . _timers [ argIndex ] !== DISABLE_SCHEDULE ) {
465
+ this . _timers [ argIndex ] = args ;
466
466
}
467
467
}
468
468
@@ -491,6 +491,7 @@ export default class Backburner {
491
491
let [ target , method , args , wait , isImmediate = false ] = parseDebounceArgs ( ...arguments ) ;
492
492
493
493
let index = findTimerItem ( target , method , this . _timers ) ;
494
+
494
495
let timerId ;
495
496
if ( index === - 1 ) {
496
497
timerId = this . _later ( target , method , isImmediate ? DISABLE_SCHEDULE : args , wait ) ;
@@ -501,11 +502,12 @@ export default class Backburner {
501
502
let executeAt = this . _platform . now ( ) + wait || this . _timers [ index ] ;
502
503
this . _timers [ index ] = executeAt ;
503
504
504
- if ( this . _timers [ index + 4 ] !== DISABLE_SCHEDULE ) {
505
- this . _timers [ index + 4 ] = args ;
505
+ let argIndex = index + 4 ;
506
+ if ( this . _timers [ argIndex ] !== DISABLE_SCHEDULE ) {
507
+ this . _timers [ argIndex ] = args ;
506
508
}
507
-
508
509
timerId = this . _timers [ index + 1 ] ;
510
+
509
511
if ( index === 0 ) {
510
512
this . _reinstallTimerTimeout ( ) ;
511
513
}
@@ -618,7 +620,7 @@ export default class Backburner {
618
620
}
619
621
}
620
622
621
- private _later ( target , method , args , wait , isImmediate = false ) {
623
+ private _later ( target , method , args , wait ) {
622
624
let stack = this . DEBUG ? new Error ( ) : undefined ;
623
625
let executeAt = this . _platform . now ( ) + wait ;
624
626
let id = UUID ++ ;
@@ -642,8 +644,7 @@ export default class Backburner {
642
644
private _cancelLaterTimer ( timer ) {
643
645
for ( let i = 1 ; i < this . _timers . length ; i += 6 ) {
644
646
if ( this . _timers [ i ] === timer ) {
645
- i = i - 1 ;
646
- this . _timers . splice ( i , 6 ) ;
647
+ this . _timers . splice ( i - 1 , 6 ) ;
647
648
if ( i === 0 ) {
648
649
this . _reinstallTimerTimeout ( ) ;
649
650
}
0 commit comments