2020-02-01 05:01:58 +13:00
|
|
|
export function uuid() {
|
2020-08-07 08:12:35 +12:00
|
|
|
// always want to make this start with a letter, as this makes it
|
2021-01-20 07:44:29 +13:00
|
|
|
// easier to use with template string bindings in the client
|
2021-05-04 22:32:22 +12:00
|
|
|
return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
|
2020-02-03 22:24:25 +13:00
|
|
|
const r = (Math.random() * 16) | 0,
|
|
|
|
v = c == "x" ? r : (r & 0x3) | 0x8
|
|
|
|
return v.toString(16)
|
|
|
|
})
|
2020-02-01 05:01:58 +13:00
|
|
|
}
|