-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
37 lines (29 loc) · 1.07 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// functions that are too long for the main program file
const constants = require('./constants.js');
const request = require('request-promise');
const parser = require('node-html-parser');
const aboutMessage = constants.aboutMessage;
const helpMessage = constants.helpMessage;
const startMessage = constants.startMessage;
const yesNoKeyboard = constants.yesNoKeyboard;
const creditsURL = constants.creditsURL;
const menuURL = constants.menuURL;
function shuffleArray(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports.shuffleArray = shuffleArray;
module.exports.sleep = sleep;