sindresorhus / p-limit

Run multiple promise-returning & async functions with limited concurrency
MIT License
2.06k stars 106 forks source link

Feature request: Ability to clear the queue #18

Closed cbwk closed 4 years ago

cbwk commented 4 years ago

I'm not sure if this is a feature you'd want here, happy to open a PR if so.

In addition to being able to read the values for activeCount and pendingCount, I would like also to be able to clear the queue.

The driving use case is that I would like to only run with the latest arguments if there are pending calls. E.g. I have a function that performs an expensive API based validation, and I only care about the current state of things, not the intermediary state.

Is this a feature that you believe should live here? Thanks in advance.

sindresorhus commented 4 years ago

Sure, sounds useful for when you need more control. PR welcome. Make sure to document some example use-cases.