loopify
Loop over a function
Usage
loopify = ;var n = 0;var { n++; console; if n > 4 // Throw null to stop looping without rejecting throw null; }// Prints// > Iteration 1// > Iteration 2// > Iteration 3// > Iteration 4// > Done!; // Add a sleep period of 50ms between callbacks; { n++; console; if n > 4 // Throw en error to reject the loopify promise. throw "One loop too many."; } // Prints// > Iteration 1// > Iteration 2// > Iteration 3// > Iteration 4// > One loop too many.;