All files / src uuidv4.js

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 2/2

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 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          5056x                                   1x  
// golfed version of uuid-v4
// uuid node module relies on crypto, which is a bit fat to embed
//
// cf amazing https://gist.github.com/jed/982883
 
const b = (a) => a
  ? (
    a ^
    Math.random()
    * 16
    >> a/4
  ).toString(16)
  : (
    [1e7] +
    -1e3 +
    -4e3 +
    -8e3 +
    -1e11
  ).replace(
    /[018]/g,
    b
  );
 
module.exports = b;