MCPcopy
hub / github.com/angular/angular / randomUUID

Function randomUUID

modules/ssr-benchmarks/test-data.ts:16–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15// We can drop this and use crypto.randomUUID() once we move to node 20
16function randomUUID() {
17 let uuid = '';
18 const chars = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
19 for (let i = 0; i < chars.length; i++) {
20 const randomValue = (Math.random() * 16) | 0; // Generate random value (0-15)
21 if (chars[i] === 'x') {
22 uuid += randomValue.toString(16); // Replace 'x' with random hex value
23 } else if (chars[i] === 'y') {
24 uuid += ((randomValue & 0x3) | 0x8).toString(16); // Replace 'y' with a value between 8 and 11
25 } else {
26 uuid += chars[i]; // Preserve the dashes and '4' in the template
27 }
28 }
29 return uuid;
30}
31
32export function initData(count: number) {
33 data = Array.from({length: count}, () => ({id: randomUUID(), name: randomUUID()}));

Callers 2

_prepareBenchpressSetupFunction · 0.85
initDataFunction · 0.85

Calls 1

toStringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…