code: function startInterval(func, time, self) {
    const ctx = {
      timer: null,
      stopped: false
    };
  
    const cb = async () => {
      assert(ctx.timer != null);
      ctx.timer = null;
  
      try {
        await func.call(self);
      } finally {
        if (!ctx.stopped)
          ctx.timer = setTimeout(cb, time);
      }
    };
  
    ctx.timer = setTimeout(cb, time);
  
    return ctx;
  }
docs: Start an interval. Wait for promise
  to resolve on each iteration.
  @param {Function} func
  @param {Number?} time
  @param {Object?} self
  @returns {Object}