Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. function eachAsync(collection, iterator, callback) {
  2. var iterate = function(i) {
  3. setTimeout(function() {
  4. iterator(collection[i]);
  5. if (i < collection.length-1) {
  6. iterate(i + 1);
  7. } else {
  8. if(callback) callback();
  9. }
  10. }, 0);
  11. };
  12. iterate(0 );
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement