UNPKG

typed-catch-of-the-day

Version:

typescript version of wes bos' catch of the day app

23 lines (18 loc) 373 B
export function loopAsync(turns, work, callback) { let currentTurn = 0 let 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() }