Refactor models (merge Players in Games), add cursor to correspondance games. Finishe...
[vchess.git] / server / utils / tokenGenerator.js
index b549198..d89b4cc 100644 (file)
@@ -1,13 +1,11 @@
-function randString()
-{
-       return Math.random().toString(36).substr(2); // remove `0.`
+function randString() {
+  return Math.random().toString(36).substr(2); // remove `0.`
 }
 
-module.exports = function(tlen)
-{
-       let res = "";
-       let nbRands = Math.ceil(tlen/10); //10 = min length of a rand() string
-       for (let i = 0; i < nbRands; i++)
-               res += randString();
-       return res.substr(0, tlen);
+module.exports = function(tokenLength) {
+  let res = "";
+  // 10 = min length of a rand() string
+  const nbRands = Math.ceil(tokenLength/10);
+  for (let i = 0; i < nbRands; i++) res += randString();
+  return res.substr(0, tokenLength);
 }