All files / src uuid.ts

100% Statements 6/6
100% Branches 2/2
100% Functions 2/2
100% Lines 6/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 61x 61x 1891x 1891x   61x    
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;
}