A token bucket to allow throttling for messaging applications.
npm install tokenizedTokenized
=========
Easily create and manage a bucket of tokens
npm install --save tokenizedjavascript
const TokenBucket = require('tokenized')
const bucket = new TokenBucket()
`
The constructor will accept a single token or an array of tokens. You can also instantiate
the TokenBucket class without a token if you do not have/need one right away.$3
Adds a token to your bucket
`javascript
bucket.addToken('single-token')
`
$3
Retrieves a token from your bucket
`javascript
const token = bucket.getToken()
`
If no tokens are available, token will be null$3
Adds token to your bucket at a regular interval
`javascript
bucket.addTokenAtInterval('auto-token', 5, 'seconds')
`
* token => your token to add to the bucket
* interval => default 1 (number) the frequency to add this token to the bucket
* intervalValue => default ms (string) value of the frequency number. options are:
ms / milliseconds => milliseconds
s / seconds => seconds
m / minutes => minutes
h / hours => hours
d / days => days$3
Stops the automatic adding of token that was started by using addTokenAtInterval
`javascript
TokenBucket.stopAddingToken('auto-token')
``