Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added an example for getTokensRemaining in README.d

  • Loading branch information...
commit 6c26dfba6ed2e5c1cf1824b34159565b764e7a86 1 parent e5c12c7
luto luto authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 README.md
10 README.md
View
@@ -68,6 +68,16 @@ limiter.removeTokens(1, function(err, remainingRequests) {
});
```
+To get the number of remaining tokens **outside** the `removeTokens`-callback
+simply use the `getTokensRemaining`-method.
+```javascript
+var RateLimiter = require('limiter').RateLimiter;
+var limiter = new RateLimiter(1, 250);
+
+// returns 1 since we did not remove a token and our number of tokens per interval is 1
+limiter.getTokensRemaining();
+```
+
Uses the token bucket directly to throttle at the byte level:
```javascript
Please sign in to comment.
Something went wrong with that request. Please try again.