Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
Created October 25, 2014 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturadnidge/d85325f67fa233e56c7d to your computer and use it in GitHub Desktop.
Save sturadnidge/d85325f67fa233e56c7d to your computer and use it in GitHub Desktop.
Generate a UUID... use node-uuid if you can though.
function uuidGen() {
var uuid = 'xxxxxxxxxxxxyxxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g,
function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
return uuid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment