1 | /* eslint-disable no-bitwise */
|
2 | export var generateUuid = function generateUuid() {
|
3 | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
4 | var r = Math.random() * 16 | 0;
|
5 | return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
6 | });
|
7 | };
|
8 | /* eslint-enable no-bitwise */
|
9 |
|
10 | var staticValue = false;
|
11 | export var uuid = {
|
12 | setStatic: function setStatic(value) {
|
13 | staticValue = value;
|
14 | },
|
15 | generate: function generate() {
|
16 | return staticValue || generateUuid();
|
17 | }
|
18 | }; |
\ | No newline at end of file |