async-ratelimiter
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -0,1 +1,10 @@ | ||
<a name="1.1.0"></a> | ||
# 1.1.0 (2018-07-16) | ||
* allow custom duration in .get ([f3edcf2](https://github.com/microlinkhq/async-ratelimiter/commit/f3edcf2)) | ||
* allow custom limits ([a94f501](https://github.com/microlinkhq/async-ratelimiter/commit/a94f501)) | ||
* keep responsibility of tests ([2fd9903](https://github.com/microlinkhq/async-ratelimiter/commit/2fd9903)) | ||
<a name="1.0.2"></a> | ||
@@ -2,0 +11,0 @@ ## 1.0.2 (2018-06-18) |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://documentup.com/microlinkhq/async-ratelimiter", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"main": "src/index.js", | ||
@@ -15,4 +15,4 @@ "author": { | ||
{ | ||
"name": "TJ Holowaychuk", | ||
"email": "tj@vision-media.ca" | ||
"name": "Noam Shemesh", | ||
"email": "noam@bigpanda.io" | ||
}, | ||
@@ -68,4 +68,4 @@ { | ||
{ | ||
"name": "Noam Shemesh", | ||
"email": "noam@bigpanda.io" | ||
"name": "TJ Holowaychuk", | ||
"email": "tj@vision-media.ca" | ||
}, | ||
@@ -72,0 +72,0 @@ { |
@@ -110,2 +110,15 @@ # async-ratelimiter | ||
##### max | ||
Type: `number` | ||
The maximum number of requests within `duration`. If provided, it overrides the default `max` value. This is useful for custom limits that differ between IDs. | ||
##### duration | ||
Type: `number` | ||
How long keep records of requests in milliseconds. If provided, it overrides the default `duration` value. | ||
## License | ||
@@ -112,0 +125,0 @@ |
@@ -17,6 +17,8 @@ 'use strict' | ||
async get ({ id = this.id } = {}) { | ||
async get ({ id = this.id, max = this.max, duration = this.duration } = {}) { | ||
assert(id, 'id required') | ||
assert(max, 'max required') | ||
assert(duration, 'duration required') | ||
const { db, duration, max } = this | ||
const { db } = this | ||
const key = `${this.namespace}:${id}` | ||
@@ -23,0 +25,0 @@ const now = microtime.now() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11381
44
129