index.js
function LooseInterval(fn, interval, callback) {
  if (!(this instanceof LooseInterval)) return new LooseInterval(fn, interval, callback)
  if (typeof fn != "function") throw new Error("LooseInterval requires a function")
  if (typeof interval == "function") {
    callback = interval
    interval = null
  }

  this.fn = fn
  this.interval = interval
  this.callback = callback

  EventEmitter.call(this)

  this._running = false
  if (interval != null) this.start(interval)
}
function LooseInterval(fn, interval, callback) {
  if (!(this instanceof LooseInterval)) return new LooseInterval(fn, interval, callback)
  if (typeof fn != "function") throw new Error("LooseInterval requires a function")
  if (typeof interval == "function") {
    callback = interval
    interval = null
  }

  this.fn = fn
  this.interval = interval
  this.callback = callback

  EventEmitter.call(this)

  this._running = false
  if (interval != null) this.start(interval)
}
function LooseInterval ( fn , interval , callback ) { if ( ! ( this instanceof LooseInterval ) ) return new LooseInterval ( fn , interval , callback ) if ( typeof fn != "function" ) throw new Error ( "LooseInterval requires a function" ) if ( typeof interval == "function" ) { callback = interval interval = null } this . fn = fn this . interval = interval this . callback = callback EventEmitter . call ( this ) this . _running = false if ( interval != null ) this . start ( interval ) }
Create a loose-interval repeated task. Like setInterval but will reschedule when the task
finishes to avoid overlapping tasks. Your function must provide a callback to alert its
completion.
@param {Function} fn       The function to repeatedly call. Must provide a callback. fn(cb)
@param {Number}   interval Millisecond interval to wait between the function's end next call.
@param {Function} callback Callback to forward results to after each run.
Create a loose - interval repeated task . Like setInterval but will reschedule when the task finishes to avoid overlapping tasks . Your function must provide a callback to alert its completion .