forked from greguz/porro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersistent-porro.d.mts
30 lines (30 loc) · 1.02 KB
/
persistent-porro.d.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
export class PersistentPorro extends Porro {
/**
* Hydrate the bucket with given state
*
* @param {Object} state
* @param {number} state.bucketSize - Number of tokens available inside the bucket.
* @param {number} state.interval - Time interval in ms when tokens are refilled.
* @param {number} state.tokensPerInterval - Number of refilled tokens per interval.
* @param {number} state.tokens - Number of tokens available inside the bucket during save.
* @param {number} state.lastRequest - milliseconds of last request.
*/
static Hydrate(state: {
bucketSize: number;
interval: number;
tokensPerInterval: number;
tokens: number;
lastRequest: number;
}): PersistentPorro;
/**
* Create the bucke and store it in the database
*/
getState(): {
bucketSize: number;
interval: number;
tokensPerInterval: number;
tokens: number;
lastRequest: number;
};
}
import { Porro } from "./porro.mjs";