Utils: Add UUID v4 support

Unique IDs should use UUID as there's a higher prevention of overflow
when assigning them.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2023-07-02 18:31:02 -04:00
parent 1fe2e4032a
commit ca2542d81a

View File

@ -668,3 +668,11 @@ export async function waitUntilCondition(condition, timeout = 1000, interval = 1
}, interval);
});
}
export function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}