How to use uuid

Comprehensive uuid code examples:

How to use uuid.stringify:

222
223
224
225
226
227
228
229
230
231
//
// Due to a bug introduced in a1bcd35e2
const duplicate = vhdById.get(UUID.stringify(vhd.footer.uuid))
let vhdKept = vhd
if (duplicate !== undefined) {
  logWarn('uuid is duplicated', { uuid: UUID.stringify(vhd.footer.uuid) })
  if (duplicate.containsAllDataOf(vhd)) {
    logWarn(`should delete ${path}`)
    vhdKept = duplicate
    vhds.delete(path)

How to use uuid.v1:

138
139
140
141
142
143
144
145
146
147

let deck = Object.assign(
    {},
    {
        name: req.body.name,
        uuid: uuid.v1(),
        username: req.user.username,
        pods: req.body.pods
    }
);

How to use uuid.v4:

58
59
60
61
62
63
64
65
66
67
68
69
70


function hash(algo, string) {
    return crypto.createHash(algo).update(string).digest("hex");
}


const getUUID = uuid.v4;


function logIOC(type, value, description) {
    log("info", "IOC: " + description);
    IOC.push({type, value, description});