export default function interval ( fn , duration ) { let timer ; const start = ( ) => { timer = setTimeout ( ( ) => { try { fn ( ) ; } catch ( e ) { throw e ; } finally { start ( ) ; } } , duration ) ; } ; start ( ) ; return ( ) => { clearTimeout ( timer ) ; } ; }