MCPcopy Index your code
hub / github.com/node-modules/utility / randomString

Function randomString

src/string.ts:1–10  ·  view source on GitHub ↗
(length?: number, charSet?: string)

Source from the content-addressed store, hash-verified

1export function randomString(length?: number, charSet?: string) {
2 const result: string[] = [];
3 length = length || 16;
4 charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
5
6 while (length--) {
7 result.push(charSet[Math.floor(Math.random() * charSet.length)]);
8 }
9 return result.join('');
10}
11
12/**
13 * split string to array

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…