(prefix: string = "")
| 18 | * @returns A random string that will resemble "prefix-8d49f0zp5t". |
| 19 | */ |
| 20 | export function createRandomName(prefix: string = ""): string { |
| 21 | // Available characters for random string creation |
| 22 | const chars = "0123456789abcdefghijklmnopqrstuvwxyz"; |
| 23 | |
| 24 | // Grab 10 randome characters from the character array |
| 25 | const random = Array.from( |
| 26 | { length: 10 }, |
| 27 | () => chars[Math.floor(Math.random() * chars.length)], |
| 28 | ).join(""); |
| 29 | |
| 30 | // Join with the prefix if provided |
| 31 | return `${prefix}${prefix.length > 0 ? "-" : ""}${random}`; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Creates a random boolean. |
no outgoing calls
no test coverage detected