Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. let timerId = null;
  2. let iteration = 0;
  3. const initDelay = 100;
  4. function processBatch() {
  5. const items = values.slice(10 * iteration, 10 * iteration + 10);
  6.  
  7. // function execution
  8.  
  9. if (items.length < 10) {
  10. console.log(items);
  11. clearTimeout(timerId);
  12. return;
  13. }
  14.  
  15. iteration += 1;
  16. timerId = setTimeout(processBatch, initDelay);
  17.  
  18. }
  19.  
  20. timerId = setTimeout(processBatch, initDelay);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement