@@ -17,6 +17,7 @@ class ArtistClass {
1717 private chalk = { } ;
1818 private disposers = [ ] ;
1919 private timers = { } ;
20+ private invokedTimers = [ ] ;
2021
2122 constructor ( chalk = { } ) {
2223 this . registerElements ( uiElements ) ;
@@ -61,6 +62,9 @@ class ArtistClass {
6162 handlebars . registerHelper ( "eq" , function ( arg1 , arg2 , options ) {
6263 return arg1 === arg2 ? options . fn ( this ) : options . inverse ( this ) ;
6364 } ) ;
65+ handlebars . registerHelper ( "neq" , function ( arg1 , arg2 , options ) {
66+ return arg1 !== arg2 ? options . fn ( this ) : options . inverse ( this ) ;
67+ } ) ;
6468 handlebars . registerHelper ( "list" , ( context , options ) => {
6569 let ret = "" ;
6670
@@ -87,6 +91,7 @@ class ArtistClass {
8791 }
8892
8993 registerAndInvokeTimer ( id , name , func , ms ) {
94+ this . invokedTimers . push ( id ) ;
9095 if ( this . timers [ id ] ?. [ name ] ) {
9196 return ;
9297 }
@@ -108,6 +113,14 @@ class ArtistClass {
108113 } ) ;
109114 }
110115
116+ clearUnusedTimers ( ) {
117+ Object . keys ( this . timers ) . forEach ( ( t ) => {
118+ if ( ! this . invokedTimers . includes ( t ) ) {
119+ clearInterval ( this . timers [ t ] [ "intervalId" ] ) ;
120+ }
121+ } ) ;
122+ }
123+
111124 clearTimers ( ) {
112125 Object . keys ( this . timers ) . forEach ( ( key : any ) => {
113126 clearInterval ( this . timers [ key ] . intervalId ) ;
@@ -185,6 +198,8 @@ class ArtistClass {
185198 }
186199
187200 render ( tplStr : string ) {
201+ this . clearUnusedTimers ( ) ;
202+ this . invokedTimers = [ ] ;
188203 const minifiedStr = this . minifyTpl ( tplStr ) ;
189204 const compiledStr = this . compileTpl ( minifiedStr ) ;
190205 const elements = this . parseTpl ( compiledStr ) ;
0 commit comments