p-queue icon indicating copy to clipboard operation
p-queue copied to clipboard

Check each batch results before continue

Open ThanosDi opened this issue 4 years ago • 1 comments

Is there a way to check the batch results (based on concurrency) to determine if the queue should continue?

For example I want to check 500 urls with concurrency 10 but I'd like to know each batch result to understand if I should keep going or not.

ThanosDi avatar Jul 22 '21 14:07 ThanosDi

Maybe you could store you results to array and check if it meets conditions to stop the queue.

const results = [];

queue.on('completed', (result) => {
  results.push(result);

  if (shouldCancel(results)) {
    queue.pause();
  }
});

filippofilip95 avatar Sep 08 '21 13:09 filippofilip95