mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Adding a failsafe for rndName and how seeding works on crash
This commit is contained in:
@@ -165,11 +165,15 @@ function rndName(seed, len) {
|
||||
word = '';
|
||||
is_vowel = false;
|
||||
var arr;
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (is_vowel) arr = vowels;
|
||||
else arr = consts;
|
||||
is_vowel = !is_vowel;
|
||||
word += arr[(seed[i%seed.length].charCodeAt()+i) % (arr.length-1)];
|
||||
try {
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (is_vowel) arr = vowels;
|
||||
else arr = consts;
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user