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