File tree 1 file changed +10
-11
lines changed
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ function onTimeout () {
13
13
while ( idx < len ) {
14
14
const timer = fastTimers [ idx ]
15
15
16
- if ( timer . expires && fastNow >= timer . expires ) {
17
- timer . expires = 0
16
+ if ( timer . expires === 0 ) {
17
+ timer . expires = fastNow + timer . delay
18
+ } else if ( timer . expires >= 0 && fastNow >= timer . expires ) {
19
+ timer . expires = - 1
18
20
timer . callback ( timer . opaque )
19
21
}
20
22
21
- if ( timer . expires === 0 ) {
22
- timer . active = false
23
+ if ( timer . expires === - 1 ) {
24
+ timer . expires = - 2
23
25
if ( idx !== len - 1 ) {
24
26
fastTimers [ idx ] = fastTimers . pop ( )
25
27
} else {
@@ -53,27 +55,24 @@ class Timeout {
53
55
this . callback = callback
54
56
this . delay = delay
55
57
this . opaque = opaque
56
- this . expires = 0
57
- this . active = false
58
+ this . expires = - 2
58
59
59
60
this . refresh ( )
60
61
}
61
62
62
63
refresh ( ) {
63
- if ( ! this . active ) {
64
- this . active = true
64
+ if ( this . expires === - 2 ) {
65
65
fastTimers . push ( this )
66
66
if ( ! fastNowTimeout || fastTimers . length === 1 ) {
67
67
refreshTimeout ( )
68
- fastNow = Date . now ( )
69
68
}
70
69
}
71
70
72
- this . expires = fastNow + this . delay
71
+ this . expires = 0
73
72
}
74
73
75
74
clear ( ) {
76
- this . expires = 0
75
+ this . expires = - 1
77
76
}
78
77
}
79
78
You can’t perform that action at this time.
0 commit comments