Constructor
new Token(id, data, usesRemaining, nextReset)
Token Constructor
Parameters:
Name | Type | Description |
---|---|---|
id |
string | token string |
data |
* | reserved for future use |
usesRemaining |
number | Number of uses remaining until the token is exhausted |
nextReset |
number | Time when the token can be used again even if it's exhausted (unix timestamp) |
- Source:
Methods
freeze()
Freeze the uses remaining and next reset values. Helpful for keeping stable ordering for a valid priority queue.
- Source:
invalidate()
Indicate that the token should no longer be used.
- Source:
unfreeze()
Unfreeze the uses remaining and next reset values.
- Source:
update(usesRemaining, nextReset)
Update the uses remaining and next reset time for a token.
Parameters:
Name | Type | Description |
---|---|---|
usesRemaining |
number | Number of uses remaining until the token is exhausted |
nextReset |
number | Time when the token can be used again even if it's exhausted (unix timestamp) |
- Source: