comparison src/implab/Uuid.js @ 1:93fb6c09f2e1

minor fixes
author cin
date Fri, 02 Jun 2017 18:15:22 +0300
parents fc2517695ee1
children 00779cb63b12
comparison
equal deleted inserted replaced
0:fc2517695ee1 1:93fb6c09f2e1
29 _whatwgRNG = _rng = function whatwgRNG() { 29 _whatwgRNG = _rng = function whatwgRNG() {
30 _crypto.getRandomValues(_rnds8); 30 _crypto.getRandomValues(_rnds8);
31 return _rnds8; 31 return _rnds8;
32 }; 32 };
33 _rng(); 33 _rng();
34 } catch (e) {} 34 } catch (e) { /**/ }
35 } 35 }
36 36
37 if (!_rng) { 37 if (!_rng) {
38 // Math.random()-based (RNG) 38 // Math.random()-based (RNG)
39 // 39 //
68 var _rb = require('crypto').randomBytes; 68 var _rb = require('crypto').randomBytes;
69 _nodeRNG = _rng = _rb && function () { 69 _nodeRNG = _rng = _rb && function () {
70 return _rb(16); 70 return _rb(16);
71 }; 71 };
72 _rng(); 72 _rng();
73 } catch (e) {} 73 } catch (e) { /**/ }
74 } 74 }
75 } 75 }
76 76
77 if (_window) { 77 if (_window) {
78 setupBrowser(); 78 setupBrowser();
259 259
260 return buf || unparse(rnds); 260 return buf || unparse(rnds);
261 } 261 }
262 262
263 // Export public API 263 // Export public API
264 var uuid = function() { 264 var uuid = function () {
265 return new String(v4()); 265 return new String(v4());
266 }; 266 };
267 uuid.v1 = v1; 267 uuid.v1 = v1;
268 uuid.v4 = v4; 268 uuid.v4 = v4;
269 uuid.create = v4; 269 uuid.create = v4;