15 lines
340 B
TypeScript
15 lines
340 B
TypeScript
export const generateUUID = (length: number) => {
|
|
// Base62-Version (a-z, A-Z, 0-9)
|
|
const base62 =
|
|
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
let string = "";
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
string += base62.charAt(Math.floor(Math.random() * base62.length));
|
|
}
|
|
|
|
console.log(string);
|
|
|
|
return string;
|
|
};
|