react-mdl
Version:
React Components wrapper for Material Design Lite UI
25 lines (19 loc) • 405 B
JavaScript
export { 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();
}
;