Created
March 20, 2017 11:05
-
-
Save yy-dev7/673b5b854e8a774bfc6eb51264e0f008 to your computer and use it in GitHub Desktop.
generateUUID
This file contains 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
/** | |
* 生成uuid | |
* @return {[string]} uuid | |
*/ | |
function generateUUID() { | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1) | |
} | |
/* eslint-disable prefer-template */ | |
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | |
s4() + '-' + s4() + s4() + s4() | |
} | |
export default generateUUID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment