Skip to content

Commit c4adef3

Browse files
committed
move generateUUID
1 parent 9380fc2 commit c4adef3

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/index.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -317,23 +317,6 @@ export function notify(name: string, args: any) {
317317
window.parent.postMessage(payload, "*");
318318
}
319319

320-
function generateUUID() {
321-
const buf = new Uint8Array(16);
322-
crypto.getRandomValues(buf);
323-
324-
buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
325-
buf[8] = (buf[8] & 0x3f) | 0x80; // variant
326-
327-
const hex = Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
328-
329-
return [
330-
hex.substring(0, 8),
331-
hex.substring(8, 12),
332-
hex.substring(12, 16),
333-
hex.substring(16, 20),
334-
hex.substring(20),
335-
].join("-");
336-
}
337320
export function addNotificationListener(
338321
name: "tablesChanged",
339322
handler: () => void,
@@ -454,3 +437,21 @@ window.addEventListener("message", (event) => {
454437
}
455438
});
456439

440+
function generateUUID() {
441+
const buf = new Uint8Array(16);
442+
crypto.getRandomValues(buf);
443+
444+
buf[6] = (buf[6] & 0x0f) | 0x40; // version 4
445+
buf[8] = (buf[8] & 0x3f) | 0x80; // variant
446+
447+
const hex = Array.from(buf, (b) => b.toString(16).padStart(2, "0")).join("");
448+
449+
return [
450+
hex.substring(0, 8),
451+
hex.substring(8, 12),
452+
hex.substring(12, 16),
453+
hex.substring(16, 20),
454+
hex.substring(20),
455+
].join("-");
456+
}
457+

0 commit comments

Comments
 (0)