Skip to content
New issue

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

Would this project be open to a PR adding asyncRemoveTokens? #63

Closed
sunknudsen opened this issue Mar 7, 2020 · 2 comments
Closed

Would this project be open to a PR adding asyncRemoveTokens? #63

sunknudsen opened this issue Mar 7, 2020 · 2 comments

Comments

@sunknudsen
Copy link

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
Copy link
Owner

Sure! I think this could be a member of RateLimiter

@jhurliman
Copy link
Owner

Done in 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants