Closed bieron closed 3 years ago
We need it also for real life - we are creating a token bucket on demand (per user), and want the user to be able to work with it immediately.
This is similar to https://github.com/jhurliman/node-rate-limiter/issues/18, which propose a different approach which I think is more generic.
BTW, I now see that event the code of RateLimiter is manually filling the TokenBucket after creating it (in https://github.com/jhurliman/node-rate-limiter/blob/master/lib/rateLimiter.js#L20-L21).
I guess this means that this functionality should be exposed.
@jhurliman, @SirR4T what do you say? Maybe make the new option part of an "options" argument of the constructor to allow additional options in the future? Or, just expose the "content" member in the Typescript?
@yoshigev I am leaning toward the second option of exposing content
in the Typescript defs.
content
is now exposed in the 2.0.0 rewrite
Hello.
The reason I need is solely for testing sake, so I'll welcome any other suggestion for how to elegantly create a TokenBucket "ready to spill" without waiting for it or ugly monkeypatching. Still, I think it's a valuable functionality, and it maintains previous behavior.
Feel free to modify this PR of course.