This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Counter class tracks expiring event counts for specific labels. | |
// Events are added with a timestamp using `put`. | |
// Use `get_count` to get the count of valid events for a label. | |
// Use `get_total_count` to get the count of all valid events across labels. | |
// Events older than the expiration window are discarded automatically. | |
class Counter { | |
expirationWindow: number; | |
elements: { [key: string]: number[] } = {}; |