mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
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:
@ -668,3 +668,11 @@ export async function waitUntilCondition(condition, timeout = 1000, interval = 1
|
|||||||
}, interval);
|
}, 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user