sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.41k stars 182 forks source link

Check each batch results before continue #154

Open ThanosDi opened 3 years ago

ThanosDi commented 3 years ago

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.

filippofilip95 commented 3 years ago

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();
  }
});