Refactor
This commit is contained in:
parent
c3cef31974
commit
4da7d84c0a
@ -1,12 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* Generate a UUID
|
||||||
|
*/
|
||||||
export default () => {
|
export default () => {
|
||||||
var uuid = '', i, random;
|
let uuid = '';
|
||||||
for (i = 0; i < 32; i++) {
|
|
||||||
random = Math.random() * 16 | 0;
|
for (let i = 0; i < 32; i++) {
|
||||||
|
const random = Math.random() * 16 | 0;
|
||||||
|
|
||||||
if (i == 8 || i == 12 || i == 16 || i == 20) {
|
if (i == 8 || i == 12 || i == 16 || i == 20) {
|
||||||
uuid += '-';
|
uuid += '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
|
uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uuid;
|
return uuid;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user