8e2c91663e
Co-Authored-By: Claude Code <noreply@anthropic.com>
8 lines
279 B
TypeScript
8 lines
279 B
TypeScript
export function uuid(): string {
|
|
if (globalThis.crypto?.randomUUID) return crypto.randomUUID();
|
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
const r = (Math.random() * 16) | 0;
|
|
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
|
|
});
|
|
}
|