Create a new instance of Limiter
Optional
options: LimiterOptionsThe limiter options
Returns the limiter options
Returns the number of pending jobs
Returns the number of jobs in the queue
Register an event listener over the done
event, which is emitted when a task has ended, either
due to completion or failure.
done
event
Done event listener
Register an event listener over the refill
event, which is emitted when queue bucket is refilled
refill
event
Refill event listener
Register an event listener over the seed
event, which is emitted when queue is empty and a
new task is added
seed
event
The listener function to add
Executes a task and returns a promise that resolves when the task is done
The task to execute
A promise that resolves when the task is done
Executes a task and returns a promise that resolves when the task is done
The task to execute
Optional
taskArgs: TaskArgumentsThe arguments for the task
Optional
options: TaskOptions<U>The options for the job
A promise that resolves when the task is done
Removes the specified listener from the listener array for the done
event.
done
event
The listener function to remove
Removes the specified listener from the listener array for the refill
event.
refill
event
The listener function to remove
Removes the specified listener from the listener array for the seed
event.
seed
event
The listener function to remove
Register an event listener over the done
event, which is emitted when a task has ended, either
due to completion or failure.
done
event
Done event listener
Register an event listener over the refill
event, which is emitted when queue bucket is refilled
refill
event
Refill event listener
Register an event listener over the seed
event, which is emitted when queue is empty and a
new task is added
seed
event
The listener function to add
Registers a one-time event listener over the done
event, which is emitted when a task has
ended, either due to completion or failure.
done
event
Done event listener
Registers a one-time event listener over the refill
event, which is emitted when queue bucket
is refilled
refill
event
Refill event listener
Registers a one-time event listener over the seed
event, which is emitted when queue is empty
and a new task is added
seed
event
The listener function to add
Registers a event listener over the done
event, at the beginning of the listeners array,
which is emitted when a task has ended, either due to completion or failure.
done
event
Done event listener
Registers a event listener over the refill
event, at the beginning of the listeners array,
which is emitted when queue bucket is refilled
refill
event
Refill event listener
Registers a event listener over the seed
event, at the beginning of the listeners array, which
is emitted when queue is empty and a new task is added
seed
event
The listener function to add
Registers a one-time event listener over the done
event, at the beginning of the listeners
array, which is emitted when a task has ended, either due to completion or failure.
done
event
Done event listener
Registers a one-time event listener over the refill
event, at the beginning of the listeners
array, which is emitted when queue bucket is refilled
refill
event
Refill event listener
Registers a one-time event listener over the seed
event, at the beginning of the listeners
array, which is emitted when queue is empty and a new task is added
seed
event
The listener function to add
Removes all listeners, or those of the specified event.
Optional
event: "done"done
event
Removes all listeners, or those of the specified event.
Optional
event: "refill"refill
event
Removes all listeners, or those of the specified event.
Optional
event: "seed"seed
event
Removes the specified listener from the listener array for the done
event.
done
event
The listener function to remove
Removes the specified listener from the listener array for the refill
event.
refill
event
The listener function to remove
Removes the specified listener from the listener array for the seed
event.
seed
event
The listener function to remove
Schedules a task to be executed by the limiter
The task to schedule
The task handler
Schedules a task to be executed by the limiter
The task to schedule
Optional
taskArgs: TaskArgumentsThe arguments for the task
Optional
options: TaskOptions<U>The options for the job
The task handler
A limiter is a queue system that allows you to control the rate of job processing. It can be used to limit the number of concurrent jobs, the delay between each job, the maximum number of jobs in the queue, and the strategy to use when the queue length reaches highWater.