tiny-essentials
Version:
Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.
19 lines (14 loc) β’ 1.59 kB
Markdown
### π `TinyRateLimiter` Updates in v1.10.0 π―
This version brings a bunch of internal improvements and cleanup to `TinyRateLimiter`, making it faster, cleaner, and more memory-friendly. Hereβs whatβs new:
* π¦ **New memory optimization logic**: The limiter can now keep only the latest N entries per group (`#maxMemory`) to reduce memory usage. Automatically calls `onMemoryExceeded(groupId)` if defined.
* π§ͺ **Improved rate limit check**: The `isRateLimited()` method is now faster and more consistent, even when `interval` is disabled.
* π§Ό **Better cleanup system**: Groups now use either their own TTL or fallback to `maxIdle`, and the internal `_cleanup()` handles expiration gracefully.
* π **New metrics method**: `getMetrics(groupId)` now returns hit count, last hit, spacing average, and time since last hit in one call!
* π **New helpers**:
* `getAllUserMappings()` β returns user β group map as plain object π
* `getAverageHitSpacing()` β computes average time between hits
* `getTimeSinceLastHit()` β useful for time-based triggers
* β οΈ **Deprecated**: `reset(userId)` is now deprecated β use `resetUserGroup(userId)` instead.
* π **Fully isolated internals**: All core options (`interval`, `maxHits`, `maxIdle`) now throw if misconfigured. Stronger encapsulation and clearer API.
This release keeps the class drop-in compatible with previous versions but brings real performance and control benefits under scale. Enjoy! π§©π‘
**Full Changelog**: https://github.com/JasminDreasond/Tiny-Essentials/compare/1.9.2...1.10.0