()
| 14 | |
| 15 | // We can drop this and use crypto.randomUUID() once we move to node 20 |
| 16 | function 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 | |
| 32 | export function initData(count: number) { |
| 33 | data = Array.from({length: count}, () => ({id: randomUUID(), name: randomUUID()})); |
no test coverage detected
searching dependent graphs…