MCPcopy
hub / github.com/darkreader/darkreader / generateUID

Function generateUID

src/utils/uid.ts:5–16  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3}
4
5export function generateUID(): string {
6 if ('randomUUID' in crypto) {
7 const uuid = crypto.randomUUID();
8 return uuid.substring(0, 8) + uuid.substring(9, 13) + uuid.substring(14, 18) + uuid.substring(19, 23) + uuid.substring(24);
9 }
10
11 if ('getRandomValues' in crypto) {
12 return Array.from((crypto as Crypto).getRandomValues(new Uint8Array(16))).map((x) => hexify(x)).join('');
13 }
14
15 return Math.floor(Math.random() * 2 ** 55).toString(36);
16}

Callers 5

index.tsFile · 0.90
bgFetchFunction · 0.90
index.tsFile · 0.90
onPresetChangeFunction · 0.90
uid.tests.tsFile · 0.90

Calls 1

hexifyFunction · 0.85

Tested by

no test coverage detected