/**
 * Manages timers so that this application can be cleanly exited
 */ export class TimerManager extends null { /**
     * A set of timeouts to clear on destroy
     */ private static storedTimeouts = new Set < NodeJS . Timeout > ( ) ; /**
     * A set of intervals to clear on destroy
     */ private static storedIntervals = new Set < NodeJS . Timeout > ( ) ; param fn param delay param args public static setTimeout < A = unknown > ( fn , delay , ... args ) { const timeout = setTimeout ( ( ) => { this . storedTimeouts . delete ( timeout ) ; fn ( ... args ) ; } , delay ) ; this . storedTimeouts . add ( timeout ) ; return timeout ; } param timeout public static clearTimeout ( timeout ) { clearTimeout ( timeout ) ; this . storedTimeouts . delete ( timeout ) ; } param fn param delay param args public static setInterval < A = unknown > ( fn , delay , ... args ) { const interval = setInterval ( fn , delay , ... args ) ; this . storedIntervals . add ( interval ) ; return interval ; } param interval public static clearInterval ( interval ) { clearInterval ( interval ) ; this . storedIntervals . delete ( interval ) ; } /**
     * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit
     */ public static destroy ( ) { for ( const i of this . storedTimeouts ) clearTimeout ( i ) ; for ( const i of this . storedIntervals ) clearInterval ( i ) ; this . storedTimeouts . clear ( ) ; this . storedIntervals . clear ( ) ; } }