async-ratelimiter
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -0,1 +1,9 @@ | ||
<a name="1.1.2"></a> | ||
## 1.1.2 (2018-07-23) | ||
* Closes #6 ([6614d30](https://github.com/microlinkhq/async-ratelimiter/commit/6614d30)), closes [#6](https://github.com/microlinkhq/async-ratelimiter/issues/6) | ||
* old data test and delete the old ones by score ([31beaed](https://github.com/microlinkhq/async-ratelimiter/commit/31beaed)) | ||
<a name="1.1.1"></a> | ||
@@ -2,0 +10,0 @@ ## 1.1.1 (2018-07-18) |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://documentup.com/microlinkhq/async-ratelimiter", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"main": "src/index.js", | ||
@@ -15,2 +15,6 @@ "author": { | ||
{ | ||
"name": "TJ Holowaychuk", | ||
"email": "tj@vision-media.ca" | ||
}, | ||
{ | ||
"name": "Noam Shemesh", | ||
@@ -20,6 +24,2 @@ "email": "noam@bigpanda.io" | ||
{ | ||
"name": "TJ Holowaychuk", | ||
"email": "tj@vision-media.ca" | ||
}, | ||
{ | ||
"name": "Kiko Beats", | ||
@@ -26,0 +26,0 @@ "email": "josefrancisco.verdu@gmail.com" |
@@ -29,6 +29,7 @@ 'use strict' | ||
.multi() | ||
.zrange([key, 0, start, 'WITHSCORES']) | ||
.zremrangebyscore([key, 0, start]) | ||
.zcard([key]) | ||
.zadd([key, now, now]) | ||
.zrange([key, 0, 0]) | ||
.zrange([key, -max, -max]) | ||
.pexpire([key, duration]) | ||
@@ -39,6 +40,9 @@ .exec() | ||
const oldest = parseInt(res[3][1]) | ||
const oldestInRange = parseInt(res[4][1]) | ||
const resetMicro = | ||
(Number.isNaN(oldestInRange) ? oldest : oldestInRange) + duration * 1000 | ||
return { | ||
remaining: count < max ? max - count : 0, | ||
reset: Math.floor((oldest + duration * 1000) / 1000000), | ||
reset: Math.floor(resetMicro / 1000000), | ||
total: max | ||
@@ -45,0 +49,0 @@ } |
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
11961
48