Here’s a loop from 0 to N with a rest of 1 second in each round.

function some_operation(Callback) {
  var Index   = 0;
  var Results = ...;

  (function relaxing_loop(){
    var Data_Entry = Data[Index];
    //do something with Data_Entry...
    //update Results...

    if (Index<N-1) {
      Index++;
      setTimeout(relaxing_loop,1000); //relax for 1 second
    }
    else {
      Callback(Results);
    }
  })();//relaxing_loop
}//some_operation
Advertisements