Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let timerId = null;
- let iteration = 0;
- const initDelay = 100;
- function processBatch() {
- const items = values.slice(10 * iteration, 10 * iteration + 10);
- // function execution
- if (items.length < 10) {
- console.log(items);
- clearTimeout(timerId);
- return;
- }
- iteration += 1;
- timerId = setTimeout(processBatch, initDelay);
- }
- timerId = setTimeout(processBatch, initDelay);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement