destructuring array assignment

This commit is contained in:
Simon Martín
2018-02-27 16:24:30 +01:00
parent 98a92f51e6
commit 85b0c63eb0
+3 -7
View File
@@ -55,11 +55,7 @@ function rateLimitMiddleware(metadataBackend, endpointGroup = null) {
return next();
}
const isBloqued = rateLimit[0];
const limit = rateLimit[1];
const remaining = rateLimit[2];
const retry = rateLimit[3];
const reset = rateLimit[4];
const [isBloqued, limit, remaining, retry, reset] = rateLimit;
res.set({
'X-Rate-Limit-Limit': limit,
@@ -139,7 +135,7 @@ function getLuaScript() {
* isBloqued, limit, remaining, retry, reset
*/
function getLowerRateLimit(ratelimits) {
/*jshint maxcomplexity:10 */
/*jshint maxcomplexity:10 */
if (!ratelimits || !Array.isArray(ratelimits) || !ratelimits.length) {
return;
}
@@ -158,7 +154,7 @@ function getLowerRateLimit(ratelimits) {
minIndex = currentIndex;
break;
}
if (minValue === undefined || ratelimit[2] < minValue) {
// smaller remaining
minIndex = currentIndex;