Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. function splitLoop(items, process, context, callback) {
  2. var todo = items.concat();
  3.  
  4. setTimeout(function () {
  5. var start = +new Date();
  6.  
  7. do {
  8. process.call(context, todo.shift());
  9. }
  10.  
  11. while (todo.length > 0 && (+new Date() - start < 50));
  12. if (todo.length > 0) {
  13. setTimeout(arguments.callee, 25);
  14. } else {
  15. callback(items);
  16. }
  17. }, 25);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement