Loop over array but with time delay
npm install iterate-with-delay
- iterates over array or object but pauses inbetween
- uses callback for each element
- calls extra callback when done
delay = require('iterate-with-delay')
arr = ["one","two","three"];
delay.each( arr, { time:1000 }, function(el,k){
console.log( new Date()+"element received: "+k+" -> "+el );
},function(num){
console.log("finished processing "+num+" items");
});
delay = require('iterate-with-delay')
arr = ["one","two","three"];
delay.each( arr, { time:1000 }, function(el,k){
console.log( new Date()+"element received: "+k+" -> "+el );
},function(num){
console.log("finished processing "+num+" items");
});
ms = 500
delay = require('iterate-with-delay')
delayEach = function(arr,cb){
delay arr, {time:ms}, cb
}
// now use delayEach in your application, and
// use ms to control the delay on a global level