"use strict";
exports.__esModule = true;
exports.loopAsync = loopAsync;
function loopAsync(turns, work, callback) {
  var currentTurn = 0;
  var isDone = false;
  function done() {
    isDone = true;
    callback.apply(this, arguments);
  }
  function next() {
    if (isDone) return;
    if (currentTurn < turns) {
      work.call(this, currentTurn++, next, done);
    } else {
      done.apply(this, arguments);
    }
  }
  next();
}