All files / src uuid.ts

16.66% Statements 1/6
0% Branches 0/2
0% Functions 0/2
16.66% Lines 1/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 91x                
export function generateUUID(): string {
  let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
  uuid = uuid.replace(/[xy]/g, function (c): string {
    const r = (Math.random() * 16) % 16 | 0;
    return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
  });
  return uuid;
}