mirror of
https://github.com/wu736139669/vczero.github.io.git
synced 2026-08-05 06:23:38 +00:00
17 lines
488 B
JavaScript
17 lines
488 B
JavaScript
/**
|
|
* Inspired from the book of JavaScript Patterns, Stoyan Stefanov.
|
|
* You can add some special value in this guid, such as user's email or nickname or id.
|
|
* @module guid for JavaScript client
|
|
*/
|
|
(function(exports){
|
|
exports.guid = {
|
|
'create': function(){
|
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
var r = Math.random() * 16 | 0,
|
|
v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
return v.toString(16);
|
|
}).toUpperCase();
|
|
}
|
|
};
|
|
})(window);
|