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 = '';
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user