Skip to content

Commit 226b13b

Browse files
author
Travis CI
committed
Travis CI - [ci skip] - automatic dist folder
1 parent bb3a751 commit 226b13b

File tree

3 files changed

+47
-72
lines changed

3 files changed

+47
-72
lines changed

dist/kuzzle.js

Lines changed: 45 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,53 @@
44
// Copyright (c) 2010-2012 Robert Kieffer
55
// MIT License - http://opensource.org/licenses/mit-license.php
66

7-
/*global window, require, define */
8-
(function(_window) {
9-
'use strict';
7+
(function() {
8+
var _global = this;
109

1110
// Unique ID creation requires a high quality random # generator. We feature
1211
// detect to determine the best RNG source, normalizing to a function that
1312
// returns 128-bits of randomness, since that's what's usually required
14-
var _rng, _mathRNG, _nodeRNG, _whatwgRNG, _previousRoot;
15-
16-
function setupBrowser() {
17-
// Allow for MSIE11 msCrypto
18-
var _crypto = _window.crypto || _window.msCrypto;
19-
20-
if (!_rng && _crypto && _crypto.getRandomValues) {
21-
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
22-
//
23-
// Moderately fast, high quality
24-
try {
25-
var _rnds8 = new Uint8Array(16);
26-
_whatwgRNG = _rng = function whatwgRNG() {
27-
_crypto.getRandomValues(_rnds8);
28-
return _rnds8;
29-
};
30-
_rng();
31-
} catch(e) {}
32-
}
33-
34-
if (!_rng) {
35-
// Math.random()-based (RNG)
36-
//
37-
// If all else fails, use Math.random(). It's fast, but is of unspecified
38-
// quality.
39-
var _rnds = new Array(16);
40-
_mathRNG = _rng = function() {
41-
for (var i = 0, r; i < 16; i++) {
42-
if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; }
43-
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
44-
}
13+
var _rng;
4514

46-
return _rnds;
47-
};
48-
if ('undefined' !== typeof console && console.warn) {
49-
console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()");
50-
}
51-
}
15+
// Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
16+
//
17+
// Moderately fast, high quality
18+
if (typeof(_global.require) == 'function') {
19+
try {
20+
var _rb = _global.require('crypto').randomBytes;
21+
_rng = _rb && function() {return _rb(16);};
22+
} catch(e) {}
5223
}
5324

54-
function setupNode() {
55-
// Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
25+
if (!_rng && _global.crypto && crypto.getRandomValues) {
26+
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
5627
//
5728
// Moderately fast, high quality
58-
if ('function' === typeof require) {
59-
try {
60-
var _rb = require('crypto').randomBytes;
61-
_nodeRNG = _rng = _rb && function() {return _rb(16);};
62-
_rng();
63-
} catch(e) {}
64-
}
29+
var _rnds8 = new Uint8Array(16);
30+
_rng = function whatwgRNG() {
31+
crypto.getRandomValues(_rnds8);
32+
return _rnds8;
33+
};
6534
}
6635

67-
if (_window) {
68-
setupBrowser();
69-
} else {
70-
setupNode();
36+
if (!_rng) {
37+
// Math.random()-based (RNG)
38+
//
39+
// If all else fails, use Math.random(). It's fast, but is of unspecified
40+
// quality.
41+
var _rnds = new Array(16);
42+
_rng = function() {
43+
for (var i = 0, r; i < 16; i++) {
44+
if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
45+
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
46+
}
47+
48+
return _rnds;
49+
};
7150
}
7251

7352
// Buffer class to use
74-
var BufferClass = ('function' === typeof Buffer) ? Buffer : Array;
53+
var BufferClass = typeof(_global.Buffer) == 'function' ? _global.Buffer : Array;
7554

7655
// Maps for number <-> hex string conversion
7756
var _byteToHex = [];
@@ -140,17 +119,17 @@
140119

141120
options = options || {};
142121

143-
var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq;
122+
var clockseq = options.clockseq != null ? options.clockseq : _clockseq;
144123

145124
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
146125
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
147126
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
148127
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
149-
var msecs = (options.msecs != null) ? options.msecs : new Date().getTime();
128+
var msecs = options.msecs != null ? options.msecs : new Date().getTime();
150129

151130
// Per 4.2.1.2, use count of uuid's generated during the current clock
152131
// cycle to simulate higher resolution clock
153-
var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1;
132+
var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
154133

155134
// Time since last uuid creation (in msecs)
156135
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
@@ -216,8 +195,8 @@
216195
// Deprecated - 'format' argument, as supported in v1.2
217196
var i = buf && offset || 0;
218197

219-
if (typeof(options) === 'string') {
220-
buf = (options === 'binary') ? new BufferClass(16) : null;
198+
if (typeof(options) == 'string') {
199+
buf = options == 'binary' ? new BufferClass(16) : null;
221200
options = null;
222201
}
223202
options = options || {};
@@ -245,32 +224,28 @@
245224
uuid.parse = parse;
246225
uuid.unparse = unparse;
247226
uuid.BufferClass = BufferClass;
248-
uuid._rng = _rng;
249-
uuid._mathRNG = _mathRNG;
250-
uuid._nodeRNG = _nodeRNG;
251-
uuid._whatwgRNG = _whatwgRNG;
252227

253-
if (('undefined' !== typeof module) && module.exports) {
228+
if (typeof(module) != 'undefined' && module.exports) {
254229
// Publish as node.js module
255230
module.exports = uuid;
256-
} else if (typeof define === 'function' && define.amd) {
231+
} else if (typeof define === 'function' && define.amd) {
257232
// Publish as AMD module
258233
define(function() {return uuid;});
259-
234+
260235

261236
} else {
262237
// Publish as global (in browsers)
263-
_previousRoot = _window.uuid;
238+
var _previousRoot = _global.uuid;
264239

265240
// **`noConflict()` - (browser only) to reset global 'uuid' var**
266241
uuid.noConflict = function() {
267-
_window.uuid = _previousRoot;
242+
_global.uuid = _previousRoot;
268243
return uuid;
269244
};
270245

271-
_window.uuid = uuid;
246+
_global.uuid = uuid;
272247
}
273-
})('undefined' !== typeof window ? window : null);
248+
}).call(this);
274249

275250
},{}],2:[function(require,module,exports){
276251
var

0 commit comments

Comments
 (0)