Skip to content

Node.js based forum software built for the modern web

refactor: remove var

Barış Soner Uşaklı05e753c73b1f
diff --git a/src/topics/fork.js b/src/topics/fork.js
index 70649af9ee..53cecfaa7c 100644
--- a/src/topics/fork.js
+++ b/src/topics/fork.js
@@ -1,13 +1,13 @@
'use strict';
-var async = require('async');
+const async = require('async');
-var db = require('../database');
-var posts = require('../posts');
-var privileges = require('../privileges');
-var plugins = require('../plugins');
-var meta = require('../meta');
+const db = require('../database');
+const posts = require('../posts');
+const privileges = require('../privileges');
+const plugins = require('../plugins');
+const meta = require('../meta');
module.exports = function (Topics) {
Topics.createTopicFromPosts = async function (uid, title, pids, fromTid) {
@@ -27,8 +27,8 @@ module.exports = function (Topics) {
pids.sort((a, b) => a - b);
- var mainPid = pids[0];
- var cid = await posts.getCidByPid(mainPid);
+ const mainPid = pids[0];
+ const cid = await posts.getCidByPid(mainPid);
const [postData, isAdminOrMod] = await Promise.all([
posts.getPostData(mainPid),
@@ -57,22 +57,20 @@ module.exports = function (Topics) {
};
Topics.movePostToTopic = async function (callerUid, pid, tid) {
- var postData;
tid = parseInt(tid, 10);
const exists = await Topics.exists(tid);
if (!exists) {
throw new Error('[[error:no-topic]]');
}
- const post = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
- if (!post || !post.tid) {
+ const postData = await posts.getPostFields(pid, ['tid', 'uid', 'timestamp', 'upvotes', 'downvotes']);
+ if (!postData || !postData.tid) {
throw new Error('[[error:no-post]]');
}
- if (post.tid === tid) {
+ if (postData.tid === tid) {
throw new Error('[[error:cant-move-to-same-topic]]');
}
- postData = post;
postData.pid = pid;
await Topics.removePostFromTopic(postData.tid, postData);
diff --git a/src/topics/recent.js b/src/topics/recent.js
index ecb626ec53..8f51c640e7 100644
--- a/src/topics/recent.js
+++ b/src/topics/recent.js
@@ -1,12 +1,12 @@
'use strict';
-var db = require('../database');
-var plugins = require('../plugins');
-var posts = require('../posts');
+const db = require('../database');
+const plugins = require('../plugins');
+const posts = require('../posts');
module.exports = function (Topics) {
- var terms = {
+ const terms = {
day: 86400000,
week: 604800000,
month: 2592000000,
@@ -33,12 +33,12 @@ module.exports = function (Topics) {
};
Topics.getLatestTidsFromSet = async function (set, start, stop, term) {
- var since = terms.day;
+ let since = terms.day;
if (terms[term]) {
since = terms[term];
}
- var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
+ const count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
return await db.getSortedSetRevRangeByScore(set, start, count, '+inf', Date.now() - since);
};