keeweb/app/scripts/util/id-generator.js

14 lines
352 B
JavaScript
Raw Normal View History

2017-01-31 07:50:28 +01:00
const IdGenerator = {
2015-12-06 23:13:29 +01:00
uuid: function() {
2017-01-31 07:50:28 +01:00
const s4 = IdGenerator.s4;
2015-12-06 23:13:29 +01:00
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
},
s4: function() {
2019-08-16 23:05:39 +02:00
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
2015-12-06 23:13:29 +01:00
}
};
module.exports = IdGenerator;