Skip to content

Instantly share code, notes, and snippets.

View sombreroEnPuntas's full-sized avatar
🦕

Matías Fornés sombreroEnPuntas

🦕
View GitHub Profile
// 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[] } = {};