1 | View Code Duplication | "use strict"; |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
2 | Object.defineProperty(exports, "__esModule", { value: true }); |
||
3 | var RateLimiter = /** @class */ (function () { |
||
4 | function RateLimiter(rateLimits) { |
||
5 | this.rateLimits = rateLimits; |
||
6 | } |
||
7 | RateLimiter.prototype.call = function (callback) { |
||
8 | this.rateLimits.forEach(function (rateLimit) { |
||
9 | if (!rateLimit.isActive()) { |
||
10 | rateLimit.startTimer(); |
||
11 | } |
||
12 | if (rateLimit.getCallsLeft() > 0) { |
||
13 | rateLimit.decrementCall(); |
||
14 | callback(); |
||
15 | } |
||
16 | }); |
||
17 | }; |
||
18 | RateLimiter.prototype.isActive = function () { |
||
19 | var active = []; |
||
20 | this.rateLimits.forEach(function (rateLimit) { |
||
21 | active.push(rateLimit.isActive()); |
||
22 | }); |
||
23 | return active; |
||
24 | }; |
||
25 | RateLimiter.prototype.callsLeft = function () { |
||
26 | var active = []; |
||
27 | this.rateLimits.forEach(function (rateLimit) { |
||
28 | active.push(rateLimit.getCallsLeft()); |
||
29 | }); |
||
30 | return active; |
||
31 | }; |
||
32 | RateLimiter.prototype.timeLeft = function () { |
||
33 | var active = []; |
||
34 | this.rateLimits.forEach(function (rateLimit) { |
||
35 | active.push(rateLimit.getTimeLeft()); |
||
36 | }); |
||
37 | return active; |
||
38 | }; |
||
39 | return RateLimiter; |
||
40 | }()); |
||
41 | exports.RateLimiter = RateLimiter; |
||
42 | //# sourceMappingURL=ratelimiter.js.map |