Skip to content

Commit de6d219

Browse files
authored
Add custom UUID function
1 parent 4e802f1 commit de6d219

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/core/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,15 @@ const Resolver = {
8686
}
8787
},
8888
uuid: () => {
89-
return window.crypto !== undefined ? window.crypto.randomUUID() : '' + Date.now()
89+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
90+
.replace(/[xy]/g, function (c) {
91+
const r = Math.random() * 16 | 0,
92+
v = c == 'x' ? r : (r & 0x3 | 0x8);
93+
return v.toString(16);
94+
});
9095
}
9196
}
9297

93-
// add the randomUUID option to crypto
94-
window.crypto.randomUUID = function () {
95-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
96-
.replace(/[xy]/g, function (c) {
97-
const r = Math.random() * 16 | 0,
98-
v = c == 'x' ? r : (r & 0x3 | 0x8);
99-
return v.toString(16);
100-
});
101-
}
102-
10398
export {
10499
Attachment,
105100
When,

0 commit comments

Comments
 (0)