Adding a failsafe for rndName and how seeding works on crash

This commit is contained in:
Kasper Rynning-Tønnesen
2018-08-29 13:49:34 +02:00
parent fa51a5f3b6
commit 249855e09b

View File

@@ -165,11 +165,15 @@ function rndName(seed, len) {
word = ''; word = '';
is_vowel = false; is_vowel = false;
var arr; var arr;
for (var i = 0; i < len; i++) { try {
if (is_vowel) arr = vowels; for (var i = 0; i < len; i++) {
else arr = consts; if (is_vowel) arr = vowels;
is_vowel = !is_vowel; else arr = consts;
word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)]; is_vowel = !is_vowel;
word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)];
}
} catch(e) {
return rndName(uniqid.time().toLowerCase(), len);
} }
return word; return word;
} }