()
| 14 | private readonly hourLimiter = new Limiter({ tokensPerInterval: 12, interval: "hour" }) |
| 15 | |
| 16 | public canTry(): boolean { |
| 17 | // Note: we must check using >= 1 because technically when there are no tokens left |
| 18 | // you get back a number like 0.00013333333333333334 |
| 19 | // which would cause fail if the logic were > 0 |
| 20 | return this.minuteLimiter.getTokensRemaining() >= 1 || this.hourLimiter.getTokensRemaining() >= 1 |
| 21 | } |
| 22 | |
| 23 | public removeToken(): boolean { |
| 24 | return this.minuteLimiter.tryRemoveTokens(1) || this.hourLimiter.tryRemoveTokens(1) |
no outgoing calls
no test coverage detected