Created
September 19, 2013 13:55
-
-
Save justinobney/6623855 to your computer and use it in GitHub Desktop.
UUID in JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var svc = { | |
new: function() { | |
function _p8(s) { | |
var p = (Math.random().toString(16)+"000000000").substr(2,8); | |
return s ? "-" + p.substr(0,4) + "-" + p.substr(4,4) : p ; | |
} | |
return _p8() + _p8(true) + _p8(true) + _p8(); | |
}, | |
empty: function() { | |
return '00000000-0000-0000-0000-000000000000'; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment