author Santo Pfingsten
 *  see https export default class DelayedExecution { private callback : ( ) => void ; private instance : ReturnType < typeof setTimeout > | null = null ; constructor ( callback ) { this . callback = callback ; this . execute = this . execute . bind ( this ) ; } public restart ( ms ) { this . cancel ( ) ; this . instance = setTimeout ( this . execute , ms ) ; } public execute ( ) { this . cancel ( ) ; this . callback ( ) ; } public cancel ( ) { if ( this . instance ) { clearTimeout ( this . instance ) ; this . instance = null ; } } }