[Uuid] - a unique identification

2020-01-02

UUID, Universally Unique Identifier, a universally unique identifier.

 

// definition of a method of generating uuid
const getUuid = () => { const S = [] // define a hexadecimal string const = hexdigits '0123456789abcdef' for (the let I = 0; I <36; I ++ ) { // 0x10 hexadecimal number is converted to decimal 16 S [I] = hexDigits.substr (Math.floor (Math.random () * 0x10),. 1 ) } // bits 12-15 of The time_hi_and_version to 0010 Field S [14] = '. 4' // bits 6-7 of The clock_seq_hi_and_reserved to 01 // 0x3 to 3, 0x8 is. 8 S [. 19] = hexDigits.substr ((S [. 19] && 0x3) || 0x8,. 1 ) S [ . 8] = S [13 is] = S [18 is] = S [23 is] = '-' const UUID S.join = ( '' ) return UUID } Export default getUuid

called directly // use
getUuid () to
 

Guess you like

Origin www.cnblogs.com/fengwenya/p/12141917.html