date class Timer { returns { void } date timeout ( interval , args ? ) { return new Promise ( ( resolve ) => { setTimeout ( ( ) => { resolve ( args ) ; } , interval ) ; } ) ; } returns { void } date inTheEnd ( ) { return this . timeout ( 0 ) ; } param { Number } interval param { Function } callback returns { Object } date interval ( interval , callback ) { this . timeout ( interval ) . then ( ( ) => { typeof callback === 'function' && callback ( ) !== false && this . interval ( interval , callback ) ; } ) ; return { then : c => callback = c } ; } returns { void } date start ( ) { const startDate = new Date ( ) ; return { stop ( ) { const stopDate = new Date ( ) ; return stopDate . getTime ( ) - startDate . getTime ( ) ; } } ; } } export default new Timer ( ) ;