Add generateRandomString helper function and remove nanoid dependency

This commit is contained in:
faris Aljohari
2024-06-01 20:25:05 +03:00
parent 0e99df8037
commit f0606f81e7
4 changed files with 14 additions and 19 deletions

View File

@ -0,0 +1,10 @@
export function generateRandomString(length: number): string {
const characters =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let randomString = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
randomString += characters.charAt(randomIndex);
}
return randomString;
}