Add function for generating random usernames

Not used yet.
This commit is contained in:
N-Pex 2020-12-10 15:12:40 +01:00
parent 6db4365b87
commit b46b06b308
2 changed files with 22 additions and 0 deletions

View file

@ -279,6 +279,26 @@ class Util {
reader.readAsArrayBuffer(file);
});
}
/** Generate a random user name */
randomUser() {
return this.randomString(
12,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
);
}
// From here: https://stackoverflow.com/questions/1349404/generate-random-string-characters-in-javascript
randomString(length, characters) {
var result = "";
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(
Math.floor(Math.random() * charactersLength)
);
}
return result;
}
}
export default new Util();