score:0

Accepted answer

That depends on what you mean by "wait for the callback to finish". Is it a very slow function that runs synchronously (and thus continuously)? Then yes.

d3.timer(() => {
  const now = Date.now();
  while(Date.now() - now < 1000) {}; // do nothing, but keep the process engaged
  console.log("Ping");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>

But if it is an asynchronous function - like an API call - which deschedules the process, then no.

let i = 0,
  j = 0;
d3.timer(() => {
  // Break after 100 iterations
  if(j > 100) {
    return true;
  }

  // do nothing, but release the process
  // so the thread can go do other things
  console.log("Scheduled promise", j);
  j++;
  
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(i);
      console.log("Resolved promise", i);
      i++;
    }, 1000);
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>


Related Query

More Query from same tag