https://www.npmjs.com/package/uuidj

    1. // Create a version 4 (random number-based) UUID object
    2. var objV4 = UUID.genV4();
    3. // Create a version 1 (time-based) UUID object
    4. var objV1 = UUID.genV1();
    5. // Create a UUID object from a hexadecimal string
    6. var uuid = UUID.parse("a0e0f130-8c21-11df-92d9-95795a3bcd40");
    7. // Get string representations of a UUID object
    8. console.log(uuid.toString()); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
    9. console.log(uuid.hexString); // "a0e0f130-8c21-11df-92d9-95795a3bcd40"
    10. console.log(uuid.hexNoDelim); // "a0e0f1308c2111df92d995795a3bcd40"
    11. console.log(uuid.bitString); // "101000001110000 ... 1100110101000000"
    12. console.log(uuid.urn); // "urn:uuid:a0e0f130-8c21-11df-92d9-95795a3bcd40"
    13. // Compare UUID objects
    14. console.log(objV4.equals(objV1)); // false
    15. // Get UUID version numbers
    16. console.log(objV4.version); // 4
    17. console.log(objV1.version); // 1
    18. // Get internal field values in 3 different forms via 2 different accessors
    19. console.log(uuid.intFields.timeLow); // 2699096368
    20. console.log(uuid.bitFields.timeMid); // "1000110000100001"
    21. console.log(uuid.hexFields.timeHiAndVersion); // "11df"
    22. console.log(uuid.intFields.clockSeqHiAndReserved); // 146
    23. console.log(uuid.bitFields.clockSeqLow); // "11011001"
    24. console.log(uuid.hexFields.node); // "95795a3bcd40"
    25. console.log(uuid.intFields[0]); // 2699096368
    26. console.log(uuid.bitFields[1]); // "1000110000100001"
    27. console.log(uuid.hexFields[2]); // "11df"
    28. console.log(uuid.intFields[3]); // 146
    29. console.log(uuid.bitFields[4]); // "11011001"
    30. console.log(uuid.hexFields[5]);