Tizen 2.0 Release
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.2.0 / node_modules / testswarm / node_modules / request / uuid.js
1 module.exports = function () {
2   var s = [], itoh = '0123456789ABCDEF'
3  
4   // Make array of random hex digits. The UUID only has 32 digits in it, but we
5   // allocate an extra items to make room for the '-'s we'll be inserting.
6   for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10)
7  
8   // Conform to RFC-4122, section 4.4
9   s[14] = 4;  // Set 4 high bits of time_high field to version
10   s[19] = (s[19] & 0x3) | 0x8  // Specify 2 high bits of clock sequence
11  
12   // Convert to hex chars
13   for (var i = 0; i <36; i++) s[i] = itoh[s[i]]
14  
15   // Insert '-'s
16   s[8] = s[13] = s[18] = s[23] = '-'
17  
18   return s.join('')
19 }