This commit is contained in:
2025-04-13 15:10:07 -07:00
parent 5cd701ca2b
commit aade48a7b8
18 changed files with 3185 additions and 299 deletions

13
src/IDUtils.ts Normal file
View File

@@ -0,0 +1,13 @@
function uuidv4() {
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c: any) =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
export function generateID() {
if (self.crypto.hasOwnProperty("randomUUID")) {
return self.crypto.randomUUID();
}
return uuidv4();
}