Would this project be open to a PR adding asyncRemoveTokens?
sunknudsen opened this issue · 2 comments
sunknudsen commented
I have been wrapping removeTokens
in a promise (as suggested in #52) for a while.
Feels like it would be clean and useful if we implemented an asyncRemoveTokens
method.
function asyncRemoveTokens(count: number, rateLimiter: RateLimiter) {
return new Promise((resolve, reject) => {
rateLimiter.removeTokens(count, (error, remainingRequests) => {
if (error) return reject(error)
resolve(remainingRequests)
})
})
}
jhurliman commented
Sure! I think this could be a member of RateLimiter
jhurliman commented
Done in 2.0.0