async-task-throttle
A simple async task throttle.
Install
$ yarn add async-task-throttle
Usage
Sample
{ return } const throttleTask = AsyncTaskThrottle // use `throttleTask` just like `task`// but up to 6 tasks are running at the same moment
Interface
AsyncTaskThrottle.create
: T
- task: the async task function.
- size: defualt 6, at the same moment, up to
size
tasks are runing, others are in the waiting queue. - max: defualt Infinity, when the length of waiting queue is greater than
max
, late tasks will be rejected instantly.