We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'd like to wrap my functions like this:
let limiter: RateLimiterAbstract; //... @limiter.enforce // or for more tokens: @limiter.enforce(2) function limitedFunction() { // implementation }
And the same on RateLimiterQueue.
RateLimiterQueue
Any interest in this feature?
The text was updated successfully, but these errors were encountered:
@dmurvihill Hey, interesting approach. It could be created as a new package based on rate-limiter-flexible. After that we could add it to docs.
rate-limiter-flexible
Sorry, something went wrong.
This is the implementation:
import { RateLimiterQueue } from "rate-limiter-flexible"; export function limitWith<Args extends unknown[], Return>( queue: RateLimiterQueue, cost: number = 1, ) { return (f: (...args: Args) => Return) => { return async (...args: Args) => { await queue.removeTokens(cost); return f(...args); }; }; }
I don't really want to publish an entire NPM package just for that, or have it as a separate dependency for that matter. (anyone remember left-pad?)
left-pad
@dmurvihill Could you write a usage example? Probably, for RateLimiterRedis as it is the most popular limiter. I'll add it to the docs.
RateLimiterRedis
See the original comment for suggested usage.
No branches or pull requests
I'd like to wrap my functions like this:
And the same on
RateLimiterQueue
.Any interest in this feature?
The text was updated successfully, but these errors were encountered: