jhurliman / node-rate-limiter

A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled
MIT License
1.51k stars 135 forks source link

No way to calculate amount of time until the next drip? #88

Open KevinNovak opened 2 years ago

KevinNovak commented 2 years ago

I am using this package to create cooldowns for certain commands that users run, and I want to be able to tell the user the amount of time they have to wait until they can run the command again.

I can't seem to find any way that this is possible with the current code.

We can get:

But there does not seem to be a way to tell what the current time within an interval is. Therefore I cannot calculate how much time is left before the next drip.

EDIT: It seems like this could be solved by giving us access to the internal clock, specifically getMilliseconds(). Additionally, maybe we could have a method to getTimeToNextDrip() or getTimeToNextInterval()?