12345678910111213141516 |
- // from: https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid
- const replaceString = str => {
- return str.replace(/[xy]/g, function(c) {
- var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- })
- }
- export default () => {
- return replaceString('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
- }
- export const createRandom = (length = 8) => {
- return replaceString(''.padEnd(length, 'x'))
- }
|