fetch-fic
Version: 
Package up delicious, delicious fanfic from various sources into epub ebooks ready for reading in your ereader of choice.
16 lines (14 loc) • 336 B
JavaScript
module.exports = spinGauge
function spinGauge (gauge) {
  let spinning = 0
  let spinInterval
  return P => {
    if (++spinning === 1) {
      spinInterval = setInterval(function () { gauge.pulse() }, 50)
    }
    return P.finally(function (result) {
      if (--spinning === 0) clearInterval(spinInterval)
    })
  }
}