@@ -101,7 +101,7 @@ type TTimerMeasurable = {
101101} ;
102102type TTimerTimeout = TTimerMeasurable & {
103103 type : ETimer . TIMEOUT ;
104- delay : number ;
104+ timeout : number ;
105105} ;
106106type TTimerAnimation = TTimerMeasurable & {
107107 type : ETimer . ANIMATION ;
@@ -112,7 +112,7 @@ type TTimerIdle = TTimerMeasurable & {
112112} ;
113113type TTimerTask = TTimerMeasurable & {
114114 type : ETimer . TASK ;
115- delay : number ;
115+ timeout : number ;
116116 priority ?: TTaskPriority ;
117117} ;
118118type TTimerOptions =
@@ -159,7 +159,6 @@ const timerApi = __mirror__
159159 * in javascript event-loop
160160 */
161161export class Timer {
162- delay : number = 0 ;
163162 timeout : number = 0 ;
164163 /** callback's self-time in milliseconds */
165164 callbackSelfTime : number = - 1 ;
@@ -175,10 +174,9 @@ export class Timer {
175174
176175 if (
177176 this . #options. type === ETimer . TIMEOUT ||
177+ this . #options. type === ETimer . IDLE ||
178178 this . #options. type === ETimer . TASK
179179 ) {
180- this . delay = this . #options. delay ;
181- } else if ( this . #options. type === ETimer . IDLE ) {
182180 this . timeout = this . #options. timeout ;
183181 }
184182
@@ -198,7 +196,7 @@ export class Timer {
198196 this . #handler = timerApi . setTimeout ( ( ) => {
199197 this . #handler = 0 ;
200198 this . trigger ( ...args ) ;
201- } , this . delay ) ;
199+ } , this . timeout ) ;
202200 } else if (
203201 this . #options. type === ETimer . ANIMATION
204202 ) {
@@ -218,7 +216,7 @@ export class Timer {
218216 // nullifying AFTER the trigger to allow use-case when aborting from the callback
219217 this . #abortController = null ;
220218 } , {
221- delay : this . delay ,
219+ delay : this . timeout ,
222220 signal : this . #abortController. signal ,
223221 priority : this . #options. priority ,
224222 } ) . catch ( NOOP ) ;
@@ -282,7 +280,7 @@ export class Fps {
282280 #eachSecond: Timer ;
283281
284282 constructor ( callback ?: ( value : number ) => void ) {
285- this . #eachSecond = new Timer ( { type : ETimer . TIMEOUT , delay : 1e3 } , ( ) => {
283+ this . #eachSecond = new Timer ( { type : ETimer . TIMEOUT , timeout : 1e3 } , ( ) => {
286284 this . value = this . #ticks;
287285 this . #ticks = 0 ;
288286 callback ?.( this . value ) ;
0 commit comments