1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bla = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
2 | exports.endianness = function () { return 'LE' };
|
3 |
|
4 | exports.hostname = function () {
|
5 | if (typeof location !== 'undefined') {
|
6 | return location.hostname
|
7 | }
|
8 | else return '';
|
9 | };
|
10 |
|
11 | exports.loadavg = function () { return [] };
|
12 |
|
13 | exports.uptime = function () { return 0 };
|
14 |
|
15 | exports.freemem = function () {
|
16 | return Number.MAX_VALUE;
|
17 | };
|
18 |
|
19 | exports.totalmem = function () {
|
20 | return Number.MAX_VALUE;
|
21 | };
|
22 |
|
23 | exports.cpus = function () { return [] };
|
24 |
|
25 | exports.type = function () { return 'Browser' };
|
26 |
|
27 | exports.release = function () {
|
28 | if (typeof navigator !== 'undefined') {
|
29 | return navigator.appVersion;
|
30 | }
|
31 | return '';
|
32 | };
|
33 |
|
34 | exports.networkInterfaces
|
35 | = exports.getNetworkInterfaces
|
36 | = function () { return {} };
|
37 |
|
38 | exports.arch = function () { return 'javascript' };
|
39 |
|
40 | exports.platform = function () { return 'browser' };
|
41 |
|
42 | exports.tmpdir = exports.tmpDir = function () {
|
43 | return '/tmp';
|
44 | };
|
45 |
|
46 | exports.EOL = '\n';
|
47 |
|
48 | exports.homedir = function () {
|
49 | return '/'
|
50 | };
|
51 |
|
52 | },{}],2:[function(require,module,exports){
|
53 |
|
54 | var process = module.exports = {};
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | var cachedSetTimeout;
|
62 | var cachedClearTimeout;
|
63 |
|
64 | function defaultSetTimout() {
|
65 | throw new Error('setTimeout has not been defined');
|
66 | }
|
67 | function defaultClearTimeout () {
|
68 | throw new Error('clearTimeout has not been defined');
|
69 | }
|
70 | (function () {
|
71 | try {
|
72 | if (typeof setTimeout === 'function') {
|
73 | cachedSetTimeout = setTimeout;
|
74 | } else {
|
75 | cachedSetTimeout = defaultSetTimout;
|
76 | }
|
77 | } catch (e) {
|
78 | cachedSetTimeout = defaultSetTimout;
|
79 | }
|
80 | try {
|
81 | if (typeof clearTimeout === 'function') {
|
82 | cachedClearTimeout = clearTimeout;
|
83 | } else {
|
84 | cachedClearTimeout = defaultClearTimeout;
|
85 | }
|
86 | } catch (e) {
|
87 | cachedClearTimeout = defaultClearTimeout;
|
88 | }
|
89 | } ())
|
90 | function runTimeout(fun) {
|
91 | if (cachedSetTimeout === setTimeout) {
|
92 |
|
93 | return setTimeout(fun, 0);
|
94 | }
|
95 |
|
96 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
97 | cachedSetTimeout = setTimeout;
|
98 | return setTimeout(fun, 0);
|
99 | }
|
100 | try {
|
101 |
|
102 | return cachedSetTimeout(fun, 0);
|
103 | } catch(e){
|
104 | try {
|
105 |
|
106 | return cachedSetTimeout.call(null, fun, 0);
|
107 | } catch(e){
|
108 |
|
109 | return cachedSetTimeout.call(this, fun, 0);
|
110 | }
|
111 | }
|
112 |
|
113 |
|
114 | }
|
115 | function runClearTimeout(marker) {
|
116 | if (cachedClearTimeout === clearTimeout) {
|
117 |
|
118 | return clearTimeout(marker);
|
119 | }
|
120 |
|
121 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
122 | cachedClearTimeout = clearTimeout;
|
123 | return clearTimeout(marker);
|
124 | }
|
125 | try {
|
126 |
|
127 | return cachedClearTimeout(marker);
|
128 | } catch (e){
|
129 | try {
|
130 |
|
131 | return cachedClearTimeout.call(null, marker);
|
132 | } catch (e){
|
133 |
|
134 |
|
135 | return cachedClearTimeout.call(this, marker);
|
136 | }
|
137 | }
|
138 |
|
139 |
|
140 |
|
141 | }
|
142 | var queue = [];
|
143 | var draining = false;
|
144 | var currentQueue;
|
145 | var queueIndex = -1;
|
146 |
|
147 | function cleanUpNextTick() {
|
148 | if (!draining || !currentQueue) {
|
149 | return;
|
150 | }
|
151 | draining = false;
|
152 | if (currentQueue.length) {
|
153 | queue = currentQueue.concat(queue);
|
154 | } else {
|
155 | queueIndex = -1;
|
156 | }
|
157 | if (queue.length) {
|
158 | drainQueue();
|
159 | }
|
160 | }
|
161 |
|
162 | function drainQueue() {
|
163 | if (draining) {
|
164 | return;
|
165 | }
|
166 | var timeout = runTimeout(cleanUpNextTick);
|
167 | draining = true;
|
168 |
|
169 | var len = queue.length;
|
170 | while(len) {
|
171 | currentQueue = queue;
|
172 | queue = [];
|
173 | while (++queueIndex < len) {
|
174 | if (currentQueue) {
|
175 | currentQueue[queueIndex].run();
|
176 | }
|
177 | }
|
178 | queueIndex = -1;
|
179 | len = queue.length;
|
180 | }
|
181 | currentQueue = null;
|
182 | draining = false;
|
183 | runClearTimeout(timeout);
|
184 | }
|
185 |
|
186 | process.nextTick = function (fun) {
|
187 | var args = new Array(arguments.length - 1);
|
188 | if (arguments.length > 1) {
|
189 | for (var i = 1; i < arguments.length; i++) {
|
190 | args[i - 1] = arguments[i];
|
191 | }
|
192 | }
|
193 | queue.push(new Item(fun, args));
|
194 | if (queue.length === 1 && !draining) {
|
195 | runTimeout(drainQueue);
|
196 | }
|
197 | };
|
198 |
|
199 |
|
200 | function Item(fun, array) {
|
201 | this.fun = fun;
|
202 | this.array = array;
|
203 | }
|
204 | Item.prototype.run = function () {
|
205 | this.fun.apply(null, this.array);
|
206 | };
|
207 | process.title = 'browser';
|
208 | process.browser = true;
|
209 | process.env = {};
|
210 | process.argv = [];
|
211 | process.version = '';
|
212 | process.versions = {};
|
213 |
|
214 | function noop() {}
|
215 |
|
216 | process.on = noop;
|
217 | process.addListener = noop;
|
218 | process.once = noop;
|
219 | process.off = noop;
|
220 | process.removeListener = noop;
|
221 | process.removeAllListeners = noop;
|
222 | process.emit = noop;
|
223 | process.prependListener = noop;
|
224 | process.prependOnceListener = noop;
|
225 |
|
226 | process.listeners = function (name) { return [] }
|
227 |
|
228 | process.binding = function (name) {
|
229 | throw new Error('process.binding is not supported');
|
230 | };
|
231 |
|
232 | process.cwd = function () { return '/' };
|
233 | process.chdir = function (dir) {
|
234 | throw new Error('process.chdir is not supported');
|
235 | };
|
236 | process.umask = function() { return 0; };
|
237 |
|
238 | },{}],3:[function(require,module,exports){
|
239 | if (typeof Object.create === 'function') {
|
240 |
|
241 | module.exports = function inherits(ctor, superCtor) {
|
242 | ctor.super_ = superCtor
|
243 | ctor.prototype = Object.create(superCtor.prototype, {
|
244 | constructor: {
|
245 | value: ctor,
|
246 | enumerable: false,
|
247 | writable: true,
|
248 | configurable: true
|
249 | }
|
250 | });
|
251 | };
|
252 | } else {
|
253 |
|
254 | module.exports = function inherits(ctor, superCtor) {
|
255 | ctor.super_ = superCtor
|
256 | var TempCtor = function () {}
|
257 | TempCtor.prototype = superCtor.prototype
|
258 | ctor.prototype = new TempCtor()
|
259 | ctor.prototype.constructor = ctor
|
260 | }
|
261 | }
|
262 |
|
263 | },{}],4:[function(require,module,exports){
|
264 | module.exports = function isBuffer(arg) {
|
265 | return arg && typeof arg === 'object'
|
266 | && typeof arg.copy === 'function'
|
267 | && typeof arg.fill === 'function'
|
268 | && typeof arg.readUInt8 === 'function';
|
269 | }
|
270 | },{}],5:[function(require,module,exports){
|
271 | (function (process,global){
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 | var formatRegExp = /%[sdj%]/g;
|
294 | exports.format = function(f) {
|
295 | if (!isString(f)) {
|
296 | var objects = [];
|
297 | for (var i = 0; i < arguments.length; i++) {
|
298 | objects.push(inspect(arguments[i]));
|
299 | }
|
300 | return objects.join(' ');
|
301 | }
|
302 |
|
303 | var i = 1;
|
304 | var args = arguments;
|
305 | var len = args.length;
|
306 | var str = String(f).replace(formatRegExp, function(x) {
|
307 | if (x === '%%') return '%';
|
308 | if (i >= len) return x;
|
309 | switch (x) {
|
310 | case '%s': return String(args[i++]);
|
311 | case '%d': return Number(args[i++]);
|
312 | case '%j':
|
313 | try {
|
314 | return JSON.stringify(args[i++]);
|
315 | } catch (_) {
|
316 | return '[Circular]';
|
317 | }
|
318 | default:
|
319 | return x;
|
320 | }
|
321 | });
|
322 | for (var x = args[i]; i < len; x = args[++i]) {
|
323 | if (isNull(x) || !isObject(x)) {
|
324 | str += ' ' + x;
|
325 | } else {
|
326 | str += ' ' + inspect(x);
|
327 | }
|
328 | }
|
329 | return str;
|
330 | };
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 | exports.deprecate = function(fn, msg) {
|
337 |
|
338 | if (isUndefined(global.process)) {
|
339 | return function() {
|
340 | return exports.deprecate(fn, msg).apply(this, arguments);
|
341 | };
|
342 | }
|
343 |
|
344 | if (process.noDeprecation === true) {
|
345 | return fn;
|
346 | }
|
347 |
|
348 | var warned = false;
|
349 | function deprecated() {
|
350 | if (!warned) {
|
351 | if (process.throwDeprecation) {
|
352 | throw new Error(msg);
|
353 | } else if (process.traceDeprecation) {
|
354 | console.trace(msg);
|
355 | } else {
|
356 | console.error(msg);
|
357 | }
|
358 | warned = true;
|
359 | }
|
360 | return fn.apply(this, arguments);
|
361 | }
|
362 |
|
363 | return deprecated;
|
364 | };
|
365 |
|
366 |
|
367 | var debugs = {};
|
368 | var debugEnviron;
|
369 | exports.debuglog = function(set) {
|
370 | if (isUndefined(debugEnviron))
|
371 | debugEnviron = process.env.NODE_DEBUG || '';
|
372 | set = set.toUpperCase();
|
373 | if (!debugs[set]) {
|
374 | if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
375 | var pid = process.pid;
|
376 | debugs[set] = function() {
|
377 | var msg = exports.format.apply(exports, arguments);
|
378 | console.error('%s %d: %s', set, pid, msg);
|
379 | };
|
380 | } else {
|
381 | debugs[set] = function() {};
|
382 | }
|
383 | }
|
384 | return debugs[set];
|
385 | };
|
386 |
|
387 |
|
388 | /**
|
389 | * Echos the value of a value. Trys to print the value out
|
390 | * in the best way possible given the different types.
|
391 | *
|
392 | * @param {Object} obj The object to print out.
|
393 | * @param {Object} opts Optional options object that alters the output.
|
394 | */
|
395 |
|
396 | function inspect(obj, opts) {
|
397 |
|
398 | var ctx = {
|
399 | seen: [],
|
400 | stylize: stylizeNoColor
|
401 | };
|
402 |
|
403 | if (arguments.length >= 3) ctx.depth = arguments[2];
|
404 | if (arguments.length >= 4) ctx.colors = arguments[3];
|
405 | if (isBoolean(opts)) {
|
406 |
|
407 | ctx.showHidden = opts;
|
408 | } else if (opts) {
|
409 |
|
410 | exports._extend(ctx, opts);
|
411 | }
|
412 |
|
413 | if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
414 | if (isUndefined(ctx.depth)) ctx.depth = 2;
|
415 | if (isUndefined(ctx.colors)) ctx.colors = false;
|
416 | if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
417 | if (ctx.colors) ctx.stylize = stylizeWithColor;
|
418 | return formatValue(ctx, obj, ctx.depth);
|
419 | }
|
420 | exports.inspect = inspect;
|
421 |
|
422 |
|
423 |
|
424 | inspect.colors = {
|
425 | 'bold' : [1, 22],
|
426 | 'italic' : [3, 23],
|
427 | 'underline' : [4, 24],
|
428 | 'inverse' : [7, 27],
|
429 | 'white' : [37, 39],
|
430 | 'grey' : [90, 39],
|
431 | 'black' : [30, 39],
|
432 | 'blue' : [34, 39],
|
433 | 'cyan' : [36, 39],
|
434 | 'green' : [32, 39],
|
435 | 'magenta' : [35, 39],
|
436 | 'red' : [31, 39],
|
437 | 'yellow' : [33, 39]
|
438 | };
|
439 |
|
440 |
|
441 | inspect.styles = {
|
442 | 'special': 'cyan',
|
443 | 'number': 'yellow',
|
444 | 'boolean': 'yellow',
|
445 | 'undefined': 'grey',
|
446 | 'null': 'bold',
|
447 | 'string': 'green',
|
448 | 'date': 'magenta',
|
449 |
|
450 | 'regexp': 'red'
|
451 | };
|
452 |
|
453 |
|
454 | function stylizeWithColor(str, styleType) {
|
455 | var style = inspect.styles[styleType];
|
456 |
|
457 | if (style) {
|
458 | return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
459 | '\u001b[' + inspect.colors[style][1] + 'm';
|
460 | } else {
|
461 | return str;
|
462 | }
|
463 | }
|
464 |
|
465 |
|
466 | function stylizeNoColor(str, styleType) {
|
467 | return str;
|
468 | }
|
469 |
|
470 |
|
471 | function arrayToHash(array) {
|
472 | var hash = {};
|
473 |
|
474 | array.forEach(function(val, idx) {
|
475 | hash[val] = true;
|
476 | });
|
477 |
|
478 | return hash;
|
479 | }
|
480 |
|
481 |
|
482 | function formatValue(ctx, value, recurseTimes) {
|
483 |
|
484 |
|
485 | if (ctx.customInspect &&
|
486 | value &&
|
487 | isFunction(value.inspect) &&
|
488 |
|
489 | value.inspect !== exports.inspect &&
|
490 |
|
491 | !(value.constructor && value.constructor.prototype === value)) {
|
492 | var ret = value.inspect(recurseTimes, ctx);
|
493 | if (!isString(ret)) {
|
494 | ret = formatValue(ctx, ret, recurseTimes);
|
495 | }
|
496 | return ret;
|
497 | }
|
498 |
|
499 |
|
500 | var primitive = formatPrimitive(ctx, value);
|
501 | if (primitive) {
|
502 | return primitive;
|
503 | }
|
504 |
|
505 |
|
506 | var keys = Object.keys(value);
|
507 | var visibleKeys = arrayToHash(keys);
|
508 |
|
509 | if (ctx.showHidden) {
|
510 | keys = Object.getOwnPropertyNames(value);
|
511 | }
|
512 |
|
513 |
|
514 |
|
515 | if (isError(value)
|
516 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
517 | return formatError(value);
|
518 | }
|
519 |
|
520 |
|
521 | if (keys.length === 0) {
|
522 | if (isFunction(value)) {
|
523 | var name = value.name ? ': ' + value.name : '';
|
524 | return ctx.stylize('[Function' + name + ']', 'special');
|
525 | }
|
526 | if (isRegExp(value)) {
|
527 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
528 | }
|
529 | if (isDate(value)) {
|
530 | return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
531 | }
|
532 | if (isError(value)) {
|
533 | return formatError(value);
|
534 | }
|
535 | }
|
536 |
|
537 | var base = '', array = false, braces = ['{', '}'];
|
538 |
|
539 |
|
540 | if (isArray(value)) {
|
541 | array = true;
|
542 | braces = ['[', ']'];
|
543 | }
|
544 |
|
545 |
|
546 | if (isFunction(value)) {
|
547 | var n = value.name ? ': ' + value.name : '';
|
548 | base = ' [Function' + n + ']';
|
549 | }
|
550 |
|
551 |
|
552 | if (isRegExp(value)) {
|
553 | base = ' ' + RegExp.prototype.toString.call(value);
|
554 | }
|
555 |
|
556 |
|
557 | if (isDate(value)) {
|
558 | base = ' ' + Date.prototype.toUTCString.call(value);
|
559 | }
|
560 |
|
561 |
|
562 | if (isError(value)) {
|
563 | base = ' ' + formatError(value);
|
564 | }
|
565 |
|
566 | if (keys.length === 0 && (!array || value.length == 0)) {
|
567 | return braces[0] + base + braces[1];
|
568 | }
|
569 |
|
570 | if (recurseTimes < 0) {
|
571 | if (isRegExp(value)) {
|
572 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
573 | } else {
|
574 | return ctx.stylize('[Object]', 'special');
|
575 | }
|
576 | }
|
577 |
|
578 | ctx.seen.push(value);
|
579 |
|
580 | var output;
|
581 | if (array) {
|
582 | output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
583 | } else {
|
584 | output = keys.map(function(key) {
|
585 | return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
586 | });
|
587 | }
|
588 |
|
589 | ctx.seen.pop();
|
590 |
|
591 | return reduceToSingleString(output, base, braces);
|
592 | }
|
593 |
|
594 |
|
595 | function formatPrimitive(ctx, value) {
|
596 | if (isUndefined(value))
|
597 | return ctx.stylize('undefined', 'undefined');
|
598 | if (isString(value)) {
|
599 | var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
600 | .replace(/'/g, "\\'")
|
601 | .replace(/\\"/g, '"') + '\'';
|
602 | return ctx.stylize(simple, 'string');
|
603 | }
|
604 | if (isNumber(value))
|
605 | return ctx.stylize('' + value, 'number');
|
606 | if (isBoolean(value))
|
607 | return ctx.stylize('' + value, 'boolean');
|
608 |
|
609 | if (isNull(value))
|
610 | return ctx.stylize('null', 'null');
|
611 | }
|
612 |
|
613 |
|
614 | function formatError(value) {
|
615 | return '[' + Error.prototype.toString.call(value) + ']';
|
616 | }
|
617 |
|
618 |
|
619 | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
620 | var output = [];
|
621 | for (var i = 0, l = value.length; i < l; ++i) {
|
622 | if (hasOwnProperty(value, String(i))) {
|
623 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
624 | String(i), true));
|
625 | } else {
|
626 | output.push('');
|
627 | }
|
628 | }
|
629 | keys.forEach(function(key) {
|
630 | if (!key.match(/^\d+$/)) {
|
631 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
632 | key, true));
|
633 | }
|
634 | });
|
635 | return output;
|
636 | }
|
637 |
|
638 |
|
639 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
640 | var name, str, desc;
|
641 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
642 | if (desc.get) {
|
643 | if (desc.set) {
|
644 | str = ctx.stylize('[Getter/Setter]', 'special');
|
645 | } else {
|
646 | str = ctx.stylize('[Getter]', 'special');
|
647 | }
|
648 | } else {
|
649 | if (desc.set) {
|
650 | str = ctx.stylize('[Setter]', 'special');
|
651 | }
|
652 | }
|
653 | if (!hasOwnProperty(visibleKeys, key)) {
|
654 | name = '[' + key + ']';
|
655 | }
|
656 | if (!str) {
|
657 | if (ctx.seen.indexOf(desc.value) < 0) {
|
658 | if (isNull(recurseTimes)) {
|
659 | str = formatValue(ctx, desc.value, null);
|
660 | } else {
|
661 | str = formatValue(ctx, desc.value, recurseTimes - 1);
|
662 | }
|
663 | if (str.indexOf('\n') > -1) {
|
664 | if (array) {
|
665 | str = str.split('\n').map(function(line) {
|
666 | return ' ' + line;
|
667 | }).join('\n').substr(2);
|
668 | } else {
|
669 | str = '\n' + str.split('\n').map(function(line) {
|
670 | return ' ' + line;
|
671 | }).join('\n');
|
672 | }
|
673 | }
|
674 | } else {
|
675 | str = ctx.stylize('[Circular]', 'special');
|
676 | }
|
677 | }
|
678 | if (isUndefined(name)) {
|
679 | if (array && key.match(/^\d+$/)) {
|
680 | return str;
|
681 | }
|
682 | name = JSON.stringify('' + key);
|
683 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
684 | name = name.substr(1, name.length - 2);
|
685 | name = ctx.stylize(name, 'name');
|
686 | } else {
|
687 | name = name.replace(/'/g, "\\'")
|
688 | .replace(/\\"/g, '"')
|
689 | .replace(/(^"|"$)/g, "'");
|
690 | name = ctx.stylize(name, 'string');
|
691 | }
|
692 | }
|
693 |
|
694 | return name + ': ' + str;
|
695 | }
|
696 |
|
697 |
|
698 | function reduceToSingleString(output, base, braces) {
|
699 | var numLinesEst = 0;
|
700 | var length = output.reduce(function(prev, cur) {
|
701 | numLinesEst++;
|
702 | if (cur.indexOf('\n') >= 0) numLinesEst++;
|
703 | return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
704 | }, 0);
|
705 |
|
706 | if (length > 60) {
|
707 | return braces[0] +
|
708 | (base === '' ? '' : base + '\n ') +
|
709 | ' ' +
|
710 | output.join(',\n ') +
|
711 | ' ' +
|
712 | braces[1];
|
713 | }
|
714 |
|
715 | return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
716 | }
|
717 |
|
718 |
|
719 |
|
720 |
|
721 | function isArray(ar) {
|
722 | return Array.isArray(ar);
|
723 | }
|
724 | exports.isArray = isArray;
|
725 |
|
726 | function isBoolean(arg) {
|
727 | return typeof arg === 'boolean';
|
728 | }
|
729 | exports.isBoolean = isBoolean;
|
730 |
|
731 | function isNull(arg) {
|
732 | return arg === null;
|
733 | }
|
734 | exports.isNull = isNull;
|
735 |
|
736 | function isNullOrUndefined(arg) {
|
737 | return arg == null;
|
738 | }
|
739 | exports.isNullOrUndefined = isNullOrUndefined;
|
740 |
|
741 | function isNumber(arg) {
|
742 | return typeof arg === 'number';
|
743 | }
|
744 | exports.isNumber = isNumber;
|
745 |
|
746 | function isString(arg) {
|
747 | return typeof arg === 'string';
|
748 | }
|
749 | exports.isString = isString;
|
750 |
|
751 | function isSymbol(arg) {
|
752 | return typeof arg === 'symbol';
|
753 | }
|
754 | exports.isSymbol = isSymbol;
|
755 |
|
756 | function isUndefined(arg) {
|
757 | return arg === void 0;
|
758 | }
|
759 | exports.isUndefined = isUndefined;
|
760 |
|
761 | function isRegExp(re) {
|
762 | return isObject(re) && objectToString(re) === '[object RegExp]';
|
763 | }
|
764 | exports.isRegExp = isRegExp;
|
765 |
|
766 | function isObject(arg) {
|
767 | return typeof arg === 'object' && arg !== null;
|
768 | }
|
769 | exports.isObject = isObject;
|
770 |
|
771 | function isDate(d) {
|
772 | return isObject(d) && objectToString(d) === '[object Date]';
|
773 | }
|
774 | exports.isDate = isDate;
|
775 |
|
776 | function isError(e) {
|
777 | return isObject(e) &&
|
778 | (objectToString(e) === '[object Error]' || e instanceof Error);
|
779 | }
|
780 | exports.isError = isError;
|
781 |
|
782 | function isFunction(arg) {
|
783 | return typeof arg === 'function';
|
784 | }
|
785 | exports.isFunction = isFunction;
|
786 |
|
787 | function isPrimitive(arg) {
|
788 | return arg === null ||
|
789 | typeof arg === 'boolean' ||
|
790 | typeof arg === 'number' ||
|
791 | typeof arg === 'string' ||
|
792 | typeof arg === 'symbol' ||
|
793 | typeof arg === 'undefined';
|
794 | }
|
795 | exports.isPrimitive = isPrimitive;
|
796 |
|
797 | exports.isBuffer = require('./support/isBuffer');
|
798 |
|
799 | function objectToString(o) {
|
800 | return Object.prototype.toString.call(o);
|
801 | }
|
802 |
|
803 |
|
804 | function pad(n) {
|
805 | return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
806 | }
|
807 |
|
808 |
|
809 | var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
810 | 'Oct', 'Nov', 'Dec'];
|
811 |
|
812 |
|
813 | function timestamp() {
|
814 | var d = new Date();
|
815 | var time = [pad(d.getHours()),
|
816 | pad(d.getMinutes()),
|
817 | pad(d.getSeconds())].join(':');
|
818 | return [d.getDate(), months[d.getMonth()], time].join(' ');
|
819 | }
|
820 |
|
821 |
|
822 |
|
823 | exports.log = function() {
|
824 | console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
825 | };
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 |
|
833 |
|
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 | exports.inherits = require('inherits');
|
842 |
|
843 | exports._extend = function(origin, add) {
|
844 |
|
845 | if (!add || !isObject(add)) return origin;
|
846 |
|
847 | var keys = Object.keys(add);
|
848 | var i = keys.length;
|
849 | while (i--) {
|
850 | origin[keys[i]] = add[keys[i]];
|
851 | }
|
852 | return origin;
|
853 | };
|
854 |
|
855 | function hasOwnProperty(obj, prop) {
|
856 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
857 | }
|
858 |
|
859 | }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
860 | },{"./support/isBuffer":4,"_process":2,"inherits":3}],6:[function(require,module,exports){
|
861 | "use strict";
|
862 | Object.defineProperty(exports, "__esModule", { value: true });
|
863 | var main_1 = require("./main");
|
864 | Object.defineProperty(exports, "ConnectionString", { enumerable: true, get: function () { return main_1.ConnectionString; } });
|
865 | var types_1 = require("./types");
|
866 | Object.defineProperty(exports, "HostType", { enumerable: true, get: function () { return types_1.HostType; } });
|
867 |
|
868 | },{"./main":7,"./types":9}],7:[function(require,module,exports){
|
869 | (function (process){
|
870 | "use strict";
|
871 | Object.defineProperty(exports, "__esModule", { value: true });
|
872 | exports.ConnectionString = void 0;
|
873 | var util_1 = require("util");
|
874 | var os_1 = require("os");
|
875 | var types_1 = require("./types");
|
876 | var static_1 = require("./static");
|
877 | var errInvalidDefaults = "Invalid \"defaults\" parameter: ";
|
878 | var ConnectionString = (function () {
|
879 | |
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 | function ConnectionString(cs, defaults) {
|
888 | var _this = this;
|
889 | if (!(this instanceof ConnectionString)) {
|
890 | throw new TypeError("Class constructor ConnectionString cannot be invoked without 'new'");
|
891 | }
|
892 | if (typeof cs !== 'string') {
|
893 | throw new TypeError("Invalid connection string: " + JSON.stringify(cs));
|
894 | }
|
895 | if (typeof (defaults !== null && defaults !== void 0 ? defaults : {}) !== 'object') {
|
896 | throw new TypeError(errInvalidDefaults + JSON.stringify(defaults));
|
897 | }
|
898 | cs = cs.trim();
|
899 | static_1.validateUrl(cs);
|
900 |
|
901 | var m = cs.match(/^[\w-_.+!*'()$%:]*:\/\//);
|
902 | if (m) {
|
903 | var protocol = m[0].replace(/:\/\//, '');
|
904 | if (protocol) {
|
905 | this.protocol = static_1.decode(protocol);
|
906 | }
|
907 | cs = cs.substr(m[0].length);
|
908 | }
|
909 |
|
910 | m = cs.match(/^([\w-_.+!*'()$%]*):?([\w-_.+!*'()$%]*)@/);
|
911 | if (m) {
|
912 | if (m[1]) {
|
913 | this.user = static_1.decode(m[1]);
|
914 | }
|
915 | if (m[2]) {
|
916 | this.password = static_1.decode(m[2]);
|
917 | }
|
918 | cs = cs.substr(m[0].length);
|
919 | }
|
920 |
|
921 |
|
922 | if (cs[0] !== '/') {
|
923 | var endOfHosts = cs.search(/[\/?]/);
|
924 | var hosts = (endOfHosts === -1 ? cs : cs.substr(0, endOfHosts)).split(',');
|
925 | hosts.forEach(function (h) {
|
926 | var host = static_1.parseHost(h);
|
927 | if (host) {
|
928 | if (!_this.hosts) {
|
929 | _this.hosts = [];
|
930 | }
|
931 | _this.hosts.push(host);
|
932 | }
|
933 | });
|
934 | if (endOfHosts >= 0) {
|
935 | cs = cs.substr(endOfHosts);
|
936 | }
|
937 | }
|
938 |
|
939 | m = cs.match(/\/([\w-_.+!*'()$%]+)/g);
|
940 | if (m) {
|
941 | this.path = m.map(function (s) { return static_1.decode(s.substr(1)); });
|
942 | }
|
943 |
|
944 | var idx = cs.indexOf('?');
|
945 | if (idx !== -1) {
|
946 | cs = cs.substr(idx + 1);
|
947 | m = cs.match(/([\w-_.+!*'()$%]+)=([\w-_.+!*'()$%]+)/g);
|
948 | if (m) {
|
949 | var params_1 = {};
|
950 | m.forEach(function (s) {
|
951 | var a = s.split('=');
|
952 | var prop = static_1.decode(a[0]);
|
953 | if (prop in params_1) {
|
954 | throw new Error("Parameter \"" + prop + "\" repeated.");
|
955 | }
|
956 | params_1[prop] = static_1.decode(a[1]);
|
957 | });
|
958 | this.params = params_1;
|
959 | }
|
960 | }
|
961 | if (defaults) {
|
962 | this.setDefaults(defaults);
|
963 | }
|
964 | }
|
965 | Object.defineProperty(ConnectionString.prototype, "hostname", {
|
966 | |
967 |
|
968 |
|
969 | get: function () {
|
970 | var _a;
|
971 | return (_a = this.hosts) === null || _a === void 0 ? void 0 : _a[0].name;
|
972 | },
|
973 | enumerable: false,
|
974 | configurable: true
|
975 | });
|
976 | Object.defineProperty(ConnectionString.prototype, "port", {
|
977 | |
978 |
|
979 |
|
980 | get: function () {
|
981 | var _a;
|
982 | return (_a = this.hosts) === null || _a === void 0 ? void 0 : _a[0].port;
|
983 | },
|
984 | enumerable: false,
|
985 | configurable: true
|
986 | });
|
987 | Object.defineProperty(ConnectionString.prototype, "type", {
|
988 | |
989 |
|
990 |
|
991 | get: function () {
|
992 | var _a;
|
993 | return (_a = this.hosts) === null || _a === void 0 ? void 0 : _a[0].type;
|
994 | },
|
995 | enumerable: false,
|
996 | configurable: true
|
997 | });
|
998 | |
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 | ConnectionString.parseHost = function (host) {
|
1004 | return static_1.parseHost(host, true);
|
1005 | };
|
1006 | |
1007 |
|
1008 |
|
1009 | ConnectionString.prototype.toString = function (options) {
|
1010 | var s = '';
|
1011 | var opts = options || {};
|
1012 | if (this.protocol) {
|
1013 | s += static_1.encode(this.protocol, opts).replace(/%3A/g, ':') + '://';
|
1014 | }
|
1015 | if (this.user || this.password) {
|
1016 | if (this.user) {
|
1017 | s += static_1.encode(this.user, opts);
|
1018 | }
|
1019 | if (this.password) {
|
1020 | s += ':';
|
1021 | var h = opts.passwordHash;
|
1022 | if (h) {
|
1023 | var code = (typeof h === 'string' && h[0]) || '#';
|
1024 | s += code.repeat(this.password.length);
|
1025 | }
|
1026 | else {
|
1027 | s += static_1.encode(this.password, opts);
|
1028 | }
|
1029 | }
|
1030 | s += '@';
|
1031 | }
|
1032 | if (Array.isArray(this.hosts)) {
|
1033 | s += this.hosts.map(function (h) { return static_1.fullHostName(h, options); }).join();
|
1034 | }
|
1035 | if (Array.isArray(this.path)) {
|
1036 | this.path.forEach(function (seg) {
|
1037 | s += '/' + static_1.encode(seg, opts);
|
1038 | });
|
1039 | }
|
1040 | if (this.params && typeof this.params === 'object') {
|
1041 | var params = [];
|
1042 | for (var a in this.params) {
|
1043 | var value = this.params[a];
|
1044 | if (typeof value !== 'string') {
|
1045 | value = JSON.stringify(value);
|
1046 | }
|
1047 | value = static_1.encode(value, opts);
|
1048 | if (opts.plusForSpace) {
|
1049 | value = value.replace(/%20/g, '+');
|
1050 | }
|
1051 | params.push(static_1.encode(a, opts) + "=" + value);
|
1052 | }
|
1053 | if (params.length) {
|
1054 | s += "?" + params.join('&');
|
1055 | }
|
1056 | }
|
1057 | return s;
|
1058 | };
|
1059 | |
1060 |
|
1061 |
|
1062 | ConnectionString.prototype.setDefaults = function (defaults) {
|
1063 | if (!defaults || typeof defaults !== 'object') {
|
1064 | throw new TypeError(errInvalidDefaults + JSON.stringify(defaults));
|
1065 | }
|
1066 | if (!('protocol' in this) && static_1.hasText(defaults.protocol)) {
|
1067 | this.protocol = defaults.protocol.trim();
|
1068 | }
|
1069 |
|
1070 | if (Array.isArray(defaults.hosts)) {
|
1071 | var hosts_1 = Array.isArray(this.hosts) ? this.hosts : [];
|
1072 | var dhHosts = defaults.hosts.filter(function (d) { return d && typeof d === 'object'; });
|
1073 | dhHosts.forEach(function (dh) {
|
1074 | var dhName = static_1.hasText(dh.name) ? dh.name.trim() : undefined;
|
1075 | var h = { name: dhName, port: dh.port, type: dh.type };
|
1076 | var found = false;
|
1077 | for (var i = 0; i < hosts_1.length; i++) {
|
1078 | var thisHost = static_1.fullHostName(hosts_1[i]), defHost = static_1.fullHostName(h);
|
1079 | if (thisHost.toLowerCase() === defHost.toLowerCase()) {
|
1080 | found = true;
|
1081 | break;
|
1082 | }
|
1083 | }
|
1084 | if (!found) {
|
1085 | var obj_1 = {};
|
1086 | if (h.name) {
|
1087 | if (h.type && h.type in types_1.HostType) {
|
1088 | obj_1.name = h.name;
|
1089 | obj_1.type = h.type;
|
1090 | }
|
1091 | else {
|
1092 | var t = static_1.parseHost(h.name, true);
|
1093 | if (t) {
|
1094 | obj_1.name = t.name;
|
1095 | obj_1.type = t.type;
|
1096 | }
|
1097 | }
|
1098 | }
|
1099 | var p = h.port;
|
1100 | if (typeof p === 'number' && p > 0 && p < 65536) {
|
1101 | obj_1.port = p;
|
1102 | }
|
1103 | if (obj_1.name || obj_1.port) {
|
1104 | Object.defineProperty(obj_1, 'toString', {
|
1105 | value: function (options) { return static_1.fullHostName(obj_1, options); }
|
1106 | });
|
1107 | hosts_1.push(obj_1);
|
1108 | }
|
1109 | }
|
1110 | });
|
1111 | if (hosts_1.length) {
|
1112 | this.hosts = hosts_1;
|
1113 | }
|
1114 | }
|
1115 | if (!('user' in this) && static_1.hasText(defaults.user)) {
|
1116 | this.user = defaults.user.trim();
|
1117 | }
|
1118 | if (!('password' in this) && static_1.hasText(defaults.password)) {
|
1119 | this.password = defaults.password.trim();
|
1120 | }
|
1121 |
|
1122 |
|
1123 | if (!('path' in this) && Array.isArray(defaults.path)) {
|
1124 | var s = defaults.path.filter(static_1.hasText);
|
1125 | if (s.length) {
|
1126 | this.path = s;
|
1127 | }
|
1128 | }
|
1129 |
|
1130 | if (defaults.params && typeof defaults.params === 'object') {
|
1131 | var keys = Object.keys(defaults.params);
|
1132 | if (keys.length) {
|
1133 | if (this.params && typeof (this.params) === 'object') {
|
1134 | for (var a in defaults.params) {
|
1135 | if (!(a in this.params)) {
|
1136 | this.params[a] = defaults.params[a];
|
1137 | }
|
1138 | }
|
1139 | }
|
1140 | else {
|
1141 | this.params = {};
|
1142 | for (var b in defaults.params) {
|
1143 | this.params[b] = defaults.params[b];
|
1144 | }
|
1145 | }
|
1146 | }
|
1147 | }
|
1148 | return this;
|
1149 | };
|
1150 | return ConnectionString;
|
1151 | }());
|
1152 | exports.ConnectionString = ConnectionString;
|
1153 | (function () {
|
1154 |
|
1155 | ['setDefaults', 'toString', 'hostname', 'port', 'type'].forEach(function (prop) {
|
1156 | var desc = Object.getOwnPropertyDescriptor(ConnectionString.prototype, prop);
|
1157 | desc.enumerable = false;
|
1158 | Object.defineProperty(ConnectionString.prototype, prop, desc);
|
1159 | });
|
1160 | var inspecting = false;
|
1161 |
|
1162 | console.log('INSPECT:', util_1.inspect.custom);
|
1163 | if (util_1.inspect.custom) {
|
1164 | Object.defineProperty(ConnectionString.prototype, util_1.inspect.custom, {
|
1165 | value: function () {
|
1166 | if (inspecting) {
|
1167 | return this;
|
1168 | }
|
1169 | inspecting = true;
|
1170 | var options = { colors: process.stdout.isTTY };
|
1171 | var src = util_1.inspect(this, options);
|
1172 | var _a = this, hostname = _a.hostname, port = _a.port, type = _a.type;
|
1173 | var vp = util_1.inspect({ hostname: hostname, port: port, type: type }, options);
|
1174 | inspecting = false;
|
1175 | return "" + src + os_1.EOL + "Virtual Properties: " + vp;
|
1176 | }
|
1177 | });
|
1178 | }
|
1179 | })();
|
1180 |
|
1181 | }).call(this,require('_process'))
|
1182 | },{"./static":8,"./types":9,"_process":2,"os":1,"util":5}],8:[function(require,module,exports){
|
1183 | "use strict";
|
1184 | Object.defineProperty(exports, "__esModule", { value: true });
|
1185 | exports.parseHost = exports.validateUrl = exports.hasText = exports.decode = exports.encode = exports.fullHostName = void 0;
|
1186 | var types_1 = require("./types");
|
1187 | function fullHostName(obj, options) {
|
1188 | var a = '';
|
1189 | if (obj.name) {
|
1190 | var skipEncoding = obj.type === types_1.HostType.IPv4 || obj.type === types_1.HostType.IPv6;
|
1191 | a = skipEncoding ? obj.name : encode(obj.name, options !== null && options !== void 0 ? options : {});
|
1192 | }
|
1193 | if (obj.port) {
|
1194 | a += ':' + obj.port;
|
1195 | }
|
1196 | return a;
|
1197 | }
|
1198 | exports.fullHostName = fullHostName;
|
1199 | function encode(text, options) {
|
1200 | text = encodeURIComponent(text);
|
1201 | if (options.plusForSpace) {
|
1202 | text = text.replace(/%20/g, '+');
|
1203 | }
|
1204 | return options.encodeDollar ? text : text.replace(/%24/g, '$');
|
1205 | }
|
1206 | exports.encode = encode;
|
1207 | function decode(text) {
|
1208 | return decodeURIComponent(text.replace(/\+/g, '%20'));
|
1209 | }
|
1210 | exports.decode = decode;
|
1211 | function hasText(txt) {
|
1212 | return typeof txt === 'string' && /\S/.test(txt);
|
1213 | }
|
1214 | exports.hasText = hasText;
|
1215 | function validateUrl(url) {
|
1216 | var idx = url.search(/[^A-Za-z0-9-._:/?[\]@!$&'()*+,;=%]/);
|
1217 | if (idx >= 0) {
|
1218 | var s = JSON.stringify(url[idx]).replace(/^"|"$/g, "'");
|
1219 | throw new Error("Invalid URL character " + s + " at position " + idx);
|
1220 | }
|
1221 | }
|
1222 | exports.validateUrl = validateUrl;
|
1223 | function parseHost(host, direct) {
|
1224 | if (direct) {
|
1225 | if (typeof host !== 'string') {
|
1226 | throw new TypeError("Invalid \"host\" parameter: " + JSON.stringify(host));
|
1227 | }
|
1228 | host = host.trim();
|
1229 | }
|
1230 | var m, isIPv6;
|
1231 | if (host[0] === '[') {
|
1232 |
|
1233 | m = host.match(/((\[[0-9a-z:%]{2,45}])(?::(-?[0-9a-z]+))?)/i);
|
1234 | isIPv6 = true;
|
1235 | }
|
1236 | else {
|
1237 |
|
1238 | if (direct) {
|
1239 |
|
1240 | m = host.match(/(([a-z0-9.$/\- ]*)(?::(-?[0-9a-z]+))?)/i);
|
1241 | }
|
1242 | else {
|
1243 |
|
1244 | m = host.match(/(([a-z0-9.+$%\-]*)(?::(-?[0-9a-z]+))?)/i);
|
1245 | }
|
1246 | }
|
1247 | if (m) {
|
1248 | var h_1 = {};
|
1249 | if (m[2]) {
|
1250 | if (isIPv6) {
|
1251 | h_1.name = m[2];
|
1252 | h_1.type = types_1.HostType.IPv6;
|
1253 | }
|
1254 | else {
|
1255 | if (m[2].match(/([0-9]{1,3}\.){3}[0-9]{1,3}/)) {
|
1256 | h_1.name = m[2];
|
1257 | h_1.type = types_1.HostType.IPv4;
|
1258 | }
|
1259 | else {
|
1260 | h_1.name = direct ? m[2] : decode(m[2]);
|
1261 | h_1.type = h_1.name.match(/\/|.*\.sock$/i) ? types_1.HostType.socket : types_1.HostType.domain;
|
1262 | }
|
1263 | }
|
1264 | }
|
1265 | if (m[3]) {
|
1266 | var p = m[3], port = parseInt(p);
|
1267 | if (port > 0 && port < 65536 && port.toString() === p) {
|
1268 | h_1.port = port;
|
1269 | }
|
1270 | else {
|
1271 | throw new Error("Invalid port: " + JSON.stringify(p) + ". Valid port range is: [1...65535]");
|
1272 | }
|
1273 | }
|
1274 | if (h_1.name || h_1.port) {
|
1275 | Object.defineProperty(h_1, 'toString', {
|
1276 | value: function (options) { return fullHostName(h_1, options); }
|
1277 | });
|
1278 | return h_1;
|
1279 | }
|
1280 | }
|
1281 | return null;
|
1282 | }
|
1283 | exports.parseHost = parseHost;
|
1284 |
|
1285 | },{"./types":9}],9:[function(require,module,exports){
|
1286 | "use strict";
|
1287 | Object.defineProperty(exports, "__esModule", { value: true });
|
1288 | exports.HostType = void 0;
|
1289 | var HostType;
|
1290 | (function (HostType) {
|
1291 | HostType["domain"] = "domain";
|
1292 | HostType["socket"] = "socket";
|
1293 | HostType["IPv4"] = "IPv4";
|
1294 | HostType["IPv6"] = "IPv6";
|
1295 | })(HostType = exports.HostType || (exports.HostType = {}));
|
1296 |
|
1297 | },{}]},{},[6])(6)
|
1298 | });
|