Add files via upload

This commit is contained in:
2021-08-18 00:12:37 -07:00
committed by GitHub
parent ecd6246099
commit 9d759573d2
55 changed files with 3098 additions and 0 deletions

20
util/randomToken.js Normal file
View File

@ -0,0 +1,20 @@
/** Used to generate file names
* @param {number} number - Number of characters the file name should be
* @returns {string} String containing file name
*/
function randomToken(number, symbols) {
// eslint-disable-next-line no-param-reassign
number = parseInt(number, 10);
let text = '';
let possible
if(symbols !== true) {
possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
} else {
possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()-_=+[]{}|;:/?><,.';
}
for (let i = 0; i < number; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
module.exports = randomToken;