Skip to content

Commit 65431d6

Browse files
authored
Merge pull request #10 from exo-do/features/refactor-async-await
huge refactor to remove callbacks
2 parents 182b33e + 2ca589d commit 65431d6

10 files changed

Lines changed: 399 additions & 668 deletions

Config.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var MIN_POSTS_TO_UPVOTE = 20,
1+
let MIN_POSTS_TO_UPVOTE = 20,
22
MIN_DAYS_TO_UPVOTE = 7,
33
MIN_POSTS_TO_DOWNVOTE = 50,
44
MIN_DAYS_TO_DOWNVOTE = 15,
@@ -15,7 +15,7 @@ var MIN_POSTS_TO_UPVOTE = 20,
1515
MAX_POINTS_FOR_DOWNVOTE = 10,
1616
MAX_POST_AGE_DAYS = 0; // 0 means disabled
1717

18-
var Config = {
18+
let Config = {
1919
minPostToDownvote: function () {
2020
return MIN_POSTS_TO_DOWNVOTE;
2121
},
@@ -38,9 +38,9 @@ var Config = {
3838
return MAX_VOTES_TO_SAME_USER_PER_MONTH;
3939
},
4040
maxVotesPerUser: function (reputation) {
41-
var MIN = 5,
41+
let MIN = 5,
4242
MAX = 50;
43-
var calculatedVotesPerUser = Math.floor(reputation / 10);
43+
let calculatedVotesPerUser = Math.floor(reputation / 10);
4444
if (calculatedVotesPerUser < MIN) {
4545
calculatedVotesPerUser = MIN;
4646
} else if (calculatedVotesPerUser > MAX) {
@@ -77,18 +77,18 @@ var Config = {
7777
return REP_LOG_NAMESPACE + ":user:" + voterId + ":thread:" + topicId;
7878
},
7979
getPerAuthorLogId: function (voterId, authorId) {
80-
var now = new Date();
81-
var month = (now.getMonth() + 1) + "-" + now.getFullYear();
80+
let now = new Date();
81+
let month = (now.getMonth() + 1) + "-" + now.getFullYear();
8282
return REP_LOG_NAMESPACE + ":user:" + voterId + ":author:" + authorId + ":month:" + month;
8383
},
8484
getPerUserLogId: function (voterId) {
85-
var now = new Date();
86-
var today = now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
85+
let now = new Date();
86+
let today = now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
8787
return REP_LOG_NAMESPACE + ":user:" + voterId + ":day:" + today;
8888
},
8989
getPerUserAndTypeLogId: function (voterId, voteType) {
90-
var now = new Date();
91-
var today = now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
90+
let now = new Date();
91+
let today = now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
9292
return REP_LOG_NAMESPACE + ":user:" + voterId + ":day:" + today + ':type:' + voteType;
9393
},
9494
getDisabledCategories: function () {
@@ -98,7 +98,7 @@ var Config = {
9898
return MAX_POST_AGE_DAYS;
9999
},
100100
getSettings: function () {
101-
var settings = {};
101+
let settings = {};
102102
settings.minPostsToUpvote = MIN_POSTS_TO_UPVOTE;
103103
settings.minDaysToUpvote = MIN_DAYS_TO_UPVOTE;
104104
settings.minPostsToDownvote = MIN_POSTS_TO_DOWNVOTE;
@@ -137,7 +137,7 @@ var Config = {
137137
};
138138

139139
function intArray(arr) {
140-
for (var i = 0; i < arr.length; i++) {
140+
for (let i = 0; i < arr.length; i++) {
141141
arr[i] = parseInt(arr[i], 10);
142142
}
143143
return arr;

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
### Rule #1
1212
**Upvoting** In order to upvote, the user must have
13-
- {MIN_POSTS_TO_UPVOTE} posts or more
14-
- at least {MIN_DAYS_TO_UPVOTE} days since registration
13+
- `{MIN_POSTS_TO_UPVOTE}` posts or more
14+
- at least `{MIN_DAYS_TO_UPVOTE}` days since registration
1515

1616
### Rule #2
1717
**Downvoting** In order to downvote, the user must have
18-
- {MIN_POSTS_TO_DOWNVOTE} posts or more
19-
- at least {MIN_DAYS_TO_DOWNVOTE} since registration
20-
- {MIN_REPUTATION_TO_DOWNVOTE} reputation or more
18+
- `{MIN_POSTS_TO_DOWNVOTE}` posts or more
19+
- at least `{MIN_DAYS_TO_DOWNVOTE}` since registration
20+
- `{MIN_REPUTATION_TO_DOWNVOTE}` reputation or more
2121

2222
### Rule #3
23-
Downvoting costs {DOWNVOTE_PENALIZATION} reputation (user who votes loses some reputation)
23+
Downvoting costs `{DOWNVOTE_PENALIZATION}` reputation (user who votes loses some reputation)
2424

2525
### Rule #4
2626
One user can't vote (up or down) more than `X` times a day, being `X = reputation/10`. With a minimum of 5 and a max of 50

0 commit comments

Comments
 (0)