Constructor
new Bucket(tokenLimit, interval, optionsopt)
Construct a Bucket
Properties:
| Name | Type | Description |
|---|---|---|
interval |
Number
|
How long (in ms) to wait between clearing used tokens |
lastReset |
Number
|
Timestamp of last token clearing |
lastSend |
Number
|
Timestamp of last token consumption |
tokenLimit |
Number
|
The max number tokens the bucket can consume per interval |
tokens |
Number
|
How many tokens the bucket has consumed in this interval |
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokenLimit |
Number
|
The max number of tokens the bucket can consume per interval |
||||||||||||||||
interval |
Number
|
How long (in ms) to wait between clearing used tokens |
||||||||||||||||
options |
Object
|
<optional> |
Optional parameters
|
Methods
queue(func, priorityopt)
Queue something in the Bucket
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
func |
function
|
A callback to call when a token can be consumed |
||
priority |
Boolean
|
<optional> |
false |
Whether or not the callback should use reserved tokens |