This is an implementation similar to setInternal()
but will not start the delay/loop again until the callback has finished (presuming it returned a promise). Im interested to know if there's a better way to do this. I choose this rather than using setInterval()
because I wanted to make sure it would not start over if the callback took longer than the interval time.
The callback function will only be called once an initial delay has passed. It would be simple to add a call to cb()
before calling the loop.
Let me know what you think!