Source: math/guid.js

/**
 * Функция для генерации GUID
 * @returns {string} - новый guid
 */
function createGUID() {
    let summation = [];
    let hexDigits = "0123456789ABCDEF";
    for (let i = 0; i < 32; i++) {
        summation[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    summation[12] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
    summation[16] = hexDigits.substr((summation[16] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01

    let uuid = summation.join("");
    return uuid;
}

module.exports = {
    createGUID: createGUID
};