MCPcopy Create free account
hub / github.com/aws/graph-explorer / createRandomName

Function createRandomName

packages/shared/src/utils/testing/randomData.ts:20–32  ·  view source on GitHub ↗
(prefix: string = "")

Source from the content-addressed store, hash-verified

18 * @returns A random string that will resemble "prefix-8d49f0zp5t".
19 */
20export 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.

Calls

no outgoing calls

Tested by

no test coverage detected