mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
chore: eslint no-var, vars-on-top
This commit is contained in:
committed by
Julian Lam
parent
b56d9e12b5
commit
dab3b23575
@@ -30,8 +30,8 @@ module.exports = function (module) {
|
||||
throw new Error(`[[error:invalid-score, ${scores[i]}]]`);
|
||||
}
|
||||
}
|
||||
var args = [key];
|
||||
for (var i = 0; i < scores.length; i += 1) {
|
||||
const args = [key];
|
||||
for (let i = 0; i < scores.length; i += 1) {
|
||||
args.push(scores[i], String(values[i]));
|
||||
}
|
||||
await module.client.async.zadd(args);
|
||||
@@ -51,8 +51,8 @@ module.exports = function (module) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
|
||||
var batch = module.client.batch();
|
||||
for (var i = 0; i < keys.length; i += 1) {
|
||||
const batch = module.client.batch();
|
||||
for (let i = 0; i < keys.length; i += 1) {
|
||||
if (keys[i]) {
|
||||
batch.zadd(keys[i], isArrayOfScores ? scores[i] : scores, String(value));
|
||||
}
|
||||
@@ -64,7 +64,7 @@ module.exports = function (module) {
|
||||
if (!Array.isArray(data) || !data.length) {
|
||||
return;
|
||||
}
|
||||
var batch = module.client.batch();
|
||||
const batch = module.client.batch();
|
||||
data.forEach((item) => {
|
||||
if (!utils.isNumber(item[1])) {
|
||||
throw new Error(`[[error:invalid-score, ${item[1]}]]`);
|
||||
|
||||
@@ -7,11 +7,11 @@ module.exports = function (module) {
|
||||
if (!Array.isArray(keys) || !keys.length) {
|
||||
return 0;
|
||||
}
|
||||
var tempSetName = `temp_${Date.now()}`;
|
||||
const tempSetName = `temp_${Date.now()}`;
|
||||
|
||||
var interParams = [tempSetName, keys.length].concat(keys);
|
||||
const interParams = [tempSetName, keys.length].concat(keys);
|
||||
|
||||
var multi = module.client.multi();
|
||||
const multi = module.client.multi();
|
||||
multi.zinterstore(interParams);
|
||||
multi.zcard(tempSetName);
|
||||
multi.del(tempSetName);
|
||||
@@ -30,14 +30,14 @@ module.exports = function (module) {
|
||||
};
|
||||
|
||||
async function getSortedSetRevIntersect(params) {
|
||||
var sets = params.sets;
|
||||
var start = params.hasOwnProperty('start') ? params.start : 0;
|
||||
var stop = params.hasOwnProperty('stop') ? params.stop : -1;
|
||||
var weights = params.weights || [];
|
||||
const sets = params.sets;
|
||||
const start = params.hasOwnProperty('start') ? params.start : 0;
|
||||
const stop = params.hasOwnProperty('stop') ? params.stop : -1;
|
||||
const weights = params.weights || [];
|
||||
|
||||
var tempSetName = `temp_${Date.now()}`;
|
||||
const tempSetName = `temp_${Date.now()}`;
|
||||
|
||||
var interParams = [tempSetName, sets.length].concat(sets);
|
||||
let interParams = [tempSetName, sets.length].concat(sets);
|
||||
if (weights.length) {
|
||||
interParams = interParams.concat(['WEIGHTS'].concat(weights));
|
||||
}
|
||||
@@ -46,12 +46,12 @@ module.exports = function (module) {
|
||||
interParams = interParams.concat(['AGGREGATE', params.aggregate]);
|
||||
}
|
||||
|
||||
var rangeParams = [tempSetName, start, stop];
|
||||
const rangeParams = [tempSetName, start, stop];
|
||||
if (params.withScores) {
|
||||
rangeParams.push('WITHSCORES');
|
||||
}
|
||||
|
||||
var multi = module.client.multi();
|
||||
const multi = module.client.multi();
|
||||
multi.zinterstore(interParams);
|
||||
multi[params.method](rangeParams);
|
||||
multi.del(tempSetName);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (module) {
|
||||
var helpers = require('../helpers');
|
||||
const helpers = require('../helpers');
|
||||
|
||||
module.sortedSetRemove = async function (key, value) {
|
||||
if (!key) {
|
||||
@@ -30,7 +30,7 @@ module.exports = function (module) {
|
||||
};
|
||||
|
||||
module.sortedSetsRemoveRangeByScore = async function (keys, min, max) {
|
||||
var batch = module.client.batch();
|
||||
const batch = module.client.batch();
|
||||
keys.forEach(k => batch.zremrangebyscore(k, min, max));
|
||||
await helpers.execBatch(batch);
|
||||
};
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
module.exports = function (module) {
|
||||
const helpers = require('../helpers');
|
||||
module.sortedSetUnionCard = async function (keys) {
|
||||
var tempSetName = `temp_${Date.now()}`;
|
||||
const tempSetName = `temp_${Date.now()}`;
|
||||
if (!keys.length) {
|
||||
return 0;
|
||||
}
|
||||
var multi = module.client.multi();
|
||||
const multi = module.client.multi();
|
||||
multi.zunionstore([tempSetName, keys.length].concat(keys));
|
||||
multi.zcard(tempSetName);
|
||||
multi.del(tempSetName);
|
||||
@@ -31,14 +31,14 @@ module.exports = function (module) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var tempSetName = `temp_${Date.now()}`;
|
||||
const tempSetName = `temp_${Date.now()}`;
|
||||
|
||||
var rangeParams = [tempSetName, params.start, params.stop];
|
||||
const rangeParams = [tempSetName, params.start, params.stop];
|
||||
if (params.withScores) {
|
||||
rangeParams.push('WITHSCORES');
|
||||
}
|
||||
|
||||
var multi = module.client.multi();
|
||||
const multi = module.client.multi();
|
||||
multi.zunionstore([tempSetName, params.sets.length].concat(params.sets));
|
||||
multi[params.method](rangeParams);
|
||||
multi.del(tempSetName);
|
||||
|
||||
Reference in New Issue
Block a user