UNPKG

580 kBJavaScriptView Raw
1(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(function (process,global){
3'use strict';
4
5/* eslint no-unused-vars: off */
6/* eslint-env commonjs */
7
8/**
9 * Shim process.stdout.
10 */
11
12process.stdout = require('browser-stdout')({label: false});
13
14var Mocha = require('./lib/mocha');
15
16/**
17 * Create a Mocha instance.
18 *
19 * @return {undefined}
20 */
21
22var mocha = new Mocha({reporter: 'html'});
23
24/**
25 * Save timer references to avoid Sinon interfering (see GH-237).
26 */
27
28var Date = global.Date;
29var setTimeout = global.setTimeout;
30var setInterval = global.setInterval;
31var clearTimeout = global.clearTimeout;
32var clearInterval = global.clearInterval;
33
34var uncaughtExceptionHandlers = [];
35
36var originalOnerrorHandler = global.onerror;
37
38/**
39 * Remove uncaughtException listener.
40 * Revert to original onerror handler if previously defined.
41 */
42
43process.removeListener = function(e, fn) {
44 if (e === 'uncaughtException') {
45 if (originalOnerrorHandler) {
46 global.onerror = originalOnerrorHandler;
47 } else {
48 global.onerror = function() {};
49 }
50 var i = uncaughtExceptionHandlers.indexOf(fn);
51 if (i !== -1) {
52 uncaughtExceptionHandlers.splice(i, 1);
53 }
54 }
55};
56
57/**
58 * Implements uncaughtException listener.
59 */
60
61process.on = function(e, fn) {
62 if (e === 'uncaughtException') {
63 global.onerror = function(err, url, line) {
64 fn(new Error(err + ' (' + url + ':' + line + ')'));
65 return !mocha.allowUncaught;
66 };
67 uncaughtExceptionHandlers.push(fn);
68 }
69};
70
71// The BDD UI is registered by default, but no UI will be functional in the
72// browser without an explicit call to the overridden `mocha.ui` (see below).
73// Ensure that this default UI does not expose its methods to the global scope.
74mocha.suite.removeAllListeners('pre-require');
75
76var immediateQueue = [];
77var immediateTimeout;
78
79function timeslice() {
80 var immediateStart = new Date().getTime();
81 while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
82 immediateQueue.shift()();
83 }
84 if (immediateQueue.length) {
85 immediateTimeout = setTimeout(timeslice, 0);
86 } else {
87 immediateTimeout = null;
88 }
89}
90
91/**
92 * High-performance override of Runner.immediately.
93 */
94
95Mocha.Runner.immediately = function(callback) {
96 immediateQueue.push(callback);
97 if (!immediateTimeout) {
98 immediateTimeout = setTimeout(timeslice, 0);
99 }
100};
101
102/**
103 * Function to allow assertion libraries to throw errors directly into mocha.
104 * This is useful when running tests in a browser because window.onerror will
105 * only receive the 'message' attribute of the Error.
106 */
107mocha.throwError = function(err) {
108 uncaughtExceptionHandlers.forEach(function(fn) {
109 fn(err);
110 });
111 throw err;
112};
113
114/**
115 * Override ui to ensure that the ui functions are initialized.
116 * Normally this would happen in Mocha.prototype.loadFiles.
117 */
118
119mocha.ui = function(ui) {
120 Mocha.prototype.ui.call(this, ui);
121 this.suite.emit('pre-require', global, null, this);
122 return this;
123};
124
125/**
126 * Setup mocha with the given setting options.
127 */
128
129mocha.setup = function(opts) {
130 if (typeof opts === 'string') {
131 opts = {ui: opts};
132 }
133 for (var opt in opts) {
134 if (opts.hasOwnProperty(opt)) {
135 this[opt](opts[opt]);
136 }
137 }
138 return this;
139};
140
141/**
142 * Run mocha, returning the Runner.
143 */
144
145mocha.run = function(fn) {
146 var options = mocha.options;
147 mocha.globals('location');
148
149 var query = Mocha.utils.parseQuery(global.location.search || '');
150 if (query.grep) {
151 mocha.grep(query.grep);
152 }
153 if (query.fgrep) {
154 mocha.fgrep(query.fgrep);
155 }
156 if (query.invert) {
157 mocha.invert();
158 }
159
160 return Mocha.prototype.run.call(mocha, function(err) {
161 // The DOM Document is not available in Web Workers.
162 var document = global.document;
163 if (
164 document &&
165 document.getElementById('mocha') &&
166 options.noHighlighting !== true
167 ) {
168 Mocha.utils.highlightTags('code');
169 }
170 if (fn) {
171 fn(err);
172 }
173 });
174};
175
176/**
177 * Expose the process shim.
178 * https://github.com/mochajs/mocha/pull/916
179 */
180
181Mocha.process = process;
182
183/**
184 * Expose mocha.
185 */
186
187global.Mocha = Mocha;
188global.mocha = mocha;
189
190// this allows test/acceptance/required-tokens.js to pass; thus,
191// you can now do `const describe = require('mocha').describe` in a
192// browser context (assuming browserification). should fix #880
193module.exports = global;
194
195}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
196},{"./lib/mocha":14,"_process":68,"browser-stdout":41}],2:[function(require,module,exports){
197(function (process,global){
198'use strict';
199
200/**
201 * Web Notifications module.
202 * @module Growl
203 */
204
205/**
206 * Save timer references to avoid Sinon interfering (see GH-237).
207 */
208var Date = global.Date;
209var setTimeout = global.setTimeout;
210var EVENT_RUN_END = require('../runner').constants.EVENT_RUN_END;
211
212/**
213 * Checks if browser notification support exists.
214 *
215 * @public
216 * @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)}
217 * @see {@link https://caniuse.com/#feat=promises|Browser support (promises)}
218 * @see {@link Mocha#growl}
219 * @see {@link Mocha#isGrowlCapable}
220 * @return {boolean} whether browser notification support exists
221 */
222exports.isCapable = function() {
223 var hasNotificationSupport = 'Notification' in window;
224 var hasPromiseSupport = typeof Promise === 'function';
225 return process.browser && hasNotificationSupport && hasPromiseSupport;
226};
227
228/**
229 * Implements browser notifications as a pseudo-reporter.
230 *
231 * @public
232 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API}
233 * @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification}
234 * @see {@link Growl#isPermitted}
235 * @see {@link Mocha#_growl}
236 * @param {Runner} runner - Runner instance.
237 */
238exports.notify = function(runner) {
239 var promise = isPermitted();
240
241 /**
242 * Attempt notification.
243 */
244 var sendNotification = function() {
245 // If user hasn't responded yet... "No notification for you!" (Seinfeld)
246 Promise.race([promise, Promise.resolve(undefined)])
247 .then(canNotify)
248 .then(function() {
249 display(runner);
250 })
251 .catch(notPermitted);
252 };
253
254 runner.once(EVENT_RUN_END, sendNotification);
255};
256
257/**
258 * Checks if browser notification is permitted by user.
259 *
260 * @private
261 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission}
262 * @see {@link Mocha#growl}
263 * @see {@link Mocha#isGrowlPermitted}
264 * @returns {Promise<boolean>} promise determining if browser notification
265 * permissible when fulfilled.
266 */
267function isPermitted() {
268 var permitted = {
269 granted: function allow() {
270 return Promise.resolve(true);
271 },
272 denied: function deny() {
273 return Promise.resolve(false);
274 },
275 default: function ask() {
276 return Notification.requestPermission().then(function(permission) {
277 return permission === 'granted';
278 });
279 }
280 };
281
282 return permitted[Notification.permission]();
283}
284
285/**
286 * @summary
287 * Determines if notification should proceed.
288 *
289 * @description
290 * Notification shall <strong>not</strong> proceed unless `value` is true.
291 *
292 * `value` will equal one of:
293 * <ul>
294 * <li><code>true</code> (from `isPermitted`)</li>
295 * <li><code>false</code> (from `isPermitted`)</li>
296 * <li><code>undefined</code> (from `Promise.race`)</li>
297 * </ul>
298 *
299 * @private
300 * @param {boolean|undefined} value - Determines if notification permissible.
301 * @returns {Promise<undefined>} Notification can proceed
302 */
303function canNotify(value) {
304 if (!value) {
305 var why = value === false ? 'blocked' : 'unacknowledged';
306 var reason = 'not permitted by user (' + why + ')';
307 return Promise.reject(new Error(reason));
308 }
309 return Promise.resolve();
310}
311
312/**
313 * Displays the notification.
314 *
315 * @private
316 * @param {Runner} runner - Runner instance.
317 */
318function display(runner) {
319 var stats = runner.stats;
320 var symbol = {
321 cross: '\u274C',
322 tick: '\u2705'
323 };
324 var logo = require('../../package').notifyLogo;
325 var _message;
326 var message;
327 var title;
328
329 if (stats.failures) {
330 _message = stats.failures + ' of ' + stats.tests + ' tests failed';
331 message = symbol.cross + ' ' + _message;
332 title = 'Failed';
333 } else {
334 _message = stats.passes + ' tests passed in ' + stats.duration + 'ms';
335 message = symbol.tick + ' ' + _message;
336 title = 'Passed';
337 }
338
339 // Send notification
340 var options = {
341 badge: logo,
342 body: message,
343 dir: 'ltr',
344 icon: logo,
345 lang: 'en-US',
346 name: 'mocha',
347 requireInteraction: false,
348 timestamp: Date.now()
349 };
350 var notification = new Notification(title, options);
351
352 // Autoclose after brief delay (makes various browsers act same)
353 var FORCE_DURATION = 4000;
354 setTimeout(notification.close.bind(notification), FORCE_DURATION);
355}
356
357/**
358 * As notifications are tangential to our purpose, just log the error.
359 *
360 * @private
361 * @param {Error} err - Why notification didn't happen.
362 */
363function notPermitted(err) {
364 console.error('notification error:', err.message);
365}
366
367}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
368},{"../../package":89,"../runner":34,"_process":68}],3:[function(require,module,exports){
369'use strict';
370
371/**
372 * Expose `Progress`.
373 */
374
375module.exports = Progress;
376
377/**
378 * Initialize a new `Progress` indicator.
379 */
380function Progress() {
381 this.percent = 0;
382 this.size(0);
383 this.fontSize(11);
384 this.font('helvetica, arial, sans-serif');
385}
386
387/**
388 * Set progress size to `size`.
389 *
390 * @public
391 * @param {number} size
392 * @return {Progress} Progress instance.
393 */
394Progress.prototype.size = function(size) {
395 this._size = size;
396 return this;
397};
398
399/**
400 * Set text to `text`.
401 *
402 * @public
403 * @param {string} text
404 * @return {Progress} Progress instance.
405 */
406Progress.prototype.text = function(text) {
407 this._text = text;
408 return this;
409};
410
411/**
412 * Set font size to `size`.
413 *
414 * @public
415 * @param {number} size
416 * @return {Progress} Progress instance.
417 */
418Progress.prototype.fontSize = function(size) {
419 this._fontSize = size;
420 return this;
421};
422
423/**
424 * Set font to `family`.
425 *
426 * @param {string} family
427 * @return {Progress} Progress instance.
428 */
429Progress.prototype.font = function(family) {
430 this._font = family;
431 return this;
432};
433
434/**
435 * Update percentage to `n`.
436 *
437 * @param {number} n
438 * @return {Progress} Progress instance.
439 */
440Progress.prototype.update = function(n) {
441 this.percent = n;
442 return this;
443};
444
445/**
446 * Draw on `ctx`.
447 *
448 * @param {CanvasRenderingContext2d} ctx
449 * @return {Progress} Progress instance.
450 */
451Progress.prototype.draw = function(ctx) {
452 try {
453 var percent = Math.min(this.percent, 100);
454 var size = this._size;
455 var half = size / 2;
456 var x = half;
457 var y = half;
458 var rad = half - 1;
459 var fontSize = this._fontSize;
460
461 ctx.font = fontSize + 'px ' + this._font;
462
463 var angle = Math.PI * 2 * (percent / 100);
464 ctx.clearRect(0, 0, size, size);
465
466 // outer circle
467 ctx.strokeStyle = '#9f9f9f';
468 ctx.beginPath();
469 ctx.arc(x, y, rad, 0, angle, false);
470 ctx.stroke();
471
472 // inner circle
473 ctx.strokeStyle = '#eee';
474 ctx.beginPath();
475 ctx.arc(x, y, rad - 1, 0, angle, true);
476 ctx.stroke();
477
478 // text
479 var text = this._text || (percent | 0) + '%';
480 var w = ctx.measureText(text).width;
481
482 ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
483 } catch (ignore) {
484 // don't fail if we can't render progress
485 }
486 return this;
487};
488
489},{}],4:[function(require,module,exports){
490(function (global){
491'use strict';
492
493exports.isatty = function isatty() {
494 return true;
495};
496
497exports.getWindowSize = function getWindowSize() {
498 if ('innerHeight' in global) {
499 return [global.innerHeight, global.innerWidth];
500 }
501 // In a Web Worker, the DOM Window is not available.
502 return [640, 480];
503};
504
505}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
506},{}],5:[function(require,module,exports){
507'use strict';
508/**
509 * @module Context
510 */
511/**
512 * Expose `Context`.
513 */
514
515module.exports = Context;
516
517/**
518 * Initialize a new `Context`.
519 *
520 * @private
521 */
522function Context() {}
523
524/**
525 * Set or get the context `Runnable` to `runnable`.
526 *
527 * @private
528 * @param {Runnable} runnable
529 * @return {Context} context
530 */
531Context.prototype.runnable = function(runnable) {
532 if (!arguments.length) {
533 return this._runnable;
534 }
535 this.test = this._runnable = runnable;
536 return this;
537};
538
539/**
540 * Set or get test timeout `ms`.
541 *
542 * @private
543 * @param {number} ms
544 * @return {Context} self
545 */
546Context.prototype.timeout = function(ms) {
547 if (!arguments.length) {
548 return this.runnable().timeout();
549 }
550 this.runnable().timeout(ms);
551 return this;
552};
553
554/**
555 * Set test timeout `enabled`.
556 *
557 * @private
558 * @param {boolean} enabled
559 * @return {Context} self
560 */
561Context.prototype.enableTimeouts = function(enabled) {
562 if (!arguments.length) {
563 return this.runnable().enableTimeouts();
564 }
565 this.runnable().enableTimeouts(enabled);
566 return this;
567};
568
569/**
570 * Set or get test slowness threshold `ms`.
571 *
572 * @private
573 * @param {number} ms
574 * @return {Context} self
575 */
576Context.prototype.slow = function(ms) {
577 if (!arguments.length) {
578 return this.runnable().slow();
579 }
580 this.runnable().slow(ms);
581 return this;
582};
583
584/**
585 * Mark a test as skipped.
586 *
587 * @private
588 * @throws Pending
589 */
590Context.prototype.skip = function() {
591 this.runnable().skip();
592};
593
594/**
595 * Set or get a number of allowed retries on failed tests
596 *
597 * @private
598 * @param {number} n
599 * @return {Context} self
600 */
601Context.prototype.retries = function(n) {
602 if (!arguments.length) {
603 return this.runnable().retries();
604 }
605 this.runnable().retries(n);
606 return this;
607};
608
609},{}],6:[function(require,module,exports){
610'use strict';
611/**
612 * @module Errors
613 */
614/**
615 * Factory functions to create throwable error objects
616 */
617
618/**
619 * Creates an error object to be thrown when no files to be tested could be found using specified pattern.
620 *
621 * @public
622 * @param {string} message - Error message to be displayed.
623 * @param {string} pattern - User-specified argument value.
624 * @returns {Error} instance detailing the error condition
625 */
626function createNoFilesMatchPatternError(message, pattern) {
627 var err = new Error(message);
628 err.code = 'ERR_MOCHA_NO_FILES_MATCH_PATTERN';
629 err.pattern = pattern;
630 return err;
631}
632
633/**
634 * Creates an error object to be thrown when the reporter specified in the options was not found.
635 *
636 * @public
637 * @param {string} message - Error message to be displayed.
638 * @param {string} reporter - User-specified reporter value.
639 * @returns {Error} instance detailing the error condition
640 */
641function createInvalidReporterError(message, reporter) {
642 var err = new TypeError(message);
643 err.code = 'ERR_MOCHA_INVALID_REPORTER';
644 err.reporter = reporter;
645 return err;
646}
647
648/**
649 * Creates an error object to be thrown when the interface specified in the options was not found.
650 *
651 * @public
652 * @param {string} message - Error message to be displayed.
653 * @param {string} ui - User-specified interface value.
654 * @returns {Error} instance detailing the error condition
655 */
656function createInvalidInterfaceError(message, ui) {
657 var err = new Error(message);
658 err.code = 'ERR_MOCHA_INVALID_INTERFACE';
659 err.interface = ui;
660 return err;
661}
662
663/**
664 * Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
665 *
666 * @public
667 * @param {string} message - Error message to be displayed.
668 * @returns {Error} instance detailing the error condition
669 */
670function createUnsupportedError(message) {
671 var err = new Error(message);
672 err.code = 'ERR_MOCHA_UNSUPPORTED';
673 return err;
674}
675
676/**
677 * Creates an error object to be thrown when an argument is missing.
678 *
679 * @public
680 * @param {string} message - Error message to be displayed.
681 * @param {string} argument - Argument name.
682 * @param {string} expected - Expected argument datatype.
683 * @returns {Error} instance detailing the error condition
684 */
685function createMissingArgumentError(message, argument, expected) {
686 return createInvalidArgumentTypeError(message, argument, expected);
687}
688
689/**
690 * Creates an error object to be thrown when an argument did not use the supported type
691 *
692 * @public
693 * @param {string} message - Error message to be displayed.
694 * @param {string} argument - Argument name.
695 * @param {string} expected - Expected argument datatype.
696 * @returns {Error} instance detailing the error condition
697 */
698function createInvalidArgumentTypeError(message, argument, expected) {
699 var err = new TypeError(message);
700 err.code = 'ERR_MOCHA_INVALID_ARG_TYPE';
701 err.argument = argument;
702 err.expected = expected;
703 err.actual = typeof argument;
704 return err;
705}
706
707/**
708 * Creates an error object to be thrown when an argument did not use the supported value
709 *
710 * @public
711 * @param {string} message - Error message to be displayed.
712 * @param {string} argument - Argument name.
713 * @param {string} value - Argument value.
714 * @param {string} [reason] - Why value is invalid.
715 * @returns {Error} instance detailing the error condition
716 */
717function createInvalidArgumentValueError(message, argument, value, reason) {
718 var err = new TypeError(message);
719 err.code = 'ERR_MOCHA_INVALID_ARG_VALUE';
720 err.argument = argument;
721 err.value = value;
722 err.reason = typeof reason !== 'undefined' ? reason : 'is invalid';
723 return err;
724}
725
726/**
727 * Creates an error object to be thrown when an exception was caught, but the `Error` is falsy or undefined.
728 *
729 * @public
730 * @param {string} message - Error message to be displayed.
731 * @returns {Error} instance detailing the error condition
732 */
733function createInvalidExceptionError(message, value) {
734 var err = new Error(message);
735 err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
736 err.valueType = typeof value;
737 err.value = value;
738 return err;
739}
740
741module.exports = {
742 createInvalidArgumentTypeError: createInvalidArgumentTypeError,
743 createInvalidArgumentValueError: createInvalidArgumentValueError,
744 createInvalidExceptionError: createInvalidExceptionError,
745 createInvalidInterfaceError: createInvalidInterfaceError,
746 createInvalidReporterError: createInvalidReporterError,
747 createMissingArgumentError: createMissingArgumentError,
748 createNoFilesMatchPatternError: createNoFilesMatchPatternError,
749 createUnsupportedError: createUnsupportedError
750};
751
752},{}],7:[function(require,module,exports){
753'use strict';
754
755var Runnable = require('./runnable');
756var inherits = require('./utils').inherits;
757
758/**
759 * Expose `Hook`.
760 */
761
762module.exports = Hook;
763
764/**
765 * Initialize a new `Hook` with the given `title` and callback `fn`
766 *
767 * @class
768 * @extends Runnable
769 * @param {String} title
770 * @param {Function} fn
771 */
772function Hook(title, fn) {
773 Runnable.call(this, title, fn);
774 this.type = 'hook';
775}
776
777/**
778 * Inherit from `Runnable.prototype`.
779 */
780inherits(Hook, Runnable);
781
782/**
783 * Get or set the test `err`.
784 *
785 * @memberof Hook
786 * @public
787 * @param {Error} err
788 * @return {Error}
789 */
790Hook.prototype.error = function(err) {
791 if (!arguments.length) {
792 err = this._error;
793 this._error = null;
794 return err;
795 }
796
797 this._error = err;
798};
799
800},{"./runnable":33,"./utils":38}],8:[function(require,module,exports){
801'use strict';
802
803var Test = require('../test');
804var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
805 .EVENT_FILE_PRE_REQUIRE;
806
807/**
808 * BDD-style interface:
809 *
810 * describe('Array', function() {
811 * describe('#indexOf()', function() {
812 * it('should return -1 when not present', function() {
813 * // ...
814 * });
815 *
816 * it('should return the index when present', function() {
817 * // ...
818 * });
819 * });
820 * });
821 *
822 * @param {Suite} suite Root suite.
823 */
824module.exports = function bddInterface(suite) {
825 var suites = [suite];
826
827 suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
828 var common = require('./common')(suites, context, mocha);
829
830 context.before = common.before;
831 context.after = common.after;
832 context.beforeEach = common.beforeEach;
833 context.afterEach = common.afterEach;
834 context.run = mocha.options.delay && common.runWithSuite(suite);
835 /**
836 * Describe a "suite" with the given `title`
837 * and callback `fn` containing nested suites
838 * and/or tests.
839 */
840
841 context.describe = context.context = function(title, fn) {
842 return common.suite.create({
843 title: title,
844 file: file,
845 fn: fn
846 });
847 };
848
849 /**
850 * Pending describe.
851 */
852
853 context.xdescribe = context.xcontext = context.describe.skip = function(
854 title,
855 fn
856 ) {
857 return common.suite.skip({
858 title: title,
859 file: file,
860 fn: fn
861 });
862 };
863
864 /**
865 * Exclusive suite.
866 */
867
868 context.describe.only = function(title, fn) {
869 return common.suite.only({
870 title: title,
871 file: file,
872 fn: fn
873 });
874 };
875
876 /**
877 * Describe a specification or test-case
878 * with the given `title` and callback `fn`
879 * acting as a thunk.
880 */
881
882 context.it = context.specify = function(title, fn) {
883 var suite = suites[0];
884 if (suite.isPending()) {
885 fn = null;
886 }
887 var test = new Test(title, fn);
888 test.file = file;
889 suite.addTest(test);
890 return test;
891 };
892
893 /**
894 * Exclusive test-case.
895 */
896
897 context.it.only = function(title, fn) {
898 return common.test.only(mocha, context.it(title, fn));
899 };
900
901 /**
902 * Pending test case.
903 */
904
905 context.xit = context.xspecify = context.it.skip = function(title) {
906 return context.it(title);
907 };
908
909 /**
910 * Number of attempts to retry.
911 */
912 context.it.retries = function(n) {
913 context.retries(n);
914 };
915 });
916};
917
918module.exports.description = 'BDD or RSpec style [default]';
919
920},{"../suite":36,"../test":37,"./common":9}],9:[function(require,module,exports){
921'use strict';
922
923var Suite = require('../suite');
924var errors = require('../errors');
925var createMissingArgumentError = errors.createMissingArgumentError;
926
927/**
928 * Functions common to more than one interface.
929 *
930 * @param {Suite[]} suites
931 * @param {Context} context
932 * @param {Mocha} mocha
933 * @return {Object} An object containing common functions.
934 */
935module.exports = function(suites, context, mocha) {
936 /**
937 * Check if the suite should be tested.
938 *
939 * @private
940 * @param {Suite} suite - suite to check
941 * @returns {boolean}
942 */
943 function shouldBeTested(suite) {
944 return (
945 !mocha.options.grep ||
946 (mocha.options.grep &&
947 mocha.options.grep.test(suite.fullTitle()) &&
948 !mocha.options.invert)
949 );
950 }
951
952 return {
953 /**
954 * This is only present if flag --delay is passed into Mocha. It triggers
955 * root suite execution.
956 *
957 * @param {Suite} suite The root suite.
958 * @return {Function} A function which runs the root suite
959 */
960 runWithSuite: function runWithSuite(suite) {
961 return function run() {
962 suite.run();
963 };
964 },
965
966 /**
967 * Execute before running tests.
968 *
969 * @param {string} name
970 * @param {Function} fn
971 */
972 before: function(name, fn) {
973 suites[0].beforeAll(name, fn);
974 },
975
976 /**
977 * Execute after running tests.
978 *
979 * @param {string} name
980 * @param {Function} fn
981 */
982 after: function(name, fn) {
983 suites[0].afterAll(name, fn);
984 },
985
986 /**
987 * Execute before each test case.
988 *
989 * @param {string} name
990 * @param {Function} fn
991 */
992 beforeEach: function(name, fn) {
993 suites[0].beforeEach(name, fn);
994 },
995
996 /**
997 * Execute after each test case.
998 *
999 * @param {string} name
1000 * @param {Function} fn
1001 */
1002 afterEach: function(name, fn) {
1003 suites[0].afterEach(name, fn);
1004 },
1005
1006 suite: {
1007 /**
1008 * Create an exclusive Suite; convenience function
1009 * See docstring for create() below.
1010 *
1011 * @param {Object} opts
1012 * @returns {Suite}
1013 */
1014 only: function only(opts) {
1015 opts.isOnly = true;
1016 return this.create(opts);
1017 },
1018
1019 /**
1020 * Create a Suite, but skip it; convenience function
1021 * See docstring for create() below.
1022 *
1023 * @param {Object} opts
1024 * @returns {Suite}
1025 */
1026 skip: function skip(opts) {
1027 opts.pending = true;
1028 return this.create(opts);
1029 },
1030
1031 /**
1032 * Creates a suite.
1033 *
1034 * @param {Object} opts Options
1035 * @param {string} opts.title Title of Suite
1036 * @param {Function} [opts.fn] Suite Function (not always applicable)
1037 * @param {boolean} [opts.pending] Is Suite pending?
1038 * @param {string} [opts.file] Filepath where this Suite resides
1039 * @param {boolean} [opts.isOnly] Is Suite exclusive?
1040 * @returns {Suite}
1041 */
1042 create: function create(opts) {
1043 var suite = Suite.create(suites[0], opts.title);
1044 suite.pending = Boolean(opts.pending);
1045 suite.file = opts.file;
1046 suites.unshift(suite);
1047 if (opts.isOnly) {
1048 if (mocha.options.forbidOnly && shouldBeTested(suite)) {
1049 throw new Error('`.only` forbidden');
1050 }
1051
1052 suite.parent.appendOnlySuite(suite);
1053 }
1054 if (suite.pending) {
1055 if (mocha.options.forbidPending && shouldBeTested(suite)) {
1056 throw new Error('Pending test forbidden');
1057 }
1058 }
1059 if (typeof opts.fn === 'function') {
1060 opts.fn.call(suite);
1061 suites.shift();
1062 } else if (typeof opts.fn === 'undefined' && !suite.pending) {
1063 throw createMissingArgumentError(
1064 'Suite "' +
1065 suite.fullTitle() +
1066 '" was defined but no callback was supplied. ' +
1067 'Supply a callback or explicitly skip the suite.',
1068 'callback',
1069 'function'
1070 );
1071 } else if (!opts.fn && suite.pending) {
1072 suites.shift();
1073 }
1074
1075 return suite;
1076 }
1077 },
1078
1079 test: {
1080 /**
1081 * Exclusive test-case.
1082 *
1083 * @param {Object} mocha
1084 * @param {Function} test
1085 * @returns {*}
1086 */
1087 only: function(mocha, test) {
1088 test.parent.appendOnlyTest(test);
1089 return test;
1090 },
1091
1092 /**
1093 * Pending test case.
1094 *
1095 * @param {string} title
1096 */
1097 skip: function(title) {
1098 context.test(title);
1099 },
1100
1101 /**
1102 * Number of retry attempts
1103 *
1104 * @param {number} n
1105 */
1106 retries: function(n) {
1107 context.retries(n);
1108 }
1109 }
1110 };
1111};
1112
1113},{"../errors":6,"../suite":36}],10:[function(require,module,exports){
1114'use strict';
1115var Suite = require('../suite');
1116var Test = require('../test');
1117
1118/**
1119 * Exports-style (as Node.js module) interface:
1120 *
1121 * exports.Array = {
1122 * '#indexOf()': {
1123 * 'should return -1 when the value is not present': function() {
1124 *
1125 * },
1126 *
1127 * 'should return the correct index when the value is present': function() {
1128 *
1129 * }
1130 * }
1131 * };
1132 *
1133 * @param {Suite} suite Root suite.
1134 */
1135module.exports = function(suite) {
1136 var suites = [suite];
1137
1138 suite.on(Suite.constants.EVENT_FILE_REQUIRE, visit);
1139
1140 function visit(obj, file) {
1141 var suite;
1142 for (var key in obj) {
1143 if (typeof obj[key] === 'function') {
1144 var fn = obj[key];
1145 switch (key) {
1146 case 'before':
1147 suites[0].beforeAll(fn);
1148 break;
1149 case 'after':
1150 suites[0].afterAll(fn);
1151 break;
1152 case 'beforeEach':
1153 suites[0].beforeEach(fn);
1154 break;
1155 case 'afterEach':
1156 suites[0].afterEach(fn);
1157 break;
1158 default:
1159 var test = new Test(key, fn);
1160 test.file = file;
1161 suites[0].addTest(test);
1162 }
1163 } else {
1164 suite = Suite.create(suites[0], key);
1165 suites.unshift(suite);
1166 visit(obj[key], file);
1167 suites.shift();
1168 }
1169 }
1170 }
1171};
1172
1173module.exports.description = 'Node.js module ("exports") style';
1174
1175},{"../suite":36,"../test":37}],11:[function(require,module,exports){
1176'use strict';
1177
1178exports.bdd = require('./bdd');
1179exports.tdd = require('./tdd');
1180exports.qunit = require('./qunit');
1181exports.exports = require('./exports');
1182
1183},{"./bdd":8,"./exports":10,"./qunit":12,"./tdd":13}],12:[function(require,module,exports){
1184'use strict';
1185
1186var Test = require('../test');
1187var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
1188 .EVENT_FILE_PRE_REQUIRE;
1189
1190/**
1191 * QUnit-style interface:
1192 *
1193 * suite('Array');
1194 *
1195 * test('#length', function() {
1196 * var arr = [1,2,3];
1197 * ok(arr.length == 3);
1198 * });
1199 *
1200 * test('#indexOf()', function() {
1201 * var arr = [1,2,3];
1202 * ok(arr.indexOf(1) == 0);
1203 * ok(arr.indexOf(2) == 1);
1204 * ok(arr.indexOf(3) == 2);
1205 * });
1206 *
1207 * suite('String');
1208 *
1209 * test('#length', function() {
1210 * ok('foo'.length == 3);
1211 * });
1212 *
1213 * @param {Suite} suite Root suite.
1214 */
1215module.exports = function qUnitInterface(suite) {
1216 var suites = [suite];
1217
1218 suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
1219 var common = require('./common')(suites, context, mocha);
1220
1221 context.before = common.before;
1222 context.after = common.after;
1223 context.beforeEach = common.beforeEach;
1224 context.afterEach = common.afterEach;
1225 context.run = mocha.options.delay && common.runWithSuite(suite);
1226 /**
1227 * Describe a "suite" with the given `title`.
1228 */
1229
1230 context.suite = function(title) {
1231 if (suites.length > 1) {
1232 suites.shift();
1233 }
1234 return common.suite.create({
1235 title: title,
1236 file: file,
1237 fn: false
1238 });
1239 };
1240
1241 /**
1242 * Exclusive Suite.
1243 */
1244
1245 context.suite.only = function(title) {
1246 if (suites.length > 1) {
1247 suites.shift();
1248 }
1249 return common.suite.only({
1250 title: title,
1251 file: file,
1252 fn: false
1253 });
1254 };
1255
1256 /**
1257 * Describe a specification or test-case
1258 * with the given `title` and callback `fn`
1259 * acting as a thunk.
1260 */
1261
1262 context.test = function(title, fn) {
1263 var test = new Test(title, fn);
1264 test.file = file;
1265 suites[0].addTest(test);
1266 return test;
1267 };
1268
1269 /**
1270 * Exclusive test-case.
1271 */
1272
1273 context.test.only = function(title, fn) {
1274 return common.test.only(mocha, context.test(title, fn));
1275 };
1276
1277 context.test.skip = common.test.skip;
1278 context.test.retries = common.test.retries;
1279 });
1280};
1281
1282module.exports.description = 'QUnit style';
1283
1284},{"../suite":36,"../test":37,"./common":9}],13:[function(require,module,exports){
1285'use strict';
1286
1287var Test = require('../test');
1288var EVENT_FILE_PRE_REQUIRE = require('../suite').constants
1289 .EVENT_FILE_PRE_REQUIRE;
1290
1291/**
1292 * TDD-style interface:
1293 *
1294 * suite('Array', function() {
1295 * suite('#indexOf()', function() {
1296 * suiteSetup(function() {
1297 *
1298 * });
1299 *
1300 * test('should return -1 when not present', function() {
1301 *
1302 * });
1303 *
1304 * test('should return the index when present', function() {
1305 *
1306 * });
1307 *
1308 * suiteTeardown(function() {
1309 *
1310 * });
1311 * });
1312 * });
1313 *
1314 * @param {Suite} suite Root suite.
1315 */
1316module.exports = function(suite) {
1317 var suites = [suite];
1318
1319 suite.on(EVENT_FILE_PRE_REQUIRE, function(context, file, mocha) {
1320 var common = require('./common')(suites, context, mocha);
1321
1322 context.setup = common.beforeEach;
1323 context.teardown = common.afterEach;
1324 context.suiteSetup = common.before;
1325 context.suiteTeardown = common.after;
1326 context.run = mocha.options.delay && common.runWithSuite(suite);
1327
1328 /**
1329 * Describe a "suite" with the given `title` and callback `fn` containing
1330 * nested suites and/or tests.
1331 */
1332 context.suite = function(title, fn) {
1333 return common.suite.create({
1334 title: title,
1335 file: file,
1336 fn: fn
1337 });
1338 };
1339
1340 /**
1341 * Pending suite.
1342 */
1343 context.suite.skip = function(title, fn) {
1344 return common.suite.skip({
1345 title: title,
1346 file: file,
1347 fn: fn
1348 });
1349 };
1350
1351 /**
1352 * Exclusive test-case.
1353 */
1354 context.suite.only = function(title, fn) {
1355 return common.suite.only({
1356 title: title,
1357 file: file,
1358 fn: fn
1359 });
1360 };
1361
1362 /**
1363 * Describe a specification or test-case with the given `title` and
1364 * callback `fn` acting as a thunk.
1365 */
1366 context.test = function(title, fn) {
1367 var suite = suites[0];
1368 if (suite.isPending()) {
1369 fn = null;
1370 }
1371 var test = new Test(title, fn);
1372 test.file = file;
1373 suite.addTest(test);
1374 return test;
1375 };
1376
1377 /**
1378 * Exclusive test-case.
1379 */
1380
1381 context.test.only = function(title, fn) {
1382 return common.test.only(mocha, context.test(title, fn));
1383 };
1384
1385 context.test.skip = common.test.skip;
1386 context.test.retries = common.test.retries;
1387 });
1388};
1389
1390module.exports.description =
1391 'traditional "suite"/"test" instead of BDD\'s "describe"/"it"';
1392
1393},{"../suite":36,"../test":37,"./common":9}],14:[function(require,module,exports){
1394(function (process,global){
1395'use strict';
1396
1397/*!
1398 * mocha
1399 * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
1400 * MIT Licensed
1401 */
1402
1403var escapeRe = require('escape-string-regexp');
1404var path = require('path');
1405var builtinReporters = require('./reporters');
1406var growl = require('./growl');
1407var utils = require('./utils');
1408var mocharc = require('./mocharc.json');
1409var errors = require('./errors');
1410var Suite = require('./suite');
1411var createStatsCollector = require('./stats-collector');
1412var createInvalidReporterError = errors.createInvalidReporterError;
1413var createInvalidInterfaceError = errors.createInvalidInterfaceError;
1414var EVENT_FILE_PRE_REQUIRE = Suite.constants.EVENT_FILE_PRE_REQUIRE;
1415var EVENT_FILE_POST_REQUIRE = Suite.constants.EVENT_FILE_POST_REQUIRE;
1416var EVENT_FILE_REQUIRE = Suite.constants.EVENT_FILE_REQUIRE;
1417var sQuote = utils.sQuote;
1418
1419exports = module.exports = Mocha;
1420
1421/**
1422 * To require local UIs and reporters when running in node.
1423 */
1424
1425if (!process.browser) {
1426 var cwd = process.cwd();
1427 module.paths.push(cwd, path.join(cwd, 'node_modules'));
1428}
1429
1430/**
1431 * Expose internals.
1432 */
1433
1434/**
1435 * @public
1436 * @class utils
1437 * @memberof Mocha
1438 */
1439exports.utils = utils;
1440exports.interfaces = require('./interfaces');
1441/**
1442 * @public
1443 * @memberof Mocha
1444 */
1445exports.reporters = builtinReporters;
1446exports.Runnable = require('./runnable');
1447exports.Context = require('./context');
1448/**
1449 *
1450 * @memberof Mocha
1451 */
1452exports.Runner = require('./runner');
1453exports.Suite = Suite;
1454exports.Hook = require('./hook');
1455exports.Test = require('./test');
1456
1457/**
1458 * Constructs a new Mocha instance with `options`.
1459 *
1460 * @public
1461 * @class Mocha
1462 * @param {Object} [options] - Settings object.
1463 * @param {boolean} [options.allowUncaught] - Propagate uncaught errors?
1464 * @param {boolean} [options.asyncOnly] - Force `done` callback or promise?
1465 * @param {boolean} [options.bail] - Bail after first test failure?
1466 * @param {boolean} [options.checkLeaks] - If true, check leaks.
1467 * @param {boolean} [options.delay] - Delay root suite execution?
1468 * @param {boolean} [options.enableTimeouts] - Enable timeouts?
1469 * @param {string} [options.fgrep] - Test filter given string.
1470 * @param {boolean} [options.forbidOnly] - Tests marked `only` fail the suite?
1471 * @param {boolean} [options.forbidPending] - Pending tests fail the suite?
1472 * @param {boolean} [options.fullStackTrace] - Full stacktrace upon failure?
1473 * @param {string[]} [options.global] - Variables expected in global scope.
1474 * @param {RegExp|string} [options.grep] - Test filter given regular expression.
1475 * @param {boolean} [options.growl] - Enable desktop notifications?
1476 * @param {boolean} [options.hideDiff] - Suppress diffs from failures?
1477 * @param {boolean} [options.ignoreLeaks] - Ignore global leaks?
1478 * @param {boolean} [options.invert] - Invert test filter matches?
1479 * @param {boolean} [options.noHighlighting] - Disable syntax highlighting?
1480 * @param {string} [options.reporter] - Reporter name.
1481 * @param {Object} [options.reporterOption] - Reporter settings object.
1482 * @param {number} [options.retries] - Number of times to retry failed tests.
1483 * @param {number} [options.slow] - Slow threshold value.
1484 * @param {number|string} [options.timeout] - Timeout threshold value.
1485 * @param {string} [options.ui] - Interface name.
1486 * @param {boolean} [options.color] - Color TTY output from reporter?
1487 * @param {boolean} [options.useInlineDiffs] - Use inline diffs?
1488 */
1489function Mocha(options) {
1490 options = utils.assign({}, mocharc, options || {});
1491 this.files = [];
1492 this.options = options;
1493 // root suite
1494 this.suite = new exports.Suite('', new exports.Context(), true);
1495
1496 if ('useColors' in options) {
1497 utils.deprecate(
1498 'useColors is DEPRECATED and will be removed from a future version of Mocha. Instead, use the "color" option'
1499 );
1500 options.color = 'color' in options ? options.color : options.useColors;
1501 }
1502
1503 this.grep(options.grep)
1504 .fgrep(options.fgrep)
1505 .ui(options.ui)
1506 .bail(options.bail)
1507 .reporter(options.reporter, options.reporterOptions)
1508 .useColors(options.color)
1509 .slow(options.slow)
1510 .useInlineDiffs(options.inlineDiffs)
1511 .globals(options.globals);
1512
1513 if ('enableTimeouts' in options) {
1514 utils.deprecate(
1515 'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
1516 );
1517 }
1518 this.timeout(
1519 options.enableTimeouts === false || options.timeout === false
1520 ? 0
1521 : options.timeout
1522 );
1523
1524 if ('retries' in options) {
1525 this.retries(options.retries);
1526 }
1527
1528 if ('diff' in options) {
1529 this.hideDiff(!options.diff);
1530 }
1531
1532 [
1533 'allowUncaught',
1534 'asyncOnly',
1535 'checkLeaks',
1536 'delay',
1537 'forbidOnly',
1538 'forbidPending',
1539 'fullTrace',
1540 'growl',
1541 'invert'
1542 ].forEach(function(opt) {
1543 if (options[opt]) {
1544 this[opt]();
1545 }
1546 }, this);
1547}
1548
1549/**
1550 * Enables or disables bailing on the first failure.
1551 *
1552 * @public
1553 * @see {@link https://mochajs.org/#-b---bail|CLI option}
1554 * @param {boolean} [bail=true] - Whether to bail on first error.
1555 * @returns {Mocha} this
1556 * @chainable
1557 */
1558Mocha.prototype.bail = function(bail) {
1559 if (!arguments.length) {
1560 bail = true;
1561 }
1562 this.suite.bail(bail);
1563 return this;
1564};
1565
1566/**
1567 * @summary
1568 * Adds `file` to be loaded for execution.
1569 *
1570 * @description
1571 * Useful for generic setup code that must be included within test suite.
1572 *
1573 * @public
1574 * @see {@link https://mochajs.org/#--file-file|CLI option}
1575 * @param {string} file - Pathname of file to be loaded.
1576 * @returns {Mocha} this
1577 * @chainable
1578 */
1579Mocha.prototype.addFile = function(file) {
1580 this.files.push(file);
1581 return this;
1582};
1583
1584/**
1585 * Sets reporter to `reporter`, defaults to "spec".
1586 *
1587 * @public
1588 * @see {@link https://mochajs.org/#-r---reporter-name|CLI option}
1589 * @see {@link https://mochajs.org/#reporters|Reporters}
1590 * @param {String|Function} reporter - Reporter name or constructor.
1591 * @param {Object} [reporterOptions] - Options used to configure the reporter.
1592 * @returns {Mocha} this
1593 * @chainable
1594 * @throws {Error} if requested reporter cannot be loaded
1595 * @example
1596 *
1597 * // Use XUnit reporter and direct its output to file
1598 * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' });
1599 */
1600Mocha.prototype.reporter = function(reporter, reporterOptions) {
1601 if (typeof reporter === 'function') {
1602 this._reporter = reporter;
1603 } else {
1604 reporter = reporter || 'spec';
1605 var _reporter;
1606 // Try to load a built-in reporter.
1607 if (builtinReporters[reporter]) {
1608 _reporter = builtinReporters[reporter];
1609 }
1610 // Try to load reporters from process.cwd() and node_modules
1611 if (!_reporter) {
1612 try {
1613 _reporter = require(reporter);
1614 } catch (err) {
1615 if (
1616 err.code !== 'MODULE_NOT_FOUND' ||
1617 err.message.indexOf('Cannot find module') !== -1
1618 ) {
1619 // Try to load reporters from a path (absolute or relative)
1620 try {
1621 _reporter = require(path.resolve(process.cwd(), reporter));
1622 } catch (_err) {
1623 _err.code !== 'MODULE_NOT_FOUND' ||
1624 _err.message.indexOf('Cannot find module') !== -1
1625 ? console.warn(sQuote(reporter) + ' reporter not found')
1626 : console.warn(
1627 sQuote(reporter) +
1628 ' reporter blew up with error:\n' +
1629 err.stack
1630 );
1631 }
1632 } else {
1633 console.warn(
1634 sQuote(reporter) + ' reporter blew up with error:\n' + err.stack
1635 );
1636 }
1637 }
1638 }
1639 if (!_reporter) {
1640 throw createInvalidReporterError(
1641 'invalid reporter ' + sQuote(reporter),
1642 reporter
1643 );
1644 }
1645 this._reporter = _reporter;
1646 }
1647 this.options.reporterOptions = reporterOptions;
1648 return this;
1649};
1650
1651/**
1652 * Sets test UI `name`, defaults to "bdd".
1653 *
1654 * @public
1655 * @see {@link https://mochajs.org/#-u---ui-name|CLI option}
1656 * @see {@link https://mochajs.org/#interfaces|Interface DSLs}
1657 * @param {string|Function} [ui=bdd] - Interface name or class.
1658 * @returns {Mocha} this
1659 * @chainable
1660 * @throws {Error} if requested interface cannot be loaded
1661 */
1662Mocha.prototype.ui = function(ui) {
1663 var bindInterface;
1664 if (typeof ui === 'function') {
1665 bindInterface = ui;
1666 } else {
1667 ui = ui || 'bdd';
1668 bindInterface = exports.interfaces[ui];
1669 if (!bindInterface) {
1670 try {
1671 bindInterface = require(ui);
1672 } catch (err) {
1673 throw createInvalidInterfaceError(
1674 'invalid interface ' + sQuote(ui),
1675 ui
1676 );
1677 }
1678 }
1679 }
1680 bindInterface(this.suite);
1681
1682 this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) {
1683 exports.afterEach = context.afterEach || context.teardown;
1684 exports.after = context.after || context.suiteTeardown;
1685 exports.beforeEach = context.beforeEach || context.setup;
1686 exports.before = context.before || context.suiteSetup;
1687 exports.describe = context.describe || context.suite;
1688 exports.it = context.it || context.test;
1689 exports.xit = context.xit || (context.test && context.test.skip);
1690 exports.setup = context.setup || context.beforeEach;
1691 exports.suiteSetup = context.suiteSetup || context.before;
1692 exports.suiteTeardown = context.suiteTeardown || context.after;
1693 exports.suite = context.suite || context.describe;
1694 exports.teardown = context.teardown || context.afterEach;
1695 exports.test = context.test || context.it;
1696 exports.run = context.run;
1697 });
1698
1699 return this;
1700};
1701
1702/**
1703 * Loads `files` prior to execution.
1704 *
1705 * @description
1706 * The implementation relies on Node's `require` to execute
1707 * the test interface functions and will be subject to its cache.
1708 *
1709 * @private
1710 * @see {@link Mocha#addFile}
1711 * @see {@link Mocha#run}
1712 * @see {@link Mocha#unloadFiles}
1713 * @param {Function} [fn] - Callback invoked upon completion.
1714 */
1715Mocha.prototype.loadFiles = function(fn) {
1716 var self = this;
1717 var suite = this.suite;
1718 this.files.forEach(function(file) {
1719 file = path.resolve(file);
1720 suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
1721 suite.emit(EVENT_FILE_REQUIRE, require(file), file, self);
1722 suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
1723 });
1724 fn && fn();
1725};
1726
1727/**
1728 * Removes a previously loaded file from Node's `require` cache.
1729 *
1730 * @private
1731 * @static
1732 * @see {@link Mocha#unloadFiles}
1733 * @param {string} file - Pathname of file to be unloaded.
1734 */
1735Mocha.unloadFile = function(file) {
1736 delete require.cache[require.resolve(file)];
1737};
1738
1739/**
1740 * Unloads `files` from Node's `require` cache.
1741 *
1742 * @description
1743 * This allows files to be "freshly" reloaded, providing the ability
1744 * to reuse a Mocha instance programmatically.
1745 *
1746 * <strong>Intended for consumers &mdash; not used internally</strong>
1747 *
1748 * @public
1749 * @see {@link Mocha.unloadFile}
1750 * @see {@link Mocha#loadFiles}
1751 * @see {@link Mocha#run}
1752 * @returns {Mocha} this
1753 * @chainable
1754 */
1755Mocha.prototype.unloadFiles = function() {
1756 this.files.forEach(Mocha.unloadFile);
1757 return this;
1758};
1759
1760/**
1761 * Sets `grep` filter after escaping RegExp special characters.
1762 *
1763 * @public
1764 * @see {@link Mocha#grep}
1765 * @param {string} str - Value to be converted to a regexp.
1766 * @returns {Mocha} this
1767 * @chainable
1768 * @example
1769 *
1770 * // Select tests whose full title begins with `"foo"` followed by a period
1771 * mocha.fgrep('foo.');
1772 */
1773Mocha.prototype.fgrep = function(str) {
1774 if (!str) {
1775 return this;
1776 }
1777 return this.grep(new RegExp(escapeRe(str)));
1778};
1779
1780/**
1781 * @summary
1782 * Sets `grep` filter used to select specific tests for execution.
1783 *
1784 * @description
1785 * If `re` is a regexp-like string, it will be converted to regexp.
1786 * The regexp is tested against the full title of each test (i.e., the
1787 * name of the test preceded by titles of each its ancestral suites).
1788 * As such, using an <em>exact-match</em> fixed pattern against the
1789 * test name itself will not yield any matches.
1790 * <br>
1791 * <strong>Previous filter value will be overwritten on each call!</strong>
1792 *
1793 * @public
1794 * @see {@link https://mochajs.org/#-g---grep-pattern|CLI option}
1795 * @see {@link Mocha#fgrep}
1796 * @see {@link Mocha#invert}
1797 * @param {RegExp|String} re - Regular expression used to select tests.
1798 * @return {Mocha} this
1799 * @chainable
1800 * @example
1801 *
1802 * // Select tests whose full title contains `"match"`, ignoring case
1803 * mocha.grep(/match/i);
1804 * @example
1805 *
1806 * // Same as above but with regexp-like string argument
1807 * mocha.grep('/match/i');
1808 * @example
1809 *
1810 * // ## Anti-example
1811 * // Given embedded test `it('only-this-test')`...
1812 * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this!
1813 */
1814Mocha.prototype.grep = function(re) {
1815 if (utils.isString(re)) {
1816 // extract args if it's regex-like, i.e: [string, pattern, flag]
1817 var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
1818 this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
1819 } else {
1820 this.options.grep = re;
1821 }
1822 return this;
1823};
1824
1825/**
1826 * Inverts `grep` matches.
1827 *
1828 * @public
1829 * @see {@link Mocha#grep}
1830 * @return {Mocha} this
1831 * @chainable
1832 * @example
1833 *
1834 * // Select tests whose full title does *not* contain `"match"`, ignoring case
1835 * mocha.grep(/match/i).invert();
1836 */
1837Mocha.prototype.invert = function() {
1838 this.options.invert = true;
1839 return this;
1840};
1841
1842/**
1843 * Enables or disables ignoring global leaks.
1844 *
1845 * @public
1846 * @see {@link Mocha#checkLeaks}
1847 * @param {boolean} ignoreLeaks - Whether to ignore global leaks.
1848 * @return {Mocha} this
1849 * @chainable
1850 * @example
1851 *
1852 * // Ignore global leaks
1853 * mocha.ignoreLeaks(true);
1854 */
1855Mocha.prototype.ignoreLeaks = function(ignoreLeaks) {
1856 this.options.ignoreLeaks = Boolean(ignoreLeaks);
1857 return this;
1858};
1859
1860/**
1861 * Enables checking for global variables leaked while running tests.
1862 *
1863 * @public
1864 * @see {@link https://mochajs.org/#--check-leaks|CLI option}
1865 * @see {@link Mocha#ignoreLeaks}
1866 * @return {Mocha} this
1867 * @chainable
1868 */
1869Mocha.prototype.checkLeaks = function() {
1870 this.options.ignoreLeaks = false;
1871 return this;
1872};
1873
1874/**
1875 * Displays full stack trace upon test failure.
1876 *
1877 * @public
1878 * @return {Mocha} this
1879 * @chainable
1880 */
1881Mocha.prototype.fullTrace = function() {
1882 this.options.fullStackTrace = true;
1883 return this;
1884};
1885
1886/**
1887 * Enables desktop notification support if prerequisite software installed.
1888 *
1889 * @public
1890 * @see {@link Mocha#isGrowlCapable}
1891 * @see {@link Mocha#_growl}
1892 * @return {Mocha} this
1893 * @chainable
1894 */
1895Mocha.prototype.growl = function() {
1896 this.options.growl = this.isGrowlCapable();
1897 if (!this.options.growl) {
1898 var detail = process.browser
1899 ? 'notification support not available in this browser...'
1900 : 'notification support prerequisites not installed...';
1901 console.error(detail + ' cannot enable!');
1902 }
1903 return this;
1904};
1905
1906/**
1907 * @summary
1908 * Determines if Growl support seems likely.
1909 *
1910 * @description
1911 * <strong>Not available when run in browser.</strong>
1912 *
1913 * @private
1914 * @see {@link Growl#isCapable}
1915 * @see {@link Mocha#growl}
1916 * @return {boolean} whether Growl support can be expected
1917 */
1918Mocha.prototype.isGrowlCapable = growl.isCapable;
1919
1920/**
1921 * Implements desktop notifications using a pseudo-reporter.
1922 *
1923 * @private
1924 * @see {@link Mocha#growl}
1925 * @see {@link Growl#notify}
1926 * @param {Runner} runner - Runner instance.
1927 */
1928Mocha.prototype._growl = growl.notify;
1929
1930/**
1931 * Specifies whitelist of variable names to be expected in global scope.
1932 *
1933 * @public
1934 * @see {@link https://mochajs.org/#--globals-names|CLI option}
1935 * @see {@link Mocha#checkLeaks}
1936 * @param {String[]|String} globals - Accepted global variable name(s).
1937 * @return {Mocha} this
1938 * @chainable
1939 * @example
1940 *
1941 * // Specify variables to be expected in global scope
1942 * mocha.globals(['jQuery', 'MyLib']);
1943 */
1944Mocha.prototype.globals = function(globals) {
1945 this.options.globals = (this.options.globals || [])
1946 .concat(globals)
1947 .filter(Boolean);
1948 return this;
1949};
1950
1951/**
1952 * Enables or disables TTY color output by screen-oriented reporters.
1953 *
1954 * @public
1955 * @param {boolean} colors - Whether to enable color output.
1956 * @return {Mocha} this
1957 * @chainable
1958 */
1959Mocha.prototype.useColors = function(colors) {
1960 if (colors !== undefined) {
1961 this.options.useColors = colors;
1962 }
1963 return this;
1964};
1965
1966/**
1967 * Determines if reporter should use inline diffs (rather than +/-)
1968 * in test failure output.
1969 *
1970 * @public
1971 * @param {boolean} inlineDiffs - Whether to use inline diffs.
1972 * @return {Mocha} this
1973 * @chainable
1974 */
1975Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
1976 this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
1977 return this;
1978};
1979
1980/**
1981 * Determines if reporter should include diffs in test failure output.
1982 *
1983 * @public
1984 * @param {boolean} hideDiff - Whether to hide diffs.
1985 * @return {Mocha} this
1986 * @chainable
1987 */
1988Mocha.prototype.hideDiff = function(hideDiff) {
1989 this.options.hideDiff = hideDiff !== undefined && hideDiff;
1990 return this;
1991};
1992
1993/**
1994 * @summary
1995 * Sets timeout threshold value.
1996 *
1997 * @description
1998 * A string argument can use shorthand (such as "2s") and will be converted.
1999 * If the value is `0`, timeouts will be disabled.
2000 *
2001 * @public
2002 * @see {@link https://mochajs.org/#-t---timeout-ms|CLI option}
2003 * @see {@link https://mochajs.org/#--no-timeouts|CLI option}
2004 * @see {@link https://mochajs.org/#timeouts|Timeouts}
2005 * @see {@link Mocha#enableTimeouts}
2006 * @param {number|string} msecs - Timeout threshold value.
2007 * @return {Mocha} this
2008 * @chainable
2009 * @example
2010 *
2011 * // Sets timeout to one second
2012 * mocha.timeout(1000);
2013 * @example
2014 *
2015 * // Same as above but using string argument
2016 * mocha.timeout('1s');
2017 */
2018Mocha.prototype.timeout = function(msecs) {
2019 this.suite.timeout(msecs);
2020 return this;
2021};
2022
2023/**
2024 * Sets the number of times to retry failed tests.
2025 *
2026 * @public
2027 * @see {@link https://mochajs.org/#retry-tests|Retry Tests}
2028 * @param {number} retry - Number of times to retry failed tests.
2029 * @return {Mocha} this
2030 * @chainable
2031 * @example
2032 *
2033 * // Allow any failed test to retry one more time
2034 * mocha.retries(1);
2035 */
2036Mocha.prototype.retries = function(n) {
2037 this.suite.retries(n);
2038 return this;
2039};
2040
2041/**
2042 * Sets slowness threshold value.
2043 *
2044 * @public
2045 * @see {@link https://mochajs.org/#-s---slow-ms|CLI option}
2046 * @param {number} msecs - Slowness threshold value.
2047 * @return {Mocha} this
2048 * @chainable
2049 * @example
2050 *
2051 * // Sets "slow" threshold to half a second
2052 * mocha.slow(500);
2053 * @example
2054 *
2055 * // Same as above but using string argument
2056 * mocha.slow('0.5s');
2057 */
2058Mocha.prototype.slow = function(msecs) {
2059 this.suite.slow(msecs);
2060 return this;
2061};
2062
2063/**
2064 * Enables or disables timeouts.
2065 *
2066 * @public
2067 * @see {@link https://mochajs.org/#-t---timeout-ms|CLI option}
2068 * @see {@link https://mochajs.org/#--no-timeouts|CLI option}
2069 * @param {boolean} enableTimeouts - Whether to enable timeouts.
2070 * @return {Mocha} this
2071 * @chainable
2072 */
2073Mocha.prototype.enableTimeouts = function(enableTimeouts) {
2074 this.suite.enableTimeouts(
2075 arguments.length && enableTimeouts !== undefined ? enableTimeouts : true
2076 );
2077 return this;
2078};
2079
2080/**
2081 * Forces all tests to either accept a `done` callback or return a promise.
2082 *
2083 * @public
2084 * @return {Mocha} this
2085 * @chainable
2086 */
2087Mocha.prototype.asyncOnly = function() {
2088 this.options.asyncOnly = true;
2089 return this;
2090};
2091
2092/**
2093 * Disables syntax highlighting (in browser).
2094 *
2095 * @public
2096 * @return {Mocha} this
2097 * @chainable
2098 */
2099Mocha.prototype.noHighlighting = function() {
2100 this.options.noHighlighting = true;
2101 return this;
2102};
2103
2104/**
2105 * Enables uncaught errors to propagate (in browser).
2106 *
2107 * @public
2108 * @return {Mocha} this
2109 * @chainable
2110 */
2111Mocha.prototype.allowUncaught = function() {
2112 this.options.allowUncaught = true;
2113 return this;
2114};
2115
2116/**
2117 * @summary
2118 * Delays root suite execution.
2119 *
2120 * @description
2121 * Used to perform asynch operations before any suites are run.
2122 *
2123 * @public
2124 * @see {@link https://mochajs.org/#delayed-root-suite|delayed root suite}
2125 * @returns {Mocha} this
2126 * @chainable
2127 */
2128Mocha.prototype.delay = function delay() {
2129 this.options.delay = true;
2130 return this;
2131};
2132
2133/**
2134 * Causes tests marked `only` to fail the suite.
2135 *
2136 * @public
2137 * @returns {Mocha} this
2138 * @chainable
2139 */
2140Mocha.prototype.forbidOnly = function() {
2141 this.options.forbidOnly = true;
2142 return this;
2143};
2144
2145/**
2146 * Causes pending tests and tests marked `skip` to fail the suite.
2147 *
2148 * @public
2149 * @returns {Mocha} this
2150 * @chainable
2151 */
2152Mocha.prototype.forbidPending = function() {
2153 this.options.forbidPending = true;
2154 return this;
2155};
2156
2157/**
2158 * Mocha version as specified by "package.json".
2159 *
2160 * @name Mocha#version
2161 * @type string
2162 * @readonly
2163 */
2164Object.defineProperty(Mocha.prototype, 'version', {
2165 value: require('../package.json').version,
2166 configurable: false,
2167 enumerable: true,
2168 writable: false
2169});
2170
2171/**
2172 * Callback to be invoked when test execution is complete.
2173 *
2174 * @callback DoneCB
2175 * @param {number} failures - Number of failures that occurred.
2176 */
2177
2178/**
2179 * Runs root suite and invokes `fn()` when complete.
2180 *
2181 * @description
2182 * To run tests multiple times (or to run tests in files that are
2183 * already in the `require` cache), make sure to clear them from
2184 * the cache first!
2185 *
2186 * @public
2187 * @see {@link Mocha#loadFiles}
2188 * @see {@link Mocha#unloadFiles}
2189 * @see {@link Runner#run}
2190 * @param {DoneCB} [fn] - Callback invoked when test execution completed.
2191 * @return {Runner} runner instance
2192 */
2193Mocha.prototype.run = function(fn) {
2194 if (this.files.length) {
2195 this.loadFiles();
2196 }
2197 var suite = this.suite;
2198 var options = this.options;
2199 options.files = this.files;
2200 var runner = new exports.Runner(suite, options.delay);
2201 createStatsCollector(runner);
2202 var reporter = new this._reporter(runner, options);
2203 runner.ignoreLeaks = options.ignoreLeaks !== false;
2204 runner.fullStackTrace = options.fullStackTrace;
2205 runner.asyncOnly = options.asyncOnly;
2206 runner.allowUncaught = options.allowUncaught;
2207 runner.forbidOnly = options.forbidOnly;
2208 runner.forbidPending = options.forbidPending;
2209 if (options.grep) {
2210 runner.grep(options.grep, options.invert);
2211 }
2212 if (options.globals) {
2213 runner.globals(options.globals);
2214 }
2215 if (options.growl) {
2216 this._growl(runner);
2217 }
2218 if (options.useColors !== undefined) {
2219 exports.reporters.Base.useColors = options.useColors;
2220 }
2221 exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
2222 exports.reporters.Base.hideDiff = options.hideDiff;
2223
2224 function done(failures) {
2225 fn = fn || utils.noop;
2226 if (reporter.done) {
2227 reporter.done(failures, fn);
2228 } else {
2229 fn(failures);
2230 }
2231 }
2232
2233 return runner.run(done);
2234};
2235
2236}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2237},{"../package.json":89,"./context":5,"./errors":6,"./growl":2,"./hook":7,"./interfaces":11,"./mocharc.json":15,"./reporters":21,"./runnable":33,"./runner":34,"./stats-collector":35,"./suite":36,"./test":37,"./utils":38,"_process":68,"escape-string-regexp":49,"path":42}],15:[function(require,module,exports){
2238module.exports={
2239 "diff": true,
2240 "extension": ["js"],
2241 "opts": "./test/mocha.opts",
2242 "package": "./package.json",
2243 "reporter": "spec",
2244 "slow": 75,
2245 "timeout": 2000,
2246 "ui": "bdd"
2247}
2248
2249},{}],16:[function(require,module,exports){
2250'use strict';
2251
2252module.exports = Pending;
2253
2254/**
2255 * Initialize a new `Pending` error with the given message.
2256 *
2257 * @param {string} message
2258 */
2259function Pending(message) {
2260 this.message = message;
2261}
2262
2263},{}],17:[function(require,module,exports){
2264(function (process){
2265'use strict';
2266/**
2267 * @module Base
2268 */
2269/**
2270 * Module dependencies.
2271 */
2272
2273var tty = require('tty');
2274var diff = require('diff');
2275var milliseconds = require('ms');
2276var utils = require('../utils');
2277var supportsColor = process.browser ? null : require('supports-color');
2278var constants = require('../runner').constants;
2279var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2280var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2281
2282/**
2283 * Expose `Base`.
2284 */
2285
2286exports = module.exports = Base;
2287
2288/**
2289 * Check if both stdio streams are associated with a tty.
2290 */
2291
2292var isatty = tty.isatty(1) && tty.isatty(2);
2293
2294/**
2295 * Enable coloring by default, except in the browser interface.
2296 */
2297
2298exports.useColors =
2299 !process.browser &&
2300 (supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
2301
2302/**
2303 * Inline diffs instead of +/-
2304 */
2305
2306exports.inlineDiffs = false;
2307
2308/**
2309 * Default color map.
2310 */
2311
2312exports.colors = {
2313 pass: 90,
2314 fail: 31,
2315 'bright pass': 92,
2316 'bright fail': 91,
2317 'bright yellow': 93,
2318 pending: 36,
2319 suite: 0,
2320 'error title': 0,
2321 'error message': 31,
2322 'error stack': 90,
2323 checkmark: 32,
2324 fast: 90,
2325 medium: 33,
2326 slow: 31,
2327 green: 32,
2328 light: 90,
2329 'diff gutter': 90,
2330 'diff added': 32,
2331 'diff removed': 31
2332};
2333
2334/**
2335 * Default symbol map.
2336 */
2337
2338exports.symbols = {
2339 ok: '✓',
2340 err: '✖',
2341 dot: '․',
2342 comma: ',',
2343 bang: '!'
2344};
2345
2346// With node.js on Windows: use symbols available in terminal default fonts
2347if (process.platform === 'win32') {
2348 exports.symbols.ok = '\u221A';
2349 exports.symbols.err = '\u00D7';
2350 exports.symbols.dot = '.';
2351}
2352
2353/**
2354 * Color `str` with the given `type`,
2355 * allowing colors to be disabled,
2356 * as well as user-defined color
2357 * schemes.
2358 *
2359 * @param {string} type
2360 * @param {string} str
2361 * @return {string}
2362 * @private
2363 */
2364var color = (exports.color = function(type, str) {
2365 if (!exports.useColors) {
2366 return String(str);
2367 }
2368 return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
2369});
2370
2371/**
2372 * Expose term window size, with some defaults for when stderr is not a tty.
2373 */
2374
2375exports.window = {
2376 width: 75
2377};
2378
2379if (isatty) {
2380 exports.window.width = process.stdout.getWindowSize
2381 ? process.stdout.getWindowSize(1)[0]
2382 : tty.getWindowSize()[1];
2383}
2384
2385/**
2386 * Expose some basic cursor interactions that are common among reporters.
2387 */
2388
2389exports.cursor = {
2390 hide: function() {
2391 isatty && process.stdout.write('\u001b[?25l');
2392 },
2393
2394 show: function() {
2395 isatty && process.stdout.write('\u001b[?25h');
2396 },
2397
2398 deleteLine: function() {
2399 isatty && process.stdout.write('\u001b[2K');
2400 },
2401
2402 beginningOfLine: function() {
2403 isatty && process.stdout.write('\u001b[0G');
2404 },
2405
2406 CR: function() {
2407 if (isatty) {
2408 exports.cursor.deleteLine();
2409 exports.cursor.beginningOfLine();
2410 } else {
2411 process.stdout.write('\r');
2412 }
2413 }
2414};
2415
2416function showDiff(err) {
2417 return (
2418 err &&
2419 err.showDiff !== false &&
2420 sameType(err.actual, err.expected) &&
2421 err.expected !== undefined
2422 );
2423}
2424
2425function stringifyDiffObjs(err) {
2426 if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
2427 err.actual = utils.stringify(err.actual);
2428 err.expected = utils.stringify(err.expected);
2429 }
2430}
2431
2432/**
2433 * Returns a diff between 2 strings with coloured ANSI output.
2434 *
2435 * The diff will be either inline or unified dependant on the value
2436 * of `Base.inlineDiff`.
2437 *
2438 * @param {string} actual
2439 * @param {string} expected
2440 * @return {string} Diff
2441 */
2442var generateDiff = (exports.generateDiff = function(actual, expected) {
2443 return exports.inlineDiffs
2444 ? inlineDiff(actual, expected)
2445 : unifiedDiff(actual, expected);
2446});
2447
2448/**
2449 * Output the given `failures` as a list.
2450 *
2451 * @public
2452 * @memberof Mocha.reporters.Base
2453 * @variation 1
2454 * @param {Array} failures
2455 */
2456
2457exports.list = function(failures) {
2458 console.log();
2459 failures.forEach(function(test, i) {
2460 // format
2461 var fmt =
2462 color('error title', ' %s) %s:\n') +
2463 color('error message', ' %s') +
2464 color('error stack', '\n%s\n');
2465
2466 // msg
2467 var msg;
2468 var err = test.err;
2469 var message;
2470 if (err.message && typeof err.message.toString === 'function') {
2471 message = err.message + '';
2472 } else if (typeof err.inspect === 'function') {
2473 message = err.inspect() + '';
2474 } else {
2475 message = '';
2476 }
2477 var stack = err.stack || message;
2478 var index = message ? stack.indexOf(message) : -1;
2479
2480 if (index === -1) {
2481 msg = message;
2482 } else {
2483 index += message.length;
2484 msg = stack.slice(0, index);
2485 // remove msg from stack
2486 stack = stack.slice(index + 1);
2487 }
2488
2489 // uncaught
2490 if (err.uncaught) {
2491 msg = 'Uncaught ' + msg;
2492 }
2493 // explicitly show diff
2494 if (!exports.hideDiff && showDiff(err)) {
2495 stringifyDiffObjs(err);
2496 fmt =
2497 color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
2498 var match = message.match(/^([^:]+): expected/);
2499 msg = '\n ' + color('error message', match ? match[1] : msg);
2500
2501 msg += generateDiff(err.actual, err.expected);
2502 }
2503
2504 // indent stack trace
2505 stack = stack.replace(/^/gm, ' ');
2506
2507 // indented test title
2508 var testTitle = '';
2509 test.titlePath().forEach(function(str, index) {
2510 if (index !== 0) {
2511 testTitle += '\n ';
2512 }
2513 for (var i = 0; i < index; i++) {
2514 testTitle += ' ';
2515 }
2516 testTitle += str;
2517 });
2518
2519 console.log(fmt, i + 1, testTitle, msg, stack);
2520 });
2521};
2522
2523/**
2524 * Initialize a new `Base` reporter.
2525 *
2526 * All other reporters generally
2527 * inherit from this reporter.
2528 *
2529 * @memberof Mocha.reporters
2530 * @public
2531 * @class
2532 * @param {Runner} runner
2533 */
2534
2535function Base(runner) {
2536 var failures = (this.failures = []);
2537
2538 if (!runner) {
2539 throw new TypeError('Missing runner argument');
2540 }
2541 this.stats = runner.stats; // assigned so Reporters keep a closer reference
2542 this.runner = runner;
2543
2544 runner.on(EVENT_TEST_PASS, function(test) {
2545 if (test.duration > test.slow()) {
2546 test.speed = 'slow';
2547 } else if (test.duration > test.slow() / 2) {
2548 test.speed = 'medium';
2549 } else {
2550 test.speed = 'fast';
2551 }
2552 });
2553
2554 runner.on(EVENT_TEST_FAIL, function(test, err) {
2555 if (showDiff(err)) {
2556 stringifyDiffObjs(err);
2557 }
2558 test.err = err;
2559 failures.push(test);
2560 });
2561}
2562
2563/**
2564 * Output common epilogue used by many of
2565 * the bundled reporters.
2566 *
2567 * @memberof Mocha.reporters.Base
2568 * @public
2569 */
2570Base.prototype.epilogue = function() {
2571 var stats = this.stats;
2572 var fmt;
2573
2574 console.log();
2575
2576 // passes
2577 fmt =
2578 color('bright pass', ' ') +
2579 color('green', ' %d passing') +
2580 color('light', ' (%s)');
2581
2582 console.log(fmt, stats.passes || 0, milliseconds(stats.duration));
2583
2584 // pending
2585 if (stats.pending) {
2586 fmt = color('pending', ' ') + color('pending', ' %d pending');
2587
2588 console.log(fmt, stats.pending);
2589 }
2590
2591 // failures
2592 if (stats.failures) {
2593 fmt = color('fail', ' %d failing');
2594
2595 console.log(fmt, stats.failures);
2596
2597 Base.list(this.failures);
2598 console.log();
2599 }
2600
2601 console.log();
2602};
2603
2604/**
2605 * Pad the given `str` to `len`.
2606 *
2607 * @private
2608 * @param {string} str
2609 * @param {string} len
2610 * @return {string}
2611 */
2612function pad(str, len) {
2613 str = String(str);
2614 return Array(len - str.length + 1).join(' ') + str;
2615}
2616
2617/**
2618 * Returns an inline diff between 2 strings with coloured ANSI output.
2619 *
2620 * @private
2621 * @param {String} actual
2622 * @param {String} expected
2623 * @return {string} Diff
2624 */
2625function inlineDiff(actual, expected) {
2626 var msg = errorDiff(actual, expected);
2627
2628 // linenos
2629 var lines = msg.split('\n');
2630 if (lines.length > 4) {
2631 var width = String(lines.length).length;
2632 msg = lines
2633 .map(function(str, i) {
2634 return pad(++i, width) + ' |' + ' ' + str;
2635 })
2636 .join('\n');
2637 }
2638
2639 // legend
2640 msg =
2641 '\n' +
2642 color('diff removed', 'actual') +
2643 ' ' +
2644 color('diff added', 'expected') +
2645 '\n\n' +
2646 msg +
2647 '\n';
2648
2649 // indent
2650 msg = msg.replace(/^/gm, ' ');
2651 return msg;
2652}
2653
2654/**
2655 * Returns a unified diff between two strings with coloured ANSI output.
2656 *
2657 * @private
2658 * @param {String} actual
2659 * @param {String} expected
2660 * @return {string} The diff.
2661 */
2662function unifiedDiff(actual, expected) {
2663 var indent = ' ';
2664 function cleanUp(line) {
2665 if (line[0] === '+') {
2666 return indent + colorLines('diff added', line);
2667 }
2668 if (line[0] === '-') {
2669 return indent + colorLines('diff removed', line);
2670 }
2671 if (line.match(/@@/)) {
2672 return '--';
2673 }
2674 if (line.match(/\\ No newline/)) {
2675 return null;
2676 }
2677 return indent + line;
2678 }
2679 function notBlank(line) {
2680 return typeof line !== 'undefined' && line !== null;
2681 }
2682 var msg = diff.createPatch('string', actual, expected);
2683 var lines = msg.split('\n').splice(5);
2684 return (
2685 '\n ' +
2686 colorLines('diff added', '+ expected') +
2687 ' ' +
2688 colorLines('diff removed', '- actual') +
2689 '\n\n' +
2690 lines
2691 .map(cleanUp)
2692 .filter(notBlank)
2693 .join('\n')
2694 );
2695}
2696
2697/**
2698 * Return a character diff for `err`.
2699 *
2700 * @private
2701 * @param {String} actual
2702 * @param {String} expected
2703 * @return {string} the diff
2704 */
2705function errorDiff(actual, expected) {
2706 return diff
2707 .diffWordsWithSpace(actual, expected)
2708 .map(function(str) {
2709 if (str.added) {
2710 return colorLines('diff added', str.value);
2711 }
2712 if (str.removed) {
2713 return colorLines('diff removed', str.value);
2714 }
2715 return str.value;
2716 })
2717 .join('');
2718}
2719
2720/**
2721 * Color lines for `str`, using the color `name`.
2722 *
2723 * @private
2724 * @param {string} name
2725 * @param {string} str
2726 * @return {string}
2727 */
2728function colorLines(name, str) {
2729 return str
2730 .split('\n')
2731 .map(function(str) {
2732 return color(name, str);
2733 })
2734 .join('\n');
2735}
2736
2737/**
2738 * Object#toString reference.
2739 */
2740var objToString = Object.prototype.toString;
2741
2742/**
2743 * Check that a / b have the same type.
2744 *
2745 * @private
2746 * @param {Object} a
2747 * @param {Object} b
2748 * @return {boolean}
2749 */
2750function sameType(a, b) {
2751 return objToString.call(a) === objToString.call(b);
2752}
2753
2754Base.abstract = true;
2755
2756}).call(this,require('_process'))
2757},{"../runner":34,"../utils":38,"_process":68,"diff":48,"ms":60,"supports-color":42,"tty":4}],18:[function(require,module,exports){
2758'use strict';
2759/**
2760 * @module Doc
2761 */
2762/**
2763 * Module dependencies.
2764 */
2765
2766var Base = require('./base');
2767var utils = require('../utils');
2768var constants = require('../runner').constants;
2769var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2770var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2771var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
2772var EVENT_SUITE_END = constants.EVENT_SUITE_END;
2773
2774/**
2775 * Expose `Doc`.
2776 */
2777
2778exports = module.exports = Doc;
2779
2780/**
2781 * Initialize a new `Doc` reporter.
2782 *
2783 * @class
2784 * @memberof Mocha.reporters
2785 * @extends {Base}
2786 * @public
2787 * @param {Runner} runner
2788 */
2789function Doc(runner) {
2790 Base.call(this, runner);
2791
2792 var indents = 2;
2793
2794 function indent() {
2795 return Array(indents).join(' ');
2796 }
2797
2798 runner.on(EVENT_SUITE_BEGIN, function(suite) {
2799 if (suite.root) {
2800 return;
2801 }
2802 ++indents;
2803 console.log('%s<section class="suite">', indent());
2804 ++indents;
2805 console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
2806 console.log('%s<dl>', indent());
2807 });
2808
2809 runner.on(EVENT_SUITE_END, function(suite) {
2810 if (suite.root) {
2811 return;
2812 }
2813 console.log('%s</dl>', indent());
2814 --indents;
2815 console.log('%s</section>', indent());
2816 --indents;
2817 });
2818
2819 runner.on(EVENT_TEST_PASS, function(test) {
2820 console.log('%s <dt>%s</dt>', indent(), utils.escape(test.title));
2821 var code = utils.escape(utils.clean(test.body));
2822 console.log('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
2823 });
2824
2825 runner.on(EVENT_TEST_FAIL, function(test, err) {
2826 console.log(
2827 '%s <dt class="error">%s</dt>',
2828 indent(),
2829 utils.escape(test.title)
2830 );
2831 var code = utils.escape(utils.clean(test.body));
2832 console.log(
2833 '%s <dd class="error"><pre><code>%s</code></pre></dd>',
2834 indent(),
2835 code
2836 );
2837 console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err));
2838 });
2839}
2840
2841Doc.description = 'HTML documentation';
2842
2843},{"../runner":34,"../utils":38,"./base":17}],19:[function(require,module,exports){
2844(function (process){
2845'use strict';
2846/**
2847 * @module Dot
2848 */
2849/**
2850 * Module dependencies.
2851 */
2852
2853var Base = require('./base');
2854var inherits = require('../utils').inherits;
2855var constants = require('../runner').constants;
2856var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2857var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2858var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
2859var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
2860var EVENT_RUN_END = constants.EVENT_RUN_END;
2861
2862/**
2863 * Expose `Dot`.
2864 */
2865
2866exports = module.exports = Dot;
2867
2868/**
2869 * Initialize a new `Dot` matrix test reporter.
2870 *
2871 * @class
2872 * @memberof Mocha.reporters
2873 * @extends Mocha.reporters.Base
2874 * @public
2875 * @param {Runner} runner
2876 */
2877function Dot(runner) {
2878 Base.call(this, runner);
2879
2880 var self = this;
2881 var width = (Base.window.width * 0.75) | 0;
2882 var n = -1;
2883
2884 runner.on(EVENT_RUN_BEGIN, function() {
2885 process.stdout.write('\n');
2886 });
2887
2888 runner.on(EVENT_TEST_PENDING, function() {
2889 if (++n % width === 0) {
2890 process.stdout.write('\n ');
2891 }
2892 process.stdout.write(Base.color('pending', Base.symbols.comma));
2893 });
2894
2895 runner.on(EVENT_TEST_PASS, function(test) {
2896 if (++n % width === 0) {
2897 process.stdout.write('\n ');
2898 }
2899 if (test.speed === 'slow') {
2900 process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
2901 } else {
2902 process.stdout.write(Base.color(test.speed, Base.symbols.dot));
2903 }
2904 });
2905
2906 runner.on(EVENT_TEST_FAIL, function() {
2907 if (++n % width === 0) {
2908 process.stdout.write('\n ');
2909 }
2910 process.stdout.write(Base.color('fail', Base.symbols.bang));
2911 });
2912
2913 runner.once(EVENT_RUN_END, function() {
2914 console.log();
2915 self.epilogue();
2916 });
2917}
2918
2919/**
2920 * Inherit from `Base.prototype`.
2921 */
2922inherits(Dot, Base);
2923
2924Dot.description = 'dot matrix representation';
2925
2926}).call(this,require('_process'))
2927},{"../runner":34,"../utils":38,"./base":17,"_process":68}],20:[function(require,module,exports){
2928(function (global){
2929'use strict';
2930
2931/* eslint-env browser */
2932/**
2933 * @module HTML
2934 */
2935/**
2936 * Module dependencies.
2937 */
2938
2939var Base = require('./base');
2940var utils = require('../utils');
2941var Progress = require('../browser/progress');
2942var escapeRe = require('escape-string-regexp');
2943var constants = require('../runner').constants;
2944var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2945var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2946var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
2947var EVENT_SUITE_END = constants.EVENT_SUITE_END;
2948var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
2949var escape = utils.escape;
2950
2951/**
2952 * Save timer references to avoid Sinon interfering (see GH-237).
2953 */
2954
2955var Date = global.Date;
2956
2957/**
2958 * Expose `HTML`.
2959 */
2960
2961exports = module.exports = HTML;
2962
2963/**
2964 * Stats template.
2965 */
2966
2967var statsTemplate =
2968 '<ul id="mocha-stats">' +
2969 '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
2970 '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
2971 '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
2972 '<li class="duration">duration: <em>0</em>s</li>' +
2973 '</ul>';
2974
2975var playIcon = '&#x2023;';
2976
2977/**
2978 * Initialize a new `HTML` reporter.
2979 *
2980 * @public
2981 * @class
2982 * @memberof Mocha.reporters
2983 * @extends Mocha.reporters.Base
2984 * @param {Runner} runner
2985 */
2986function HTML(runner) {
2987 Base.call(this, runner);
2988
2989 var self = this;
2990 var stats = this.stats;
2991 var stat = fragment(statsTemplate);
2992 var items = stat.getElementsByTagName('li');
2993 var passes = items[1].getElementsByTagName('em')[0];
2994 var passesLink = items[1].getElementsByTagName('a')[0];
2995 var failures = items[2].getElementsByTagName('em')[0];
2996 var failuresLink = items[2].getElementsByTagName('a')[0];
2997 var duration = items[3].getElementsByTagName('em')[0];
2998 var canvas = stat.getElementsByTagName('canvas')[0];
2999 var report = fragment('<ul id="mocha-report"></ul>');
3000 var stack = [report];
3001 var progress;
3002 var ctx;
3003 var root = document.getElementById('mocha');
3004
3005 if (canvas.getContext) {
3006 var ratio = window.devicePixelRatio || 1;
3007 canvas.style.width = canvas.width;
3008 canvas.style.height = canvas.height;
3009 canvas.width *= ratio;
3010 canvas.height *= ratio;
3011 ctx = canvas.getContext('2d');
3012 ctx.scale(ratio, ratio);
3013 progress = new Progress();
3014 }
3015
3016 if (!root) {
3017 return error('#mocha div missing, add it to your document');
3018 }
3019
3020 // pass toggle
3021 on(passesLink, 'click', function(evt) {
3022 evt.preventDefault();
3023 unhide();
3024 var name = /pass/.test(report.className) ? '' : ' pass';
3025 report.className = report.className.replace(/fail|pass/g, '') + name;
3026 if (report.className.trim()) {
3027 hideSuitesWithout('test pass');
3028 }
3029 });
3030
3031 // failure toggle
3032 on(failuresLink, 'click', function(evt) {
3033 evt.preventDefault();
3034 unhide();
3035 var name = /fail/.test(report.className) ? '' : ' fail';
3036 report.className = report.className.replace(/fail|pass/g, '') + name;
3037 if (report.className.trim()) {
3038 hideSuitesWithout('test fail');
3039 }
3040 });
3041
3042 root.appendChild(stat);
3043 root.appendChild(report);
3044
3045 if (progress) {
3046 progress.size(40);
3047 }
3048
3049 runner.on(EVENT_SUITE_BEGIN, function(suite) {
3050 if (suite.root) {
3051 return;
3052 }
3053
3054 // suite
3055 var url = self.suiteURL(suite);
3056 var el = fragment(
3057 '<li class="suite"><h1><a href="%s">%s</a></h1></li>',
3058 url,
3059 escape(suite.title)
3060 );
3061
3062 // container
3063 stack[0].appendChild(el);
3064 stack.unshift(document.createElement('ul'));
3065 el.appendChild(stack[0]);
3066 });
3067
3068 runner.on(EVENT_SUITE_END, function(suite) {
3069 if (suite.root) {
3070 updateStats();
3071 return;
3072 }
3073 stack.shift();
3074 });
3075
3076 runner.on(EVENT_TEST_PASS, function(test) {
3077 var url = self.testURL(test);
3078 var markup =
3079 '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
3080 '<a href="%s" class="replay">' +
3081 playIcon +
3082 '</a></h2></li>';
3083 var el = fragment(markup, test.speed, test.title, test.duration, url);
3084 self.addCodeToggle(el, test.body);
3085 appendToStack(el);
3086 updateStats();
3087 });
3088
3089 runner.on(EVENT_TEST_FAIL, function(test) {
3090 var el = fragment(
3091 '<li class="test fail"><h2>%e <a href="%e" class="replay">' +
3092 playIcon +
3093 '</a></h2></li>',
3094 test.title,
3095 self.testURL(test)
3096 );
3097 var stackString; // Note: Includes leading newline
3098 var message = test.err.toString();
3099
3100 // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
3101 // check for the result of the stringifying.
3102 if (message === '[object Error]') {
3103 message = test.err.message;
3104 }
3105
3106 if (test.err.stack) {
3107 var indexOfMessage = test.err.stack.indexOf(test.err.message);
3108 if (indexOfMessage === -1) {
3109 stackString = test.err.stack;
3110 } else {
3111 stackString = test.err.stack.substr(
3112 test.err.message.length + indexOfMessage
3113 );
3114 }
3115 } else if (test.err.sourceURL && test.err.line !== undefined) {
3116 // Safari doesn't give you a stack. Let's at least provide a source line.
3117 stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
3118 }
3119
3120 stackString = stackString || '';
3121
3122 if (test.err.htmlMessage && stackString) {
3123 el.appendChild(
3124 fragment(
3125 '<div class="html-error">%s\n<pre class="error">%e</pre></div>',
3126 test.err.htmlMessage,
3127 stackString
3128 )
3129 );
3130 } else if (test.err.htmlMessage) {
3131 el.appendChild(
3132 fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
3133 );
3134 } else {
3135 el.appendChild(
3136 fragment('<pre class="error">%e%e</pre>', message, stackString)
3137 );
3138 }
3139
3140 self.addCodeToggle(el, test.body);
3141 appendToStack(el);
3142 updateStats();
3143 });
3144
3145 runner.on(EVENT_TEST_PENDING, function(test) {
3146 var el = fragment(
3147 '<li class="test pass pending"><h2>%e</h2></li>',
3148 test.title
3149 );
3150 appendToStack(el);
3151 updateStats();
3152 });
3153
3154 function appendToStack(el) {
3155 // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
3156 if (stack[0]) {
3157 stack[0].appendChild(el);
3158 }
3159 }
3160
3161 function updateStats() {
3162 // TODO: add to stats
3163 var percent = ((stats.tests / runner.total) * 100) | 0;
3164 if (progress) {
3165 progress.update(percent).draw(ctx);
3166 }
3167
3168 // update stats
3169 var ms = new Date() - stats.start;
3170 text(passes, stats.passes);
3171 text(failures, stats.failures);
3172 text(duration, (ms / 1000).toFixed(2));
3173 }
3174}
3175
3176/**
3177 * Makes a URL, preserving querystring ("search") parameters.
3178 *
3179 * @param {string} s
3180 * @return {string} A new URL.
3181 */
3182function makeUrl(s) {
3183 var search = window.location.search;
3184
3185 // Remove previous grep query parameter if present
3186 if (search) {
3187 search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
3188 }
3189
3190 return (
3191 window.location.pathname +
3192 (search ? search + '&' : '?') +
3193 'grep=' +
3194 encodeURIComponent(escapeRe(s))
3195 );
3196}
3197
3198/**
3199 * Provide suite URL.
3200 *
3201 * @param {Object} [suite]
3202 */
3203HTML.prototype.suiteURL = function(suite) {
3204 return makeUrl(suite.fullTitle());
3205};
3206
3207/**
3208 * Provide test URL.
3209 *
3210 * @param {Object} [test]
3211 */
3212HTML.prototype.testURL = function(test) {
3213 return makeUrl(test.fullTitle());
3214};
3215
3216/**
3217 * Adds code toggle functionality for the provided test's list element.
3218 *
3219 * @param {HTMLLIElement} el
3220 * @param {string} contents
3221 */
3222HTML.prototype.addCodeToggle = function(el, contents) {
3223 var h2 = el.getElementsByTagName('h2')[0];
3224
3225 on(h2, 'click', function() {
3226 pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
3227 });
3228
3229 var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents));
3230 el.appendChild(pre);
3231 pre.style.display = 'none';
3232};
3233
3234/**
3235 * Display error `msg`.
3236 *
3237 * @param {string} msg
3238 */
3239function error(msg) {
3240 document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
3241}
3242
3243/**
3244 * Return a DOM fragment from `html`.
3245 *
3246 * @param {string} html
3247 */
3248function fragment(html) {
3249 var args = arguments;
3250 var div = document.createElement('div');
3251 var i = 1;
3252
3253 div.innerHTML = html.replace(/%([se])/g, function(_, type) {
3254 switch (type) {
3255 case 's':
3256 return String(args[i++]);
3257 case 'e':
3258 return escape(args[i++]);
3259 // no default
3260 }
3261 });
3262
3263 return div.firstChild;
3264}
3265
3266/**
3267 * Check for suites that do not have elements
3268 * with `classname`, and hide them.
3269 *
3270 * @param {text} classname
3271 */
3272function hideSuitesWithout(classname) {
3273 var suites = document.getElementsByClassName('suite');
3274 for (var i = 0; i < suites.length; i++) {
3275 var els = suites[i].getElementsByClassName(classname);
3276 if (!els.length) {
3277 suites[i].className += ' hidden';
3278 }
3279 }
3280}
3281
3282/**
3283 * Unhide .hidden suites.
3284 */
3285function unhide() {
3286 var els = document.getElementsByClassName('suite hidden');
3287 for (var i = 0; i < els.length; ++i) {
3288 els[i].className = els[i].className.replace('suite hidden', 'suite');
3289 }
3290}
3291
3292/**
3293 * Set an element's text contents.
3294 *
3295 * @param {HTMLElement} el
3296 * @param {string} contents
3297 */
3298function text(el, contents) {
3299 if (el.textContent) {
3300 el.textContent = contents;
3301 } else {
3302 el.innerText = contents;
3303 }
3304}
3305
3306/**
3307 * Listen on `event` with callback `fn`.
3308 */
3309function on(el, event, fn) {
3310 if (el.addEventListener) {
3311 el.addEventListener(event, fn, false);
3312 } else {
3313 el.attachEvent('on' + event, fn);
3314 }
3315}
3316
3317HTML.browserOnly = true;
3318
3319}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3320},{"../browser/progress":3,"../runner":34,"../utils":38,"./base":17,"escape-string-regexp":49}],21:[function(require,module,exports){
3321'use strict';
3322
3323// Alias exports to a their normalized format Mocha#reporter to prevent a need
3324// for dynamic (try/catch) requires, which Browserify doesn't handle.
3325exports.Base = exports.base = require('./base');
3326exports.Dot = exports.dot = require('./dot');
3327exports.Doc = exports.doc = require('./doc');
3328exports.TAP = exports.tap = require('./tap');
3329exports.JSON = exports.json = require('./json');
3330exports.HTML = exports.html = require('./html');
3331exports.List = exports.list = require('./list');
3332exports.Min = exports.min = require('./min');
3333exports.Spec = exports.spec = require('./spec');
3334exports.Nyan = exports.nyan = require('./nyan');
3335exports.XUnit = exports.xunit = require('./xunit');
3336exports.Markdown = exports.markdown = require('./markdown');
3337exports.Progress = exports.progress = require('./progress');
3338exports.Landing = exports.landing = require('./landing');
3339exports.JSONStream = exports['json-stream'] = require('./json-stream');
3340
3341},{"./base":17,"./doc":18,"./dot":19,"./html":20,"./json":23,"./json-stream":22,"./landing":24,"./list":25,"./markdown":26,"./min":27,"./nyan":28,"./progress":29,"./spec":30,"./tap":31,"./xunit":32}],22:[function(require,module,exports){
3342(function (process){
3343'use strict';
3344/**
3345 * @module JSONStream
3346 */
3347/**
3348 * Module dependencies.
3349 */
3350
3351var Base = require('./base');
3352var constants = require('../runner').constants;
3353var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3354var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3355var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3356var EVENT_RUN_END = constants.EVENT_RUN_END;
3357
3358/**
3359 * Expose `JSONStream`.
3360 */
3361
3362exports = module.exports = JSONStream;
3363
3364/**
3365 * Constructs a new `JSONStream` reporter instance.
3366 *
3367 * @public
3368 * @class
3369 * @extends Mocha.reporters.Base
3370 * @memberof Mocha.reporters
3371 * @param {Runner} runner - Instance triggers reporter actions.
3372 */
3373function JSONStream(runner) {
3374 Base.call(this, runner);
3375
3376 var self = this;
3377 var total = runner.total;
3378
3379 runner.once(EVENT_RUN_BEGIN, function() {
3380 writeEvent(['start', {total: total}]);
3381 });
3382
3383 runner.on(EVENT_TEST_PASS, function(test) {
3384 writeEvent(['pass', clean(test)]);
3385 });
3386
3387 runner.on(EVENT_TEST_FAIL, function(test, err) {
3388 test = clean(test);
3389 test.err = err.message;
3390 test.stack = err.stack || null;
3391 writeEvent(['fail', test]);
3392 });
3393
3394 runner.once(EVENT_RUN_END, function() {
3395 writeEvent(['end', self.stats]);
3396 });
3397}
3398
3399/**
3400 * Mocha event to be written to the output stream.
3401 * @typedef {Array} JSONStream~MochaEvent
3402 */
3403
3404/**
3405 * Writes Mocha event to reporter output stream.
3406 *
3407 * @private
3408 * @param {JSONStream~MochaEvent} event - Mocha event to be output.
3409 */
3410function writeEvent(event) {
3411 process.stdout.write(JSON.stringify(event) + '\n');
3412}
3413
3414/**
3415 * Returns an object literal representation of `test`
3416 * free of cyclic properties, etc.
3417 *
3418 * @private
3419 * @param {Test} test - Instance used as data source.
3420 * @return {Object} object containing pared-down test instance data
3421 */
3422function clean(test) {
3423 return {
3424 title: test.title,
3425 fullTitle: test.fullTitle(),
3426 duration: test.duration,
3427 currentRetry: test.currentRetry()
3428 };
3429}
3430
3431JSONStream.description = 'newline delimited JSON events';
3432
3433}).call(this,require('_process'))
3434},{"../runner":34,"./base":17,"_process":68}],23:[function(require,module,exports){
3435(function (process){
3436'use strict';
3437/**
3438 * @module JSON
3439 */
3440/**
3441 * Module dependencies.
3442 */
3443
3444var Base = require('./base');
3445var constants = require('../runner').constants;
3446var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3447var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3448var EVENT_TEST_END = constants.EVENT_TEST_END;
3449var EVENT_RUN_END = constants.EVENT_RUN_END;
3450var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3451
3452/**
3453 * Expose `JSON`.
3454 */
3455
3456exports = module.exports = JSONReporter;
3457
3458/**
3459 * Initialize a new `JSON` reporter.
3460 *
3461 * @public
3462 * @class JSON
3463 * @memberof Mocha.reporters
3464 * @extends Mocha.reporters.Base
3465 * @param {Runner} runner
3466 */
3467function JSONReporter(runner) {
3468 Base.call(this, runner);
3469
3470 var self = this;
3471 var tests = [];
3472 var pending = [];
3473 var failures = [];
3474 var passes = [];
3475
3476 runner.on(EVENT_TEST_END, function(test) {
3477 tests.push(test);
3478 });
3479
3480 runner.on(EVENT_TEST_PASS, function(test) {
3481 passes.push(test);
3482 });
3483
3484 runner.on(EVENT_TEST_FAIL, function(test) {
3485 failures.push(test);
3486 });
3487
3488 runner.on(EVENT_TEST_PENDING, function(test) {
3489 pending.push(test);
3490 });
3491
3492 runner.once(EVENT_RUN_END, function() {
3493 var obj = {
3494 stats: self.stats,
3495 tests: tests.map(clean),
3496 pending: pending.map(clean),
3497 failures: failures.map(clean),
3498 passes: passes.map(clean)
3499 };
3500
3501 runner.testResults = obj;
3502
3503 process.stdout.write(JSON.stringify(obj, null, 2));
3504 });
3505}
3506
3507/**
3508 * Return a plain-object representation of `test`
3509 * free of cyclic properties etc.
3510 *
3511 * @private
3512 * @param {Object} test
3513 * @return {Object}
3514 */
3515function clean(test) {
3516 var err = test.err || {};
3517 if (err instanceof Error) {
3518 err = errorJSON(err);
3519 }
3520
3521 return {
3522 title: test.title,
3523 fullTitle: test.fullTitle(),
3524 duration: test.duration,
3525 currentRetry: test.currentRetry(),
3526 err: cleanCycles(err)
3527 };
3528}
3529
3530/**
3531 * Replaces any circular references inside `obj` with '[object Object]'
3532 *
3533 * @private
3534 * @param {Object} obj
3535 * @return {Object}
3536 */
3537function cleanCycles(obj) {
3538 var cache = [];
3539 return JSON.parse(
3540 JSON.stringify(obj, function(key, value) {
3541 if (typeof value === 'object' && value !== null) {
3542 if (cache.indexOf(value) !== -1) {
3543 // Instead of going in a circle, we'll print [object Object]
3544 return '' + value;
3545 }
3546 cache.push(value);
3547 }
3548
3549 return value;
3550 })
3551 );
3552}
3553
3554/**
3555 * Transform an Error object into a JSON object.
3556 *
3557 * @private
3558 * @param {Error} err
3559 * @return {Object}
3560 */
3561function errorJSON(err) {
3562 var res = {};
3563 Object.getOwnPropertyNames(err).forEach(function(key) {
3564 res[key] = err[key];
3565 }, err);
3566 return res;
3567}
3568
3569JSONReporter.description = 'single JSON object';
3570
3571}).call(this,require('_process'))
3572},{"../runner":34,"./base":17,"_process":68}],24:[function(require,module,exports){
3573(function (process){
3574'use strict';
3575/**
3576 * @module Landing
3577 */
3578/**
3579 * Module dependencies.
3580 */
3581
3582var Base = require('./base');
3583var inherits = require('../utils').inherits;
3584var constants = require('../runner').constants;
3585var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3586var EVENT_RUN_END = constants.EVENT_RUN_END;
3587var EVENT_TEST_END = constants.EVENT_TEST_END;
3588var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
3589
3590var cursor = Base.cursor;
3591var color = Base.color;
3592
3593/**
3594 * Expose `Landing`.
3595 */
3596
3597exports = module.exports = Landing;
3598
3599/**
3600 * Airplane color.
3601 */
3602
3603Base.colors.plane = 0;
3604
3605/**
3606 * Airplane crash color.
3607 */
3608
3609Base.colors['plane crash'] = 31;
3610
3611/**
3612 * Runway color.
3613 */
3614
3615Base.colors.runway = 90;
3616
3617/**
3618 * Initialize a new `Landing` reporter.
3619 *
3620 * @public
3621 * @class
3622 * @memberof Mocha.reporters
3623 * @extends Mocha.reporters.Base
3624 * @param {Runner} runner
3625 */
3626function Landing(runner) {
3627 Base.call(this, runner);
3628
3629 var self = this;
3630 var width = (Base.window.width * 0.75) | 0;
3631 var total = runner.total;
3632 var stream = process.stdout;
3633 var plane = color('plane', '✈');
3634 var crashed = -1;
3635 var n = 0;
3636
3637 function runway() {
3638 var buf = Array(width).join('-');
3639 return ' ' + color('runway', buf);
3640 }
3641
3642 runner.on(EVENT_RUN_BEGIN, function() {
3643 stream.write('\n\n\n ');
3644 cursor.hide();
3645 });
3646
3647 runner.on(EVENT_TEST_END, function(test) {
3648 // check if the plane crashed
3649 var col = crashed === -1 ? ((width * ++n) / total) | 0 : crashed;
3650
3651 // show the crash
3652 if (test.state === STATE_FAILED) {
3653 plane = color('plane crash', '✈');
3654 crashed = col;
3655 }
3656
3657 // render landing strip
3658 stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
3659 stream.write(runway());
3660 stream.write('\n ');
3661 stream.write(color('runway', Array(col).join('⋅')));
3662 stream.write(plane);
3663 stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
3664 stream.write(runway());
3665 stream.write('\u001b[0m');
3666 });
3667
3668 runner.once(EVENT_RUN_END, function() {
3669 cursor.show();
3670 console.log();
3671 self.epilogue();
3672 });
3673}
3674
3675/**
3676 * Inherit from `Base.prototype`.
3677 */
3678inherits(Landing, Base);
3679
3680Landing.description = 'Unicode landing strip';
3681
3682}).call(this,require('_process'))
3683},{"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":68}],25:[function(require,module,exports){
3684(function (process){
3685'use strict';
3686/**
3687 * @module List
3688 */
3689/**
3690 * Module dependencies.
3691 */
3692
3693var Base = require('./base');
3694var inherits = require('../utils').inherits;
3695var constants = require('../runner').constants;
3696var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3697var EVENT_RUN_END = constants.EVENT_RUN_END;
3698var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN;
3699var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3700var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3701var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3702var color = Base.color;
3703var cursor = Base.cursor;
3704
3705/**
3706 * Expose `List`.
3707 */
3708
3709exports = module.exports = List;
3710
3711/**
3712 * Initialize a new `List` test reporter.
3713 *
3714 * @public
3715 * @class
3716 * @memberof Mocha.reporters
3717 * @extends Mocha.reporters.Base
3718 * @param {Runner} runner
3719 */
3720function List(runner) {
3721 Base.call(this, runner);
3722
3723 var self = this;
3724 var n = 0;
3725
3726 runner.on(EVENT_RUN_BEGIN, function() {
3727 console.log();
3728 });
3729
3730 runner.on(EVENT_TEST_BEGIN, function(test) {
3731 process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
3732 });
3733
3734 runner.on(EVENT_TEST_PENDING, function(test) {
3735 var fmt = color('checkmark', ' -') + color('pending', ' %s');
3736 console.log(fmt, test.fullTitle());
3737 });
3738
3739 runner.on(EVENT_TEST_PASS, function(test) {
3740 var fmt =
3741 color('checkmark', ' ' + Base.symbols.ok) +
3742 color('pass', ' %s: ') +
3743 color(test.speed, '%dms');
3744 cursor.CR();
3745 console.log(fmt, test.fullTitle(), test.duration);
3746 });
3747
3748 runner.on(EVENT_TEST_FAIL, function(test) {
3749 cursor.CR();
3750 console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
3751 });
3752
3753 runner.once(EVENT_RUN_END, self.epilogue.bind(self));
3754}
3755
3756/**
3757 * Inherit from `Base.prototype`.
3758 */
3759inherits(List, Base);
3760
3761List.description = 'like "spec" reporter but flat';
3762
3763}).call(this,require('_process'))
3764},{"../runner":34,"../utils":38,"./base":17,"_process":68}],26:[function(require,module,exports){
3765(function (process){
3766'use strict';
3767/**
3768 * @module Markdown
3769 */
3770/**
3771 * Module dependencies.
3772 */
3773
3774var Base = require('./base');
3775var utils = require('../utils');
3776var constants = require('../runner').constants;
3777var EVENT_RUN_END = constants.EVENT_RUN_END;
3778var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
3779var EVENT_SUITE_END = constants.EVENT_SUITE_END;
3780var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3781
3782/**
3783 * Constants
3784 */
3785
3786var SUITE_PREFIX = '$';
3787
3788/**
3789 * Expose `Markdown`.
3790 */
3791
3792exports = module.exports = Markdown;
3793
3794/**
3795 * Initialize a new `Markdown` reporter.
3796 *
3797 * @public
3798 * @class
3799 * @memberof Mocha.reporters
3800 * @extends Mocha.reporters.Base
3801 * @param {Runner} runner
3802 */
3803function Markdown(runner) {
3804 Base.call(this, runner);
3805
3806 var level = 0;
3807 var buf = '';
3808
3809 function title(str) {
3810 return Array(level).join('#') + ' ' + str;
3811 }
3812
3813 function mapTOC(suite, obj) {
3814 var ret = obj;
3815 var key = SUITE_PREFIX + suite.title;
3816
3817 obj = obj[key] = obj[key] || {suite: suite};
3818 suite.suites.forEach(function(suite) {
3819 mapTOC(suite, obj);
3820 });
3821
3822 return ret;
3823 }
3824
3825 function stringifyTOC(obj, level) {
3826 ++level;
3827 var buf = '';
3828 var link;
3829 for (var key in obj) {
3830 if (key === 'suite') {
3831 continue;
3832 }
3833 if (key !== SUITE_PREFIX) {
3834 link = ' - [' + key.substring(1) + ']';
3835 link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
3836 buf += Array(level).join(' ') + link;
3837 }
3838 buf += stringifyTOC(obj[key], level);
3839 }
3840 return buf;
3841 }
3842
3843 function generateTOC(suite) {
3844 var obj = mapTOC(suite, {});
3845 return stringifyTOC(obj, 0);
3846 }
3847
3848 generateTOC(runner.suite);
3849
3850 runner.on(EVENT_SUITE_BEGIN, function(suite) {
3851 ++level;
3852 var slug = utils.slug(suite.fullTitle());
3853 buf += '<a name="' + slug + '"></a>' + '\n';
3854 buf += title(suite.title) + '\n';
3855 });
3856
3857 runner.on(EVENT_SUITE_END, function() {
3858 --level;
3859 });
3860
3861 runner.on(EVENT_TEST_PASS, function(test) {
3862 var code = utils.clean(test.body);
3863 buf += test.title + '.\n';
3864 buf += '\n```js\n';
3865 buf += code + '\n';
3866 buf += '```\n\n';
3867 });
3868
3869 runner.once(EVENT_RUN_END, function() {
3870 process.stdout.write('# TOC\n');
3871 process.stdout.write(generateTOC(runner.suite));
3872 process.stdout.write(buf);
3873 });
3874}
3875
3876Markdown.description = 'GitHub Flavored Markdown';
3877
3878}).call(this,require('_process'))
3879},{"../runner":34,"../utils":38,"./base":17,"_process":68}],27:[function(require,module,exports){
3880(function (process){
3881'use strict';
3882/**
3883 * @module Min
3884 */
3885/**
3886 * Module dependencies.
3887 */
3888
3889var Base = require('./base');
3890var inherits = require('../utils').inherits;
3891var constants = require('../runner').constants;
3892var EVENT_RUN_END = constants.EVENT_RUN_END;
3893var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3894
3895/**
3896 * Expose `Min`.
3897 */
3898
3899exports = module.exports = Min;
3900
3901/**
3902 * Initialize a new `Min` minimal test reporter (best used with --watch).
3903 *
3904 * @public
3905 * @class
3906 * @memberof Mocha.reporters
3907 * @extends Mocha.reporters.Base
3908 * @param {Runner} runner
3909 */
3910function Min(runner) {
3911 Base.call(this, runner);
3912
3913 runner.on(EVENT_RUN_BEGIN, function() {
3914 // clear screen
3915 process.stdout.write('\u001b[2J');
3916 // set cursor position
3917 process.stdout.write('\u001b[1;3H');
3918 });
3919
3920 runner.once(EVENT_RUN_END, this.epilogue.bind(this));
3921}
3922
3923/**
3924 * Inherit from `Base.prototype`.
3925 */
3926inherits(Min, Base);
3927
3928Min.description = 'essentially just a summary';
3929
3930}).call(this,require('_process'))
3931},{"../runner":34,"../utils":38,"./base":17,"_process":68}],28:[function(require,module,exports){
3932(function (process){
3933'use strict';
3934/**
3935 * @module Nyan
3936 */
3937/**
3938 * Module dependencies.
3939 */
3940
3941var Base = require('./base');
3942var constants = require('../runner').constants;
3943var inherits = require('../utils').inherits;
3944var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3945var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3946var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3947var EVENT_RUN_END = constants.EVENT_RUN_END;
3948var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3949
3950/**
3951 * Expose `Dot`.
3952 */
3953
3954exports = module.exports = NyanCat;
3955
3956/**
3957 * Initialize a new `Dot` matrix test reporter.
3958 *
3959 * @param {Runner} runner
3960 * @public
3961 * @class Nyan
3962 * @memberof Mocha.reporters
3963 * @extends Mocha.reporters.Base
3964 */
3965
3966function NyanCat(runner) {
3967 Base.call(this, runner);
3968
3969 var self = this;
3970 var width = (Base.window.width * 0.75) | 0;
3971 var nyanCatWidth = (this.nyanCatWidth = 11);
3972
3973 this.colorIndex = 0;
3974 this.numberOfLines = 4;
3975 this.rainbowColors = self.generateColors();
3976 this.scoreboardWidth = 5;
3977 this.tick = 0;
3978 this.trajectories = [[], [], [], []];
3979 this.trajectoryWidthMax = width - nyanCatWidth;
3980
3981 runner.on(EVENT_RUN_BEGIN, function() {
3982 Base.cursor.hide();
3983 self.draw();
3984 });
3985
3986 runner.on(EVENT_TEST_PENDING, function() {
3987 self.draw();
3988 });
3989
3990 runner.on(EVENT_TEST_PASS, function() {
3991 self.draw();
3992 });
3993
3994 runner.on(EVENT_TEST_FAIL, function() {
3995 self.draw();
3996 });
3997
3998 runner.once(EVENT_RUN_END, function() {
3999 Base.cursor.show();
4000 for (var i = 0; i < self.numberOfLines; i++) {
4001 write('\n');
4002 }
4003 self.epilogue();
4004 });
4005}
4006
4007/**
4008 * Inherit from `Base.prototype`.
4009 */
4010inherits(NyanCat, Base);
4011
4012/**
4013 * Draw the nyan cat
4014 *
4015 * @private
4016 */
4017
4018NyanCat.prototype.draw = function() {
4019 this.appendRainbow();
4020 this.drawScoreboard();
4021 this.drawRainbow();
4022 this.drawNyanCat();
4023 this.tick = !this.tick;
4024};
4025
4026/**
4027 * Draw the "scoreboard" showing the number
4028 * of passes, failures and pending tests.
4029 *
4030 * @private
4031 */
4032
4033NyanCat.prototype.drawScoreboard = function() {
4034 var stats = this.stats;
4035
4036 function draw(type, n) {
4037 write(' ');
4038 write(Base.color(type, n));
4039 write('\n');
4040 }
4041
4042 draw('green', stats.passes);
4043 draw('fail', stats.failures);
4044 draw('pending', stats.pending);
4045 write('\n');
4046
4047 this.cursorUp(this.numberOfLines);
4048};
4049
4050/**
4051 * Append the rainbow.
4052 *
4053 * @private
4054 */
4055
4056NyanCat.prototype.appendRainbow = function() {
4057 var segment = this.tick ? '_' : '-';
4058 var rainbowified = this.rainbowify(segment);
4059
4060 for (var index = 0; index < this.numberOfLines; index++) {
4061 var trajectory = this.trajectories[index];
4062 if (trajectory.length >= this.trajectoryWidthMax) {
4063 trajectory.shift();
4064 }
4065 trajectory.push(rainbowified);
4066 }
4067};
4068
4069/**
4070 * Draw the rainbow.
4071 *
4072 * @private
4073 */
4074
4075NyanCat.prototype.drawRainbow = function() {
4076 var self = this;
4077
4078 this.trajectories.forEach(function(line) {
4079 write('\u001b[' + self.scoreboardWidth + 'C');
4080 write(line.join(''));
4081 write('\n');
4082 });
4083
4084 this.cursorUp(this.numberOfLines);
4085};
4086
4087/**
4088 * Draw the nyan cat
4089 *
4090 * @private
4091 */
4092NyanCat.prototype.drawNyanCat = function() {
4093 var self = this;
4094 var startWidth = this.scoreboardWidth + this.trajectories[0].length;
4095 var dist = '\u001b[' + startWidth + 'C';
4096 var padding = '';
4097
4098 write(dist);
4099 write('_,------,');
4100 write('\n');
4101
4102 write(dist);
4103 padding = self.tick ? ' ' : ' ';
4104 write('_|' + padding + '/\\_/\\ ');
4105 write('\n');
4106
4107 write(dist);
4108 padding = self.tick ? '_' : '__';
4109 var tail = self.tick ? '~' : '^';
4110 write(tail + '|' + padding + this.face() + ' ');
4111 write('\n');
4112
4113 write(dist);
4114 padding = self.tick ? ' ' : ' ';
4115 write(padding + '"" "" ');
4116 write('\n');
4117
4118 this.cursorUp(this.numberOfLines);
4119};
4120
4121/**
4122 * Draw nyan cat face.
4123 *
4124 * @private
4125 * @return {string}
4126 */
4127
4128NyanCat.prototype.face = function() {
4129 var stats = this.stats;
4130 if (stats.failures) {
4131 return '( x .x)';
4132 } else if (stats.pending) {
4133 return '( o .o)';
4134 } else if (stats.passes) {
4135 return '( ^ .^)';
4136 }
4137 return '( - .-)';
4138};
4139
4140/**
4141 * Move cursor up `n`.
4142 *
4143 * @private
4144 * @param {number} n
4145 */
4146
4147NyanCat.prototype.cursorUp = function(n) {
4148 write('\u001b[' + n + 'A');
4149};
4150
4151/**
4152 * Move cursor down `n`.
4153 *
4154 * @private
4155 * @param {number} n
4156 */
4157
4158NyanCat.prototype.cursorDown = function(n) {
4159 write('\u001b[' + n + 'B');
4160};
4161
4162/**
4163 * Generate rainbow colors.
4164 *
4165 * @private
4166 * @return {Array}
4167 */
4168NyanCat.prototype.generateColors = function() {
4169 var colors = [];
4170
4171 for (var i = 0; i < 6 * 7; i++) {
4172 var pi3 = Math.floor(Math.PI / 3);
4173 var n = i * (1.0 / 6);
4174 var r = Math.floor(3 * Math.sin(n) + 3);
4175 var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
4176 var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
4177 colors.push(36 * r + 6 * g + b + 16);
4178 }
4179
4180 return colors;
4181};
4182
4183/**
4184 * Apply rainbow to the given `str`.
4185 *
4186 * @private
4187 * @param {string} str
4188 * @return {string}
4189 */
4190NyanCat.prototype.rainbowify = function(str) {
4191 if (!Base.useColors) {
4192 return str;
4193 }
4194 var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
4195 this.colorIndex += 1;
4196 return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
4197};
4198
4199/**
4200 * Stdout helper.
4201 *
4202 * @param {string} string A message to write to stdout.
4203 */
4204function write(string) {
4205 process.stdout.write(string);
4206}
4207
4208NyanCat.description = '"nyan cat"';
4209
4210}).call(this,require('_process'))
4211},{"../runner":34,"../utils":38,"./base":17,"_process":68}],29:[function(require,module,exports){
4212(function (process){
4213'use strict';
4214/**
4215 * @module Progress
4216 */
4217/**
4218 * Module dependencies.
4219 */
4220
4221var Base = require('./base');
4222var constants = require('../runner').constants;
4223var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4224var EVENT_TEST_END = constants.EVENT_TEST_END;
4225var EVENT_RUN_END = constants.EVENT_RUN_END;
4226var inherits = require('../utils').inherits;
4227var color = Base.color;
4228var cursor = Base.cursor;
4229
4230/**
4231 * Expose `Progress`.
4232 */
4233
4234exports = module.exports = Progress;
4235
4236/**
4237 * General progress bar color.
4238 */
4239
4240Base.colors.progress = 90;
4241
4242/**
4243 * Initialize a new `Progress` bar test reporter.
4244 *
4245 * @public
4246 * @class
4247 * @memberof Mocha.reporters
4248 * @extends Mocha.reporters.Base
4249 * @param {Runner} runner
4250 * @param {Object} options
4251 */
4252function Progress(runner, options) {
4253 Base.call(this, runner);
4254
4255 var self = this;
4256 var width = (Base.window.width * 0.5) | 0;
4257 var total = runner.total;
4258 var complete = 0;
4259 var lastN = -1;
4260
4261 // default chars
4262 options = options || {};
4263 var reporterOptions = options.reporterOptions || {};
4264
4265 options.open = reporterOptions.open || '[';
4266 options.complete = reporterOptions.complete || '▬';
4267 options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
4268 options.close = reporterOptions.close || ']';
4269 options.verbose = reporterOptions.verbose || false;
4270
4271 // tests started
4272 runner.on(EVENT_RUN_BEGIN, function() {
4273 console.log();
4274 cursor.hide();
4275 });
4276
4277 // tests complete
4278 runner.on(EVENT_TEST_END, function() {
4279 complete++;
4280
4281 var percent = complete / total;
4282 var n = (width * percent) | 0;
4283 var i = width - n;
4284
4285 if (n === lastN && !options.verbose) {
4286 // Don't re-render the line if it hasn't changed
4287 return;
4288 }
4289 lastN = n;
4290
4291 cursor.CR();
4292 process.stdout.write('\u001b[J');
4293 process.stdout.write(color('progress', ' ' + options.open));
4294 process.stdout.write(Array(n).join(options.complete));
4295 process.stdout.write(Array(i).join(options.incomplete));
4296 process.stdout.write(color('progress', options.close));
4297 if (options.verbose) {
4298 process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
4299 }
4300 });
4301
4302 // tests are complete, output some stats
4303 // and the failures if any
4304 runner.once(EVENT_RUN_END, function() {
4305 cursor.show();
4306 console.log();
4307 self.epilogue();
4308 });
4309}
4310
4311/**
4312 * Inherit from `Base.prototype`.
4313 */
4314inherits(Progress, Base);
4315
4316Progress.description = 'a progress bar';
4317
4318}).call(this,require('_process'))
4319},{"../runner":34,"../utils":38,"./base":17,"_process":68}],30:[function(require,module,exports){
4320'use strict';
4321/**
4322 * @module Spec
4323 */
4324/**
4325 * Module dependencies.
4326 */
4327
4328var Base = require('./base');
4329var constants = require('../runner').constants;
4330var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4331var EVENT_RUN_END = constants.EVENT_RUN_END;
4332var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
4333var EVENT_SUITE_END = constants.EVENT_SUITE_END;
4334var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4335var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4336var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4337var inherits = require('../utils').inherits;
4338var color = Base.color;
4339
4340/**
4341 * Expose `Spec`.
4342 */
4343
4344exports = module.exports = Spec;
4345
4346/**
4347 * Initialize a new `Spec` test reporter.
4348 *
4349 * @public
4350 * @class
4351 * @memberof Mocha.reporters
4352 * @extends Mocha.reporters.Base
4353 * @param {Runner} runner
4354 */
4355function Spec(runner) {
4356 Base.call(this, runner);
4357
4358 var self = this;
4359 var indents = 0;
4360 var n = 0;
4361
4362 function indent() {
4363 return Array(indents).join(' ');
4364 }
4365
4366 runner.on(EVENT_RUN_BEGIN, function() {
4367 console.log();
4368 });
4369
4370 runner.on(EVENT_SUITE_BEGIN, function(suite) {
4371 ++indents;
4372 console.log(color('suite', '%s%s'), indent(), suite.title);
4373 });
4374
4375 runner.on(EVENT_SUITE_END, function() {
4376 --indents;
4377 if (indents === 1) {
4378 console.log();
4379 }
4380 });
4381
4382 runner.on(EVENT_TEST_PENDING, function(test) {
4383 var fmt = indent() + color('pending', ' - %s');
4384 console.log(fmt, test.title);
4385 });
4386
4387 runner.on(EVENT_TEST_PASS, function(test) {
4388 var fmt;
4389 if (test.speed === 'fast') {
4390 fmt =
4391 indent() +
4392 color('checkmark', ' ' + Base.symbols.ok) +
4393 color('pass', ' %s');
4394 console.log(fmt, test.title);
4395 } else {
4396 fmt =
4397 indent() +
4398 color('checkmark', ' ' + Base.symbols.ok) +
4399 color('pass', ' %s') +
4400 color(test.speed, ' (%dms)');
4401 console.log(fmt, test.title, test.duration);
4402 }
4403 });
4404
4405 runner.on(EVENT_TEST_FAIL, function(test) {
4406 console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
4407 });
4408
4409 runner.once(EVENT_RUN_END, self.epilogue.bind(self));
4410}
4411
4412/**
4413 * Inherit from `Base.prototype`.
4414 */
4415inherits(Spec, Base);
4416
4417Spec.description = 'hierarchical & verbose [default]';
4418
4419},{"../runner":34,"../utils":38,"./base":17}],31:[function(require,module,exports){
4420(function (process){
4421'use strict';
4422/**
4423 * @module TAP
4424 */
4425/**
4426 * Module dependencies.
4427 */
4428
4429var util = require('util');
4430var Base = require('./base');
4431var constants = require('../runner').constants;
4432var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4433var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4434var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4435var EVENT_RUN_END = constants.EVENT_RUN_END;
4436var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4437var EVENT_TEST_END = constants.EVENT_TEST_END;
4438var inherits = require('../utils').inherits;
4439var sprintf = util.format;
4440
4441/**
4442 * Expose `TAP`.
4443 */
4444
4445exports = module.exports = TAP;
4446
4447/**
4448 * Constructs a new TAP reporter with runner instance and reporter options.
4449 *
4450 * @public
4451 * @class
4452 * @extends Mocha.reporters.Base
4453 * @memberof Mocha.reporters
4454 * @param {Runner} runner - Instance triggers reporter actions.
4455 * @param {Object} [options] - runner options
4456 */
4457function TAP(runner, options) {
4458 Base.call(this, runner, options);
4459
4460 var self = this;
4461 var n = 1;
4462
4463 var tapVersion = '12';
4464 if (options && options.reporterOptions) {
4465 if (options.reporterOptions.tapVersion) {
4466 tapVersion = options.reporterOptions.tapVersion.toString();
4467 }
4468 }
4469
4470 this._producer = createProducer(tapVersion);
4471
4472 runner.once(EVENT_RUN_BEGIN, function() {
4473 var ntests = runner.grepTotal(runner.suite);
4474 self._producer.writeVersion();
4475 self._producer.writePlan(ntests);
4476 });
4477
4478 runner.on(EVENT_TEST_END, function() {
4479 ++n;
4480 });
4481
4482 runner.on(EVENT_TEST_PENDING, function(test) {
4483 self._producer.writePending(n, test);
4484 });
4485
4486 runner.on(EVENT_TEST_PASS, function(test) {
4487 self._producer.writePass(n, test);
4488 });
4489
4490 runner.on(EVENT_TEST_FAIL, function(test, err) {
4491 self._producer.writeFail(n, test, err);
4492 });
4493
4494 runner.once(EVENT_RUN_END, function() {
4495 self._producer.writeEpilogue(runner.stats);
4496 });
4497}
4498
4499/**
4500 * Inherit from `Base.prototype`.
4501 */
4502inherits(TAP, Base);
4503
4504/**
4505 * Returns a TAP-safe title of `test`.
4506 *
4507 * @private
4508 * @param {Test} test - Test instance.
4509 * @return {String} title with any hash character removed
4510 */
4511function title(test) {
4512 return test.fullTitle().replace(/#/g, '');
4513}
4514
4515/**
4516 * Writes newline-terminated formatted string to reporter output stream.
4517 *
4518 * @private
4519 * @param {string} format - `printf`-like format string
4520 * @param {...*} [varArgs] - Format string arguments
4521 */
4522function println(format, varArgs) {
4523 var vargs = Array.from(arguments);
4524 vargs[0] += '\n';
4525 process.stdout.write(sprintf.apply(null, vargs));
4526}
4527
4528/**
4529 * Returns a `tapVersion`-appropriate TAP producer instance, if possible.
4530 *
4531 * @private
4532 * @param {string} tapVersion - Version of TAP specification to produce.
4533 * @returns {TAPProducer} specification-appropriate instance
4534 * @throws {Error} if specification version has no associated producer.
4535 */
4536function createProducer(tapVersion) {
4537 var producers = {
4538 '12': new TAP12Producer(),
4539 '13': new TAP13Producer()
4540 };
4541 var producer = producers[tapVersion];
4542
4543 if (!producer) {
4544 throw new Error(
4545 'invalid or unsupported TAP version: ' + JSON.stringify(tapVersion)
4546 );
4547 }
4548
4549 return producer;
4550}
4551
4552/**
4553 * @summary
4554 * Constructs a new TAPProducer.
4555 *
4556 * @description
4557 * <em>Only</em> to be used as an abstract base class.
4558 *
4559 * @private
4560 * @constructor
4561 */
4562function TAPProducer() {}
4563
4564/**
4565 * Writes the TAP version to reporter output stream.
4566 *
4567 * @abstract
4568 */
4569TAPProducer.prototype.writeVersion = function() {};
4570
4571/**
4572 * Writes the plan to reporter output stream.
4573 *
4574 * @abstract
4575 * @param {number} ntests - Number of tests that are planned to run.
4576 */
4577TAPProducer.prototype.writePlan = function(ntests) {
4578 println('%d..%d', 1, ntests);
4579};
4580
4581/**
4582 * Writes that test passed to reporter output stream.
4583 *
4584 * @abstract
4585 * @param {number} n - Index of test that passed.
4586 * @param {Test} test - Instance containing test information.
4587 */
4588TAPProducer.prototype.writePass = function(n, test) {
4589 println('ok %d %s', n, title(test));
4590};
4591
4592/**
4593 * Writes that test was skipped to reporter output stream.
4594 *
4595 * @abstract
4596 * @param {number} n - Index of test that was skipped.
4597 * @param {Test} test - Instance containing test information.
4598 */
4599TAPProducer.prototype.writePending = function(n, test) {
4600 println('ok %d %s # SKIP -', n, title(test));
4601};
4602
4603/**
4604 * Writes that test failed to reporter output stream.
4605 *
4606 * @abstract
4607 * @param {number} n - Index of test that failed.
4608 * @param {Test} test - Instance containing test information.
4609 * @param {Error} err - Reason the test failed.
4610 */
4611TAPProducer.prototype.writeFail = function(n, test, err) {
4612 println('not ok %d %s', n, title(test));
4613};
4614
4615/**
4616 * Writes the summary epilogue to reporter output stream.
4617 *
4618 * @abstract
4619 * @param {Object} stats - Object containing run statistics.
4620 */
4621TAPProducer.prototype.writeEpilogue = function(stats) {
4622 // :TBD: Why is this not counting pending tests?
4623 println('# tests ' + (stats.passes + stats.failures));
4624 println('# pass ' + stats.passes);
4625 // :TBD: Why are we not showing pending results?
4626 println('# fail ' + stats.failures);
4627};
4628
4629/**
4630 * @summary
4631 * Constructs a new TAP12Producer.
4632 *
4633 * @description
4634 * Produces output conforming to the TAP12 specification.
4635 *
4636 * @private
4637 * @constructor
4638 * @extends TAPProducer
4639 * @see {@link https://testanything.org/tap-specification.html|Specification}
4640 */
4641function TAP12Producer() {
4642 /**
4643 * Writes that test failed to reporter output stream, with error formatting.
4644 * @override
4645 */
4646 this.writeFail = function(n, test, err) {
4647 TAPProducer.prototype.writeFail.call(this, n, test, err);
4648 if (err.message) {
4649 println(err.message.replace(/^/gm, ' '));
4650 }
4651 if (err.stack) {
4652 println(err.stack.replace(/^/gm, ' '));
4653 }
4654 };
4655}
4656
4657/**
4658 * Inherit from `TAPProducer.prototype`.
4659 */
4660inherits(TAP12Producer, TAPProducer);
4661
4662/**
4663 * @summary
4664 * Constructs a new TAP13Producer.
4665 *
4666 * @description
4667 * Produces output conforming to the TAP13 specification.
4668 *
4669 * @private
4670 * @constructor
4671 * @extends TAPProducer
4672 * @see {@link https://testanything.org/tap-version-13-specification.html|Specification}
4673 */
4674function TAP13Producer() {
4675 /**
4676 * Writes the TAP version to reporter output stream.
4677 * @override
4678 */
4679 this.writeVersion = function() {
4680 println('TAP version 13');
4681 };
4682
4683 /**
4684 * Writes that test failed to reporter output stream, with error formatting.
4685 * @override
4686 */
4687 this.writeFail = function(n, test, err) {
4688 TAPProducer.prototype.writeFail.call(this, n, test, err);
4689 var emitYamlBlock = err.message != null || err.stack != null;
4690 if (emitYamlBlock) {
4691 println(indent(1) + '---');
4692 if (err.message) {
4693 println(indent(2) + 'message: |-');
4694 println(err.message.replace(/^/gm, indent(3)));
4695 }
4696 if (err.stack) {
4697 println(indent(2) + 'stack: |-');
4698 println(err.stack.replace(/^/gm, indent(3)));
4699 }
4700 println(indent(1) + '...');
4701 }
4702 };
4703
4704 function indent(level) {
4705 return Array(level + 1).join(' ');
4706 }
4707}
4708
4709/**
4710 * Inherit from `TAPProducer.prototype`.
4711 */
4712inherits(TAP13Producer, TAPProducer);
4713
4714TAP.description = 'TAP-compatible output';
4715
4716}).call(this,require('_process'))
4717},{"../runner":34,"../utils":38,"./base":17,"_process":68,"util":88}],32:[function(require,module,exports){
4718(function (process,global){
4719'use strict';
4720/**
4721 * @module XUnit
4722 */
4723/**
4724 * Module dependencies.
4725 */
4726
4727var Base = require('./base');
4728var utils = require('../utils');
4729var fs = require('fs');
4730var mkdirp = require('mkdirp');
4731var path = require('path');
4732var errors = require('../errors');
4733var createUnsupportedError = errors.createUnsupportedError;
4734var constants = require('../runner').constants;
4735var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4736var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4737var EVENT_RUN_END = constants.EVENT_RUN_END;
4738var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4739var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
4740var inherits = utils.inherits;
4741var escape = utils.escape;
4742
4743/**
4744 * Save timer references to avoid Sinon interfering (see GH-237).
4745 */
4746var Date = global.Date;
4747
4748/**
4749 * Expose `XUnit`.
4750 */
4751
4752exports = module.exports = XUnit;
4753
4754/**
4755 * Initialize a new `XUnit` reporter.
4756 *
4757 * @public
4758 * @class
4759 * @memberof Mocha.reporters
4760 * @extends Mocha.reporters.Base
4761 * @param {Runner} runner
4762 */
4763function XUnit(runner, options) {
4764 Base.call(this, runner);
4765
4766 var stats = this.stats;
4767 var tests = [];
4768 var self = this;
4769
4770 // the name of the test suite, as it will appear in the resulting XML file
4771 var suiteName;
4772
4773 // the default name of the test suite if none is provided
4774 var DEFAULT_SUITE_NAME = 'Mocha Tests';
4775
4776 if (options && options.reporterOptions) {
4777 if (options.reporterOptions.output) {
4778 if (!fs.createWriteStream) {
4779 throw createUnsupportedError('file output not supported in browser');
4780 }
4781
4782 mkdirp.sync(path.dirname(options.reporterOptions.output));
4783 self.fileStream = fs.createWriteStream(options.reporterOptions.output);
4784 }
4785
4786 // get the suite name from the reporter options (if provided)
4787 suiteName = options.reporterOptions.suiteName;
4788 }
4789
4790 // fall back to the default suite name
4791 suiteName = suiteName || DEFAULT_SUITE_NAME;
4792
4793 runner.on(EVENT_TEST_PENDING, function(test) {
4794 tests.push(test);
4795 });
4796
4797 runner.on(EVENT_TEST_PASS, function(test) {
4798 tests.push(test);
4799 });
4800
4801 runner.on(EVENT_TEST_FAIL, function(test) {
4802 tests.push(test);
4803 });
4804
4805 runner.once(EVENT_RUN_END, function() {
4806 self.write(
4807 tag(
4808 'testsuite',
4809 {
4810 name: suiteName,
4811 tests: stats.tests,
4812 failures: 0,
4813 errors: stats.failures,
4814 skipped: stats.tests - stats.failures - stats.passes,
4815 timestamp: new Date().toUTCString(),
4816 time: stats.duration / 1000 || 0
4817 },
4818 false
4819 )
4820 );
4821
4822 tests.forEach(function(t) {
4823 self.test(t);
4824 });
4825
4826 self.write('</testsuite>');
4827 });
4828}
4829
4830/**
4831 * Inherit from `Base.prototype`.
4832 */
4833inherits(XUnit, Base);
4834
4835/**
4836 * Override done to close the stream (if it's a file).
4837 *
4838 * @param failures
4839 * @param {Function} fn
4840 */
4841XUnit.prototype.done = function(failures, fn) {
4842 if (this.fileStream) {
4843 this.fileStream.end(function() {
4844 fn(failures);
4845 });
4846 } else {
4847 fn(failures);
4848 }
4849};
4850
4851/**
4852 * Write out the given line.
4853 *
4854 * @param {string} line
4855 */
4856XUnit.prototype.write = function(line) {
4857 if (this.fileStream) {
4858 this.fileStream.write(line + '\n');
4859 } else if (typeof process === 'object' && process.stdout) {
4860 process.stdout.write(line + '\n');
4861 } else {
4862 console.log(line);
4863 }
4864};
4865
4866/**
4867 * Output tag for the given `test.`
4868 *
4869 * @param {Test} test
4870 */
4871XUnit.prototype.test = function(test) {
4872 Base.useColors = false;
4873
4874 var attrs = {
4875 classname: test.parent.fullTitle(),
4876 name: test.title,
4877 time: test.duration / 1000 || 0
4878 };
4879
4880 if (test.state === STATE_FAILED) {
4881 var err = test.err;
4882 var diff =
4883 Base.hideDiff || !err.actual || !err.expected
4884 ? ''
4885 : '\n' + Base.generateDiff(err.actual, err.expected);
4886 this.write(
4887 tag(
4888 'testcase',
4889 attrs,
4890 false,
4891 tag(
4892 'failure',
4893 {},
4894 false,
4895 escape(err.message) + escape(diff) + '\n' + escape(err.stack)
4896 )
4897 )
4898 );
4899 } else if (test.isPending()) {
4900 this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
4901 } else {
4902 this.write(tag('testcase', attrs, true));
4903 }
4904};
4905
4906/**
4907 * HTML tag helper.
4908 *
4909 * @param name
4910 * @param attrs
4911 * @param close
4912 * @param content
4913 * @return {string}
4914 */
4915function tag(name, attrs, close, content) {
4916 var end = close ? '/>' : '>';
4917 var pairs = [];
4918 var tag;
4919
4920 for (var key in attrs) {
4921 if (Object.prototype.hasOwnProperty.call(attrs, key)) {
4922 pairs.push(key + '="' + escape(attrs[key]) + '"');
4923 }
4924 }
4925
4926 tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
4927 if (content) {
4928 tag += content + '</' + name + end;
4929 }
4930 return tag;
4931}
4932
4933XUnit.description = 'XUnit-compatible XML output';
4934
4935}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4936},{"../errors":6,"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":68,"fs":42,"mkdirp":59,"path":42}],33:[function(require,module,exports){
4937(function (global){
4938'use strict';
4939
4940var EventEmitter = require('events').EventEmitter;
4941var Pending = require('./pending');
4942var debug = require('debug')('mocha:runnable');
4943var milliseconds = require('ms');
4944var utils = require('./utils');
4945var createInvalidExceptionError = require('./errors')
4946 .createInvalidExceptionError;
4947
4948/**
4949 * Save timer references to avoid Sinon interfering (see GH-237).
4950 */
4951var Date = global.Date;
4952var setTimeout = global.setTimeout;
4953var clearTimeout = global.clearTimeout;
4954var toString = Object.prototype.toString;
4955
4956module.exports = Runnable;
4957
4958/**
4959 * Initialize a new `Runnable` with the given `title` and callback `fn`.
4960 *
4961 * @class
4962 * @extends external:EventEmitter
4963 * @public
4964 * @param {String} title
4965 * @param {Function} fn
4966 */
4967function Runnable(title, fn) {
4968 this.title = title;
4969 this.fn = fn;
4970 this.body = (fn || '').toString();
4971 this.async = fn && fn.length;
4972 this.sync = !this.async;
4973 this._timeout = 2000;
4974 this._slow = 75;
4975 this._enableTimeouts = true;
4976 this.timedOut = false;
4977 this._retries = -1;
4978 this._currentRetry = 0;
4979 this.pending = false;
4980}
4981
4982/**
4983 * Inherit from `EventEmitter.prototype`.
4984 */
4985utils.inherits(Runnable, EventEmitter);
4986
4987/**
4988 * Get current timeout value in msecs.
4989 *
4990 * @private
4991 * @returns {number} current timeout threshold value
4992 */
4993/**
4994 * @summary
4995 * Set timeout threshold value (msecs).
4996 *
4997 * @description
4998 * A string argument can use shorthand (e.g., "2s") and will be converted.
4999 * The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>].
5000 * If clamped value matches either range endpoint, timeouts will be disabled.
5001 *
5002 * @private
5003 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value}
5004 * @param {number|string} ms - Timeout threshold value.
5005 * @returns {Runnable} this
5006 * @chainable
5007 */
5008Runnable.prototype.timeout = function(ms) {
5009 if (!arguments.length) {
5010 return this._timeout;
5011 }
5012 if (typeof ms === 'string') {
5013 ms = milliseconds(ms);
5014 }
5015
5016 // Clamp to range
5017 var INT_MAX = Math.pow(2, 31) - 1;
5018 var range = [0, INT_MAX];
5019 ms = utils.clamp(ms, range);
5020
5021 // see #1652 for reasoning
5022 if (ms === range[0] || ms === range[1]) {
5023 this._enableTimeouts = false;
5024 }
5025 debug('timeout %d', ms);
5026 this._timeout = ms;
5027 if (this.timer) {
5028 this.resetTimeout();
5029 }
5030 return this;
5031};
5032
5033/**
5034 * Set or get slow `ms`.
5035 *
5036 * @private
5037 * @param {number|string} ms
5038 * @return {Runnable|number} ms or Runnable instance.
5039 */
5040Runnable.prototype.slow = function(ms) {
5041 if (!arguments.length || typeof ms === 'undefined') {
5042 return this._slow;
5043 }
5044 if (typeof ms === 'string') {
5045 ms = milliseconds(ms);
5046 }
5047 debug('slow %d', ms);
5048 this._slow = ms;
5049 return this;
5050};
5051
5052/**
5053 * Set and get whether timeout is `enabled`.
5054 *
5055 * @private
5056 * @param {boolean} enabled
5057 * @return {Runnable|boolean} enabled or Runnable instance.
5058 */
5059Runnable.prototype.enableTimeouts = function(enabled) {
5060 if (!arguments.length) {
5061 return this._enableTimeouts;
5062 }
5063 debug('enableTimeouts %s', enabled);
5064 this._enableTimeouts = enabled;
5065 return this;
5066};
5067
5068/**
5069 * Halt and mark as pending.
5070 *
5071 * @memberof Mocha.Runnable
5072 * @public
5073 */
5074Runnable.prototype.skip = function() {
5075 throw new Pending('sync skip');
5076};
5077
5078/**
5079 * Check if this runnable or its parent suite is marked as pending.
5080 *
5081 * @private
5082 */
5083Runnable.prototype.isPending = function() {
5084 return this.pending || (this.parent && this.parent.isPending());
5085};
5086
5087/**
5088 * Return `true` if this Runnable has failed.
5089 * @return {boolean}
5090 * @private
5091 */
5092Runnable.prototype.isFailed = function() {
5093 return !this.isPending() && this.state === constants.STATE_FAILED;
5094};
5095
5096/**
5097 * Return `true` if this Runnable has passed.
5098 * @return {boolean}
5099 * @private
5100 */
5101Runnable.prototype.isPassed = function() {
5102 return !this.isPending() && this.state === constants.STATE_PASSED;
5103};
5104
5105/**
5106 * Set or get number of retries.
5107 *
5108 * @private
5109 */
5110Runnable.prototype.retries = function(n) {
5111 if (!arguments.length) {
5112 return this._retries;
5113 }
5114 this._retries = n;
5115};
5116
5117/**
5118 * Set or get current retry
5119 *
5120 * @private
5121 */
5122Runnable.prototype.currentRetry = function(n) {
5123 if (!arguments.length) {
5124 return this._currentRetry;
5125 }
5126 this._currentRetry = n;
5127};
5128
5129/**
5130 * Return the full title generated by recursively concatenating the parent's
5131 * full title.
5132 *
5133 * @memberof Mocha.Runnable
5134 * @public
5135 * @return {string}
5136 */
5137Runnable.prototype.fullTitle = function() {
5138 return this.titlePath().join(' ');
5139};
5140
5141/**
5142 * Return the title path generated by concatenating the parent's title path with the title.
5143 *
5144 * @memberof Mocha.Runnable
5145 * @public
5146 * @return {string}
5147 */
5148Runnable.prototype.titlePath = function() {
5149 return this.parent.titlePath().concat([this.title]);
5150};
5151
5152/**
5153 * Clear the timeout.
5154 *
5155 * @private
5156 */
5157Runnable.prototype.clearTimeout = function() {
5158 clearTimeout(this.timer);
5159};
5160
5161/**
5162 * Inspect the runnable void of private properties.
5163 *
5164 * @private
5165 * @return {string}
5166 */
5167Runnable.prototype.inspect = function() {
5168 return JSON.stringify(
5169 this,
5170 function(key, val) {
5171 if (key[0] === '_') {
5172 return;
5173 }
5174 if (key === 'parent') {
5175 return '#<Suite>';
5176 }
5177 if (key === 'ctx') {
5178 return '#<Context>';
5179 }
5180 return val;
5181 },
5182 2
5183 );
5184};
5185
5186/**
5187 * Reset the timeout.
5188 *
5189 * @private
5190 */
5191Runnable.prototype.resetTimeout = function() {
5192 var self = this;
5193 var ms = this.timeout() || 1e9;
5194
5195 if (!this._enableTimeouts) {
5196 return;
5197 }
5198 this.clearTimeout();
5199 this.timer = setTimeout(function() {
5200 if (!self._enableTimeouts) {
5201 return;
5202 }
5203 self.callback(self._timeoutError(ms));
5204 self.timedOut = true;
5205 }, ms);
5206};
5207
5208/**
5209 * Set or get a list of whitelisted globals for this test run.
5210 *
5211 * @private
5212 * @param {string[]} globals
5213 */
5214Runnable.prototype.globals = function(globals) {
5215 if (!arguments.length) {
5216 return this._allowedGlobals;
5217 }
5218 this._allowedGlobals = globals;
5219};
5220
5221/**
5222 * Run the test and invoke `fn(err)`.
5223 *
5224 * @param {Function} fn
5225 * @private
5226 */
5227Runnable.prototype.run = function(fn) {
5228 var self = this;
5229 var start = new Date();
5230 var ctx = this.ctx;
5231 var finished;
5232 var emitted;
5233
5234 // Sometimes the ctx exists, but it is not runnable
5235 if (ctx && ctx.runnable) {
5236 ctx.runnable(this);
5237 }
5238
5239 // called multiple times
5240 function multiple(err) {
5241 if (emitted) {
5242 return;
5243 }
5244 emitted = true;
5245 var msg = 'done() called multiple times';
5246 if (err && err.message) {
5247 err.message += " (and Mocha's " + msg + ')';
5248 self.emit('error', err);
5249 } else {
5250 self.emit('error', new Error(msg));
5251 }
5252 }
5253
5254 // finished
5255 function done(err) {
5256 var ms = self.timeout();
5257 if (self.timedOut) {
5258 return;
5259 }
5260
5261 if (finished) {
5262 return multiple(err);
5263 }
5264
5265 self.clearTimeout();
5266 self.duration = new Date() - start;
5267 finished = true;
5268 if (!err && self.duration > ms && self._enableTimeouts) {
5269 err = self._timeoutError(ms);
5270 }
5271 fn(err);
5272 }
5273
5274 // for .resetTimeout()
5275 this.callback = done;
5276
5277 // explicit async with `done` argument
5278 if (this.async) {
5279 this.resetTimeout();
5280
5281 // allows skip() to be used in an explicit async context
5282 this.skip = function asyncSkip() {
5283 done(new Pending('async skip call'));
5284 // halt execution. the Runnable will be marked pending
5285 // by the previous call, and the uncaught handler will ignore
5286 // the failure.
5287 throw new Pending('async skip; aborting execution');
5288 };
5289
5290 if (this.allowUncaught) {
5291 return callFnAsync(this.fn);
5292 }
5293 try {
5294 callFnAsync(this.fn);
5295 } catch (err) {
5296 emitted = true;
5297 done(Runnable.toValueOrError(err));
5298 }
5299 return;
5300 }
5301
5302 if (this.allowUncaught) {
5303 if (this.isPending()) {
5304 done();
5305 } else {
5306 callFn(this.fn);
5307 }
5308 return;
5309 }
5310
5311 // sync or promise-returning
5312 try {
5313 if (this.isPending()) {
5314 done();
5315 } else {
5316 callFn(this.fn);
5317 }
5318 } catch (err) {
5319 emitted = true;
5320 done(Runnable.toValueOrError(err));
5321 }
5322
5323 function callFn(fn) {
5324 var result = fn.call(ctx);
5325 if (result && typeof result.then === 'function') {
5326 self.resetTimeout();
5327 result.then(
5328 function() {
5329 done();
5330 // Return null so libraries like bluebird do not warn about
5331 // subsequently constructed Promises.
5332 return null;
5333 },
5334 function(reason) {
5335 done(reason || new Error('Promise rejected with no or falsy reason'));
5336 }
5337 );
5338 } else {
5339 if (self.asyncOnly) {
5340 return done(
5341 new Error(
5342 '--async-only option in use without declaring `done()` or returning a promise'
5343 )
5344 );
5345 }
5346
5347 done();
5348 }
5349 }
5350
5351 function callFnAsync(fn) {
5352 var result = fn.call(ctx, function(err) {
5353 if (err instanceof Error || toString.call(err) === '[object Error]') {
5354 return done(err);
5355 }
5356 if (err) {
5357 if (Object.prototype.toString.call(err) === '[object Object]') {
5358 return done(
5359 new Error('done() invoked with non-Error: ' + JSON.stringify(err))
5360 );
5361 }
5362 return done(new Error('done() invoked with non-Error: ' + err));
5363 }
5364 if (result && utils.isPromise(result)) {
5365 return done(
5366 new Error(
5367 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
5368 )
5369 );
5370 }
5371
5372 done();
5373 });
5374 }
5375};
5376
5377/**
5378 * Instantiates a "timeout" error
5379 *
5380 * @param {number} ms - Timeout (in milliseconds)
5381 * @returns {Error} a "timeout" error
5382 * @private
5383 */
5384Runnable.prototype._timeoutError = function(ms) {
5385 var msg =
5386 'Timeout of ' +
5387 ms +
5388 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
5389 if (this.file) {
5390 msg += ' (' + this.file + ')';
5391 }
5392 return new Error(msg);
5393};
5394
5395var constants = utils.defineConstants(
5396 /**
5397 * {@link Runnable}-related constants.
5398 * @public
5399 * @memberof Runnable
5400 * @readonly
5401 * @static
5402 * @alias constants
5403 * @enum {string}
5404 */
5405 {
5406 /**
5407 * Value of `state` prop when a `Runnable` has failed
5408 */
5409 STATE_FAILED: 'failed',
5410 /**
5411 * Value of `state` prop when a `Runnable` has passed
5412 */
5413 STATE_PASSED: 'passed'
5414 }
5415);
5416
5417/**
5418 * Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that.
5419 * @param {*} [value] - Value to return, if present
5420 * @returns {*|Error} `value`, otherwise an `Error`
5421 * @private
5422 */
5423Runnable.toValueOrError = function(value) {
5424 return (
5425 value ||
5426 createInvalidExceptionError(
5427 'Runnable failed with falsy or undefined exception. Please throw an Error instead.',
5428 value
5429 )
5430 );
5431};
5432
5433Runnable.constants = constants;
5434
5435}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5436},{"./errors":6,"./pending":16,"./utils":38,"debug":45,"events":50,"ms":60}],34:[function(require,module,exports){
5437(function (process,global){
5438'use strict';
5439
5440/**
5441 * Module dependencies.
5442 */
5443var util = require('util');
5444var EventEmitter = require('events').EventEmitter;
5445var Pending = require('./pending');
5446var utils = require('./utils');
5447var inherits = utils.inherits;
5448var debug = require('debug')('mocha:runner');
5449var Runnable = require('./runnable');
5450var Suite = require('./suite');
5451var HOOK_TYPE_BEFORE_EACH = Suite.constants.HOOK_TYPE_BEFORE_EACH;
5452var HOOK_TYPE_AFTER_EACH = Suite.constants.HOOK_TYPE_AFTER_EACH;
5453var HOOK_TYPE_AFTER_ALL = Suite.constants.HOOK_TYPE_AFTER_ALL;
5454var HOOK_TYPE_BEFORE_ALL = Suite.constants.HOOK_TYPE_BEFORE_ALL;
5455var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN;
5456var STATE_FAILED = Runnable.constants.STATE_FAILED;
5457var STATE_PASSED = Runnable.constants.STATE_PASSED;
5458var dQuote = utils.dQuote;
5459var ngettext = utils.ngettext;
5460var sQuote = utils.sQuote;
5461var stackFilter = utils.stackTraceFilter();
5462var stringify = utils.stringify;
5463var type = utils.type;
5464var createInvalidExceptionError = require('./errors')
5465 .createInvalidExceptionError;
5466
5467/**
5468 * Non-enumerable globals.
5469 * @readonly
5470 */
5471var globals = [
5472 'setTimeout',
5473 'clearTimeout',
5474 'setInterval',
5475 'clearInterval',
5476 'XMLHttpRequest',
5477 'Date',
5478 'setImmediate',
5479 'clearImmediate'
5480];
5481
5482var constants = utils.defineConstants(
5483 /**
5484 * {@link Runner}-related constants.
5485 * @public
5486 * @memberof Runner
5487 * @readonly
5488 * @alias constants
5489 * @static
5490 * @enum {string}
5491 */
5492 {
5493 /**
5494 * Emitted when {@link Hook} execution begins
5495 */
5496 EVENT_HOOK_BEGIN: 'hook',
5497 /**
5498 * Emitted when {@link Hook} execution ends
5499 */
5500 EVENT_HOOK_END: 'hook end',
5501 /**
5502 * Emitted when Root {@link Suite} execution begins (all files have been parsed and hooks/tests are ready for execution)
5503 */
5504 EVENT_RUN_BEGIN: 'start',
5505 /**
5506 * Emitted when Root {@link Suite} execution has been delayed via `delay` option
5507 */
5508 EVENT_DELAY_BEGIN: 'waiting',
5509 /**
5510 * Emitted when delayed Root {@link Suite} execution is triggered by user via `global.run()`
5511 */
5512 EVENT_DELAY_END: 'ready',
5513 /**
5514 * Emitted when Root {@link Suite} execution ends
5515 */
5516 EVENT_RUN_END: 'end',
5517 /**
5518 * Emitted when {@link Suite} execution begins
5519 */
5520 EVENT_SUITE_BEGIN: 'suite',
5521 /**
5522 * Emitted when {@link Suite} execution ends
5523 */
5524 EVENT_SUITE_END: 'suite end',
5525 /**
5526 * Emitted when {@link Test} execution begins
5527 */
5528 EVENT_TEST_BEGIN: 'test',
5529 /**
5530 * Emitted when {@link Test} execution ends
5531 */
5532 EVENT_TEST_END: 'test end',
5533 /**
5534 * Emitted when {@link Test} execution fails
5535 */
5536 EVENT_TEST_FAIL: 'fail',
5537 /**
5538 * Emitted when {@link Test} execution succeeds
5539 */
5540 EVENT_TEST_PASS: 'pass',
5541 /**
5542 * Emitted when {@link Test} becomes pending
5543 */
5544 EVENT_TEST_PENDING: 'pending',
5545 /**
5546 * Emitted when {@link Test} execution has failed, but will retry
5547 */
5548 EVENT_TEST_RETRY: 'retry'
5549 }
5550);
5551
5552module.exports = Runner;
5553
5554/**
5555 * Initialize a `Runner` at the Root {@link Suite}, which represents a hierarchy of {@link Suite|Suites} and {@link Test|Tests}.
5556 *
5557 * @extends external:EventEmitter
5558 * @public
5559 * @class
5560 * @param {Suite} suite Root suite
5561 * @param {boolean} [delay] Whether or not to delay execution of root suite
5562 * until ready.
5563 */
5564function Runner(suite, delay) {
5565 var self = this;
5566 this._globals = [];
5567 this._abort = false;
5568 this._delay = delay;
5569 this.suite = suite;
5570 this.started = false;
5571 this.total = suite.total();
5572 this.failures = 0;
5573 this.on(constants.EVENT_TEST_END, function(test) {
5574 self.checkGlobals(test);
5575 });
5576 this.on(constants.EVENT_HOOK_END, function(hook) {
5577 self.checkGlobals(hook);
5578 });
5579 this._defaultGrep = /.*/;
5580 this.grep(this._defaultGrep);
5581 this.globals(this.globalProps().concat(extraGlobals()));
5582}
5583
5584/**
5585 * Wrapper for setImmediate, process.nextTick, or browser polyfill.
5586 *
5587 * @param {Function} fn
5588 * @private
5589 */
5590Runner.immediately = global.setImmediate || process.nextTick;
5591
5592/**
5593 * Inherit from `EventEmitter.prototype`.
5594 */
5595inherits(Runner, EventEmitter);
5596
5597/**
5598 * Run tests with full titles matching `re`. Updates runner.total
5599 * with number of tests matched.
5600 *
5601 * @public
5602 * @memberof Runner
5603 * @param {RegExp} re
5604 * @param {boolean} invert
5605 * @return {Runner} Runner instance.
5606 */
5607Runner.prototype.grep = function(re, invert) {
5608 debug('grep %s', re);
5609 this._grep = re;
5610 this._invert = invert;
5611 this.total = this.grepTotal(this.suite);
5612 return this;
5613};
5614
5615/**
5616 * Returns the number of tests matching the grep search for the
5617 * given suite.
5618 *
5619 * @memberof Runner
5620 * @public
5621 * @param {Suite} suite
5622 * @return {number}
5623 */
5624Runner.prototype.grepTotal = function(suite) {
5625 var self = this;
5626 var total = 0;
5627
5628 suite.eachTest(function(test) {
5629 var match = self._grep.test(test.fullTitle());
5630 if (self._invert) {
5631 match = !match;
5632 }
5633 if (match) {
5634 total++;
5635 }
5636 });
5637
5638 return total;
5639};
5640
5641/**
5642 * Return a list of global properties.
5643 *
5644 * @return {Array}
5645 * @private
5646 */
5647Runner.prototype.globalProps = function() {
5648 var props = Object.keys(global);
5649
5650 // non-enumerables
5651 for (var i = 0; i < globals.length; ++i) {
5652 if (~props.indexOf(globals[i])) {
5653 continue;
5654 }
5655 props.push(globals[i]);
5656 }
5657
5658 return props;
5659};
5660
5661/**
5662 * Allow the given `arr` of globals.
5663 *
5664 * @public
5665 * @memberof Runner
5666 * @param {Array} arr
5667 * @return {Runner} Runner instance.
5668 */
5669Runner.prototype.globals = function(arr) {
5670 if (!arguments.length) {
5671 return this._globals;
5672 }
5673 debug('globals %j', arr);
5674 this._globals = this._globals.concat(arr);
5675 return this;
5676};
5677
5678/**
5679 * Check for global variable leaks.
5680 *
5681 * @private
5682 */
5683Runner.prototype.checkGlobals = function(test) {
5684 if (this.ignoreLeaks) {
5685 return;
5686 }
5687 var ok = this._globals;
5688
5689 var globals = this.globalProps();
5690 var leaks;
5691
5692 if (test) {
5693 ok = ok.concat(test._allowedGlobals || []);
5694 }
5695
5696 if (this.prevGlobalsLength === globals.length) {
5697 return;
5698 }
5699 this.prevGlobalsLength = globals.length;
5700
5701 leaks = filterLeaks(ok, globals);
5702 this._globals = this._globals.concat(leaks);
5703
5704 if (leaks.length) {
5705 var format = ngettext(
5706 leaks.length,
5707 'global leak detected: %s',
5708 'global leaks detected: %s'
5709 );
5710 var error = new Error(util.format(format, leaks.map(sQuote).join(', ')));
5711 this.fail(test, error);
5712 }
5713};
5714
5715/**
5716 * Fail the given `test`.
5717 *
5718 * @private
5719 * @param {Test} test
5720 * @param {Error} err
5721 */
5722Runner.prototype.fail = function(test, err) {
5723 if (test.isPending()) {
5724 return;
5725 }
5726
5727 ++this.failures;
5728 test.state = STATE_FAILED;
5729
5730 if (!isError(err)) {
5731 err = thrown2Error(err);
5732 }
5733
5734 try {
5735 err.stack =
5736 this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
5737 } catch (ignore) {
5738 // some environments do not take kindly to monkeying with the stack
5739 }
5740
5741 this.emit(constants.EVENT_TEST_FAIL, test, err);
5742};
5743
5744/**
5745 * Fail the given `hook` with `err`.
5746 *
5747 * Hook failures work in the following pattern:
5748 * - If bail, run corresponding `after each` and `after` hooks,
5749 * then exit
5750 * - Failed `before` hook skips all tests in a suite and subsuites,
5751 * but jumps to corresponding `after` hook
5752 * - Failed `before each` hook skips remaining tests in a
5753 * suite and jumps to corresponding `after each` hook,
5754 * which is run only once
5755 * - Failed `after` hook does not alter
5756 * execution order
5757 * - Failed `after each` hook skips remaining tests in a
5758 * suite and subsuites, but executes other `after each`
5759 * hooks
5760 *
5761 * @private
5762 * @param {Hook} hook
5763 * @param {Error} err
5764 */
5765Runner.prototype.failHook = function(hook, err) {
5766 hook.originalTitle = hook.originalTitle || hook.title;
5767 if (hook.ctx && hook.ctx.currentTest) {
5768 hook.title =
5769 hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title);
5770 } else {
5771 var parentTitle;
5772 if (hook.parent.title) {
5773 parentTitle = hook.parent.title;
5774 } else {
5775 parentTitle = hook.parent.root ? '{root}' : '';
5776 }
5777 hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle);
5778 }
5779
5780 this.fail(hook, err);
5781};
5782
5783/**
5784 * Run hook `name` callbacks and then invoke `fn()`.
5785 *
5786 * @private
5787 * @param {string} name
5788 * @param {Function} fn
5789 */
5790
5791Runner.prototype.hook = function(name, fn) {
5792 var suite = this.suite;
5793 var hooks = suite.getHooks(name);
5794 var self = this;
5795
5796 function next(i) {
5797 var hook = hooks[i];
5798 if (!hook) {
5799 return fn();
5800 }
5801 self.currentRunnable = hook;
5802
5803 if (name === 'beforeAll') {
5804 hook.ctx.currentTest = hook.parent.tests[0];
5805 } else if (name === 'afterAll') {
5806 hook.ctx.currentTest = hook.parent.tests[hook.parent.tests.length - 1];
5807 } else {
5808 hook.ctx.currentTest = self.test;
5809 }
5810
5811 self.emit(constants.EVENT_HOOK_BEGIN, hook);
5812
5813 if (!hook.listeners('error').length) {
5814 hook.on('error', function(err) {
5815 self.failHook(hook, err);
5816 });
5817 }
5818
5819 hook.run(function(err) {
5820 var testError = hook.error();
5821 if (testError) {
5822 self.fail(self.test, testError);
5823 }
5824 if (err) {
5825 if (err instanceof Pending) {
5826 if (name === HOOK_TYPE_BEFORE_EACH || name === HOOK_TYPE_AFTER_EACH) {
5827 self.test.pending = true;
5828 } else {
5829 suite.tests.forEach(function(test) {
5830 test.pending = true;
5831 });
5832 suite.suites.forEach(function(suite) {
5833 suite.pending = true;
5834 });
5835 // a pending hook won't be executed twice.
5836 hook.pending = true;
5837 }
5838 } else {
5839 self.failHook(hook, err);
5840
5841 // stop executing hooks, notify callee of hook err
5842 return fn(err);
5843 }
5844 }
5845 self.emit(constants.EVENT_HOOK_END, hook);
5846 delete hook.ctx.currentTest;
5847 next(++i);
5848 });
5849 }
5850
5851 Runner.immediately(function() {
5852 next(0);
5853 });
5854};
5855
5856/**
5857 * Run hook `name` for the given array of `suites`
5858 * in order, and callback `fn(err, errSuite)`.
5859 *
5860 * @private
5861 * @param {string} name
5862 * @param {Array} suites
5863 * @param {Function} fn
5864 */
5865Runner.prototype.hooks = function(name, suites, fn) {
5866 var self = this;
5867 var orig = this.suite;
5868
5869 function next(suite) {
5870 self.suite = suite;
5871
5872 if (!suite) {
5873 self.suite = orig;
5874 return fn();
5875 }
5876
5877 self.hook(name, function(err) {
5878 if (err) {
5879 var errSuite = self.suite;
5880 self.suite = orig;
5881 return fn(err, errSuite);
5882 }
5883
5884 next(suites.pop());
5885 });
5886 }
5887
5888 next(suites.pop());
5889};
5890
5891/**
5892 * Run hooks from the top level down.
5893 *
5894 * @param {String} name
5895 * @param {Function} fn
5896 * @private
5897 */
5898Runner.prototype.hookUp = function(name, fn) {
5899 var suites = [this.suite].concat(this.parents()).reverse();
5900 this.hooks(name, suites, fn);
5901};
5902
5903/**
5904 * Run hooks from the bottom up.
5905 *
5906 * @param {String} name
5907 * @param {Function} fn
5908 * @private
5909 */
5910Runner.prototype.hookDown = function(name, fn) {
5911 var suites = [this.suite].concat(this.parents());
5912 this.hooks(name, suites, fn);
5913};
5914
5915/**
5916 * Return an array of parent Suites from
5917 * closest to furthest.
5918 *
5919 * @return {Array}
5920 * @private
5921 */
5922Runner.prototype.parents = function() {
5923 var suite = this.suite;
5924 var suites = [];
5925 while (suite.parent) {
5926 suite = suite.parent;
5927 suites.push(suite);
5928 }
5929 return suites;
5930};
5931
5932/**
5933 * Run the current test and callback `fn(err)`.
5934 *
5935 * @param {Function} fn
5936 * @private
5937 */
5938Runner.prototype.runTest = function(fn) {
5939 var self = this;
5940 var test = this.test;
5941
5942 if (!test) {
5943 return;
5944 }
5945
5946 var suite = this.parents().reverse()[0] || this.suite;
5947 if (this.forbidOnly && suite.hasOnly()) {
5948 fn(new Error('`.only` forbidden'));
5949 return;
5950 }
5951 if (this.asyncOnly) {
5952 test.asyncOnly = true;
5953 }
5954 test.on('error', function(err) {
5955 self.fail(test, err);
5956 });
5957 if (this.allowUncaught) {
5958 test.allowUncaught = true;
5959 return test.run(fn);
5960 }
5961 try {
5962 test.run(fn);
5963 } catch (err) {
5964 fn(err);
5965 }
5966};
5967
5968/**
5969 * Run tests in the given `suite` and invoke the callback `fn()` when complete.
5970 *
5971 * @private
5972 * @param {Suite} suite
5973 * @param {Function} fn
5974 */
5975Runner.prototype.runTests = function(suite, fn) {
5976 var self = this;
5977 var tests = suite.tests.slice();
5978 var test;
5979
5980 function hookErr(_, errSuite, after) {
5981 // before/after Each hook for errSuite failed:
5982 var orig = self.suite;
5983
5984 // for failed 'after each' hook start from errSuite parent,
5985 // otherwise start from errSuite itself
5986 self.suite = after ? errSuite.parent : errSuite;
5987
5988 if (self.suite) {
5989 // call hookUp afterEach
5990 self.hookUp(HOOK_TYPE_AFTER_EACH, function(err2, errSuite2) {
5991 self.suite = orig;
5992 // some hooks may fail even now
5993 if (err2) {
5994 return hookErr(err2, errSuite2, true);
5995 }
5996 // report error suite
5997 fn(errSuite);
5998 });
5999 } else {
6000 // there is no need calling other 'after each' hooks
6001 self.suite = orig;
6002 fn(errSuite);
6003 }
6004 }
6005
6006 function next(err, errSuite) {
6007 // if we bail after first err
6008 if (self.failures && suite._bail) {
6009 tests = [];
6010 }
6011
6012 if (self._abort) {
6013 return fn();
6014 }
6015
6016 if (err) {
6017 return hookErr(err, errSuite, true);
6018 }
6019
6020 // next test
6021 test = tests.shift();
6022
6023 // all done
6024 if (!test) {
6025 return fn();
6026 }
6027
6028 // grep
6029 var match = self._grep.test(test.fullTitle());
6030 if (self._invert) {
6031 match = !match;
6032 }
6033 if (!match) {
6034 // Run immediately only if we have defined a grep. When we
6035 // define a grep — It can cause maximum callstack error if
6036 // the grep is doing a large recursive loop by neglecting
6037 // all tests. The run immediately function also comes with
6038 // a performance cost. So we don't want to run immediately
6039 // if we run the whole test suite, because running the whole
6040 // test suite don't do any immediate recursive loops. Thus,
6041 // allowing a JS runtime to breathe.
6042 if (self._grep !== self._defaultGrep) {
6043 Runner.immediately(next);
6044 } else {
6045 next();
6046 }
6047 return;
6048 }
6049
6050 if (test.isPending()) {
6051 if (self.forbidPending) {
6052 test.isPending = alwaysFalse;
6053 self.fail(test, new Error('Pending test forbidden'));
6054 delete test.isPending;
6055 } else {
6056 self.emit(constants.EVENT_TEST_PENDING, test);
6057 }
6058 self.emit(constants.EVENT_TEST_END, test);
6059 return next();
6060 }
6061
6062 // execute test and hook(s)
6063 self.emit(constants.EVENT_TEST_BEGIN, (self.test = test));
6064 self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) {
6065 if (test.isPending()) {
6066 if (self.forbidPending) {
6067 test.isPending = alwaysFalse;
6068 self.fail(test, new Error('Pending test forbidden'));
6069 delete test.isPending;
6070 } else {
6071 self.emit(constants.EVENT_TEST_PENDING, test);
6072 }
6073 self.emit(constants.EVENT_TEST_END, test);
6074 return next();
6075 }
6076 if (err) {
6077 return hookErr(err, errSuite, false);
6078 }
6079 self.currentRunnable = self.test;
6080 self.runTest(function(err) {
6081 test = self.test;
6082 if (err) {
6083 var retry = test.currentRetry();
6084 if (err instanceof Pending && self.forbidPending) {
6085 self.fail(test, new Error('Pending test forbidden'));
6086 } else if (err instanceof Pending) {
6087 test.pending = true;
6088 self.emit(constants.EVENT_TEST_PENDING, test);
6089 } else if (retry < test.retries()) {
6090 var clonedTest = test.clone();
6091 clonedTest.currentRetry(retry + 1);
6092 tests.unshift(clonedTest);
6093
6094 self.emit(constants.EVENT_TEST_RETRY, test, err);
6095
6096 // Early return + hook trigger so that it doesn't
6097 // increment the count wrong
6098 return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6099 } else {
6100 self.fail(test, err);
6101 }
6102 self.emit(constants.EVENT_TEST_END, test);
6103
6104 if (err instanceof Pending) {
6105 return next();
6106 }
6107
6108 return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6109 }
6110
6111 test.state = STATE_PASSED;
6112 self.emit(constants.EVENT_TEST_PASS, test);
6113 self.emit(constants.EVENT_TEST_END, test);
6114 self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6115 });
6116 });
6117 }
6118
6119 this.next = next;
6120 this.hookErr = hookErr;
6121 next();
6122};
6123
6124function alwaysFalse() {
6125 return false;
6126}
6127
6128/**
6129 * Run the given `suite` and invoke the callback `fn()` when complete.
6130 *
6131 * @private
6132 * @param {Suite} suite
6133 * @param {Function} fn
6134 */
6135Runner.prototype.runSuite = function(suite, fn) {
6136 var i = 0;
6137 var self = this;
6138 var total = this.grepTotal(suite);
6139 var afterAllHookCalled = false;
6140
6141 debug('run suite %s', suite.fullTitle());
6142
6143 if (!total || (self.failures && suite._bail)) {
6144 return fn();
6145 }
6146
6147 this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite));
6148
6149 function next(errSuite) {
6150 if (errSuite) {
6151 // current suite failed on a hook from errSuite
6152 if (errSuite === suite) {
6153 // if errSuite is current suite
6154 // continue to the next sibling suite
6155 return done();
6156 }
6157 // errSuite is among the parents of current suite
6158 // stop execution of errSuite and all sub-suites
6159 return done(errSuite);
6160 }
6161
6162 if (self._abort) {
6163 return done();
6164 }
6165
6166 var curr = suite.suites[i++];
6167 if (!curr) {
6168 return done();
6169 }
6170
6171 // Avoid grep neglecting large number of tests causing a
6172 // huge recursive loop and thus a maximum call stack error.
6173 // See comment in `this.runTests()` for more information.
6174 if (self._grep !== self._defaultGrep) {
6175 Runner.immediately(function() {
6176 self.runSuite(curr, next);
6177 });
6178 } else {
6179 self.runSuite(curr, next);
6180 }
6181 }
6182
6183 function done(errSuite) {
6184 self.suite = suite;
6185 self.nextSuite = next;
6186
6187 if (afterAllHookCalled) {
6188 fn(errSuite);
6189 } else {
6190 // mark that the afterAll block has been called once
6191 // and so can be skipped if there is an error in it.
6192 afterAllHookCalled = true;
6193
6194 // remove reference to test
6195 delete self.test;
6196
6197 self.hook(HOOK_TYPE_AFTER_ALL, function() {
6198 self.emit(constants.EVENT_SUITE_END, suite);
6199 fn(errSuite);
6200 });
6201 }
6202 }
6203
6204 this.nextSuite = next;
6205
6206 this.hook(HOOK_TYPE_BEFORE_ALL, function(err) {
6207 if (err) {
6208 return done();
6209 }
6210 self.runTests(suite, next);
6211 });
6212};
6213
6214/**
6215 * Handle uncaught exceptions.
6216 *
6217 * @param {Error} err
6218 * @private
6219 */
6220Runner.prototype.uncaught = function(err) {
6221 if (err) {
6222 debug('uncaught exception %O', err);
6223 } else {
6224 debug('uncaught undefined/falsy exception');
6225 err = createInvalidExceptionError(
6226 'Caught falsy/undefined exception which would otherwise be uncaught. No stack trace found; try a debugger',
6227 err
6228 );
6229 }
6230
6231 if (!isError(err)) {
6232 err = thrown2Error(err);
6233 }
6234 err.uncaught = true;
6235
6236 var runnable = this.currentRunnable;
6237
6238 if (!runnable) {
6239 runnable = new Runnable('Uncaught error outside test suite');
6240 runnable.parent = this.suite;
6241
6242 if (this.started) {
6243 this.fail(runnable, err);
6244 } else {
6245 // Can't recover from this failure
6246 this.emit(constants.EVENT_RUN_BEGIN);
6247 this.fail(runnable, err);
6248 this.emit(constants.EVENT_RUN_END);
6249 }
6250
6251 return;
6252 }
6253
6254 runnable.clearTimeout();
6255
6256 // Ignore errors if already failed or pending
6257 // See #3226
6258 if (runnable.isFailed() || runnable.isPending()) {
6259 return;
6260 }
6261 // we cannot recover gracefully if a Runnable has already passed
6262 // then fails asynchronously
6263 var alreadyPassed = runnable.isPassed();
6264 // this will change the state to "failed" regardless of the current value
6265 this.fail(runnable, err);
6266 if (!alreadyPassed) {
6267 // recover from test
6268 if (runnable.type === constants.EVENT_TEST_BEGIN) {
6269 this.emit(constants.EVENT_TEST_END, runnable);
6270 this.hookUp(HOOK_TYPE_AFTER_EACH, this.next);
6271 return;
6272 }
6273 debug(runnable);
6274
6275 // recover from hooks
6276 var errSuite = this.suite;
6277
6278 // XXX how about a less awful way to determine this?
6279 // if hook failure is in afterEach block
6280 if (runnable.fullTitle().indexOf('after each') > -1) {
6281 return this.hookErr(err, errSuite, true);
6282 }
6283 // if hook failure is in beforeEach block
6284 if (runnable.fullTitle().indexOf('before each') > -1) {
6285 return this.hookErr(err, errSuite, false);
6286 }
6287 // if hook failure is in after or before blocks
6288 return this.nextSuite(errSuite);
6289 }
6290
6291 // bail
6292 this.emit(constants.EVENT_RUN_END);
6293};
6294
6295/**
6296 * Run the root suite and invoke `fn(failures)`
6297 * on completion.
6298 *
6299 * @public
6300 * @memberof Runner
6301 * @param {Function} fn
6302 * @return {Runner} Runner instance.
6303 */
6304Runner.prototype.run = function(fn) {
6305 var self = this;
6306 var rootSuite = this.suite;
6307
6308 fn = fn || function() {};
6309
6310 function uncaught(err) {
6311 self.uncaught(err);
6312 }
6313
6314 function start() {
6315 // If there is an `only` filter
6316 if (rootSuite.hasOnly()) {
6317 rootSuite.filterOnly();
6318 }
6319 self.started = true;
6320 if (self._delay) {
6321 self.emit(constants.EVENT_DELAY_END);
6322 }
6323 self.emit(constants.EVENT_RUN_BEGIN);
6324
6325 self.runSuite(rootSuite, function() {
6326 debug('finished running');
6327 self.emit(constants.EVENT_RUN_END);
6328 });
6329 }
6330
6331 debug(constants.EVENT_RUN_BEGIN);
6332
6333 // references cleanup to avoid memory leaks
6334 this.on(constants.EVENT_SUITE_END, function(suite) {
6335 suite.cleanReferences();
6336 });
6337
6338 // callback
6339 this.on(constants.EVENT_RUN_END, function() {
6340 debug(constants.EVENT_RUN_END);
6341 process.removeListener('uncaughtException', uncaught);
6342 fn(self.failures);
6343 });
6344
6345 // uncaught exception
6346 process.on('uncaughtException', uncaught);
6347
6348 if (this._delay) {
6349 // for reporters, I guess.
6350 // might be nice to debounce some dots while we wait.
6351 this.emit(constants.EVENT_DELAY_BEGIN, rootSuite);
6352 rootSuite.once(EVENT_ROOT_SUITE_RUN, start);
6353 } else {
6354 start();
6355 }
6356
6357 return this;
6358};
6359
6360/**
6361 * Cleanly abort execution.
6362 *
6363 * @memberof Runner
6364 * @public
6365 * @return {Runner} Runner instance.
6366 */
6367Runner.prototype.abort = function() {
6368 debug('aborting');
6369 this._abort = true;
6370
6371 return this;
6372};
6373
6374/**
6375 * Filter leaks with the given globals flagged as `ok`.
6376 *
6377 * @private
6378 * @param {Array} ok
6379 * @param {Array} globals
6380 * @return {Array}
6381 */
6382function filterLeaks(ok, globals) {
6383 return globals.filter(function(key) {
6384 // Firefox and Chrome exposes iframes as index inside the window object
6385 if (/^\d+/.test(key)) {
6386 return false;
6387 }
6388
6389 // in firefox
6390 // if runner runs in an iframe, this iframe's window.getInterface method
6391 // not init at first it is assigned in some seconds
6392 if (global.navigator && /^getInterface/.test(key)) {
6393 return false;
6394 }
6395
6396 // an iframe could be approached by window[iframeIndex]
6397 // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
6398 if (global.navigator && /^\d+/.test(key)) {
6399 return false;
6400 }
6401
6402 // Opera and IE expose global variables for HTML element IDs (issue #243)
6403 if (/^mocha-/.test(key)) {
6404 return false;
6405 }
6406
6407 var matched = ok.filter(function(ok) {
6408 if (~ok.indexOf('*')) {
6409 return key.indexOf(ok.split('*')[0]) === 0;
6410 }
6411 return key === ok;
6412 });
6413 return !matched.length && (!global.navigator || key !== 'onerror');
6414 });
6415}
6416
6417/**
6418 * Check if argument is an instance of Error object or a duck-typed equivalent.
6419 *
6420 * @private
6421 * @param {Object} err - object to check
6422 * @param {string} err.message - error message
6423 * @returns {boolean}
6424 */
6425function isError(err) {
6426 return err instanceof Error || (err && typeof err.message === 'string');
6427}
6428
6429/**
6430 *
6431 * Converts thrown non-extensible type into proper Error.
6432 *
6433 * @private
6434 * @param {*} thrown - Non-extensible type thrown by code
6435 * @return {Error}
6436 */
6437function thrown2Error(err) {
6438 return new Error(
6439 'the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'
6440 );
6441}
6442
6443/**
6444 * Array of globals dependent on the environment.
6445 *
6446 * @return {Array}
6447 * @deprecated
6448 * @todo remove; long since unsupported
6449 * @private
6450 */
6451function extraGlobals() {
6452 if (typeof process === 'object' && typeof process.version === 'string') {
6453 var parts = process.version.split('.');
6454 var nodeVersion = parts.reduce(function(a, v) {
6455 return (a << 8) | v;
6456 });
6457
6458 // 'errno' was renamed to process._errno in v0.9.11.
6459 if (nodeVersion < 0x00090b) {
6460 return ['errno'];
6461 }
6462 }
6463
6464 return [];
6465}
6466
6467Runner.constants = constants;
6468
6469/**
6470 * Node.js' `EventEmitter`
6471 * @external EventEmitter
6472 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter}
6473 */
6474
6475}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
6476},{"./errors":6,"./pending":16,"./runnable":33,"./suite":36,"./utils":38,"_process":68,"debug":45,"events":50,"util":88}],35:[function(require,module,exports){
6477(function (global){
6478'use strict';
6479
6480/**
6481 * Provides a factory function for a {@link StatsCollector} object.
6482 * @module
6483 */
6484
6485var constants = require('./runner').constants;
6486var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
6487var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
6488var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
6489var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
6490var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
6491var EVENT_RUN_END = constants.EVENT_RUN_END;
6492var EVENT_TEST_END = constants.EVENT_TEST_END;
6493
6494/**
6495 * Test statistics collector.
6496 *
6497 * @public
6498 * @typedef {Object} StatsCollector
6499 * @property {number} suites - integer count of suites run.
6500 * @property {number} tests - integer count of tests run.
6501 * @property {number} passes - integer count of passing tests.
6502 * @property {number} pending - integer count of pending tests.
6503 * @property {number} failures - integer count of failed tests.
6504 * @property {Date} start - time when testing began.
6505 * @property {Date} end - time when testing concluded.
6506 * @property {number} duration - number of msecs that testing took.
6507 */
6508
6509var Date = global.Date;
6510
6511/**
6512 * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
6513 *
6514 * @private
6515 * @param {Runner} runner - Runner instance
6516 * @throws {TypeError} If falsy `runner`
6517 */
6518function createStatsCollector(runner) {
6519 /**
6520 * @type StatsCollector
6521 */
6522 var stats = {
6523 suites: 0,
6524 tests: 0,
6525 passes: 0,
6526 pending: 0,
6527 failures: 0
6528 };
6529
6530 if (!runner) {
6531 throw new TypeError('Missing runner argument');
6532 }
6533
6534 runner.stats = stats;
6535
6536 runner.once(EVENT_RUN_BEGIN, function() {
6537 stats.start = new Date();
6538 });
6539 runner.on(EVENT_SUITE_BEGIN, function(suite) {
6540 suite.root || stats.suites++;
6541 });
6542 runner.on(EVENT_TEST_PASS, function() {
6543 stats.passes++;
6544 });
6545 runner.on(EVENT_TEST_FAIL, function() {
6546 stats.failures++;
6547 });
6548 runner.on(EVENT_TEST_PENDING, function() {
6549 stats.pending++;
6550 });
6551 runner.on(EVENT_TEST_END, function() {
6552 stats.tests++;
6553 });
6554 runner.once(EVENT_RUN_END, function() {
6555 stats.end = new Date();
6556 stats.duration = stats.end - stats.start;
6557 });
6558}
6559
6560module.exports = createStatsCollector;
6561
6562}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
6563},{"./runner":34}],36:[function(require,module,exports){
6564'use strict';
6565
6566/**
6567 * Module dependencies.
6568 */
6569var EventEmitter = require('events').EventEmitter;
6570var Hook = require('./hook');
6571var utils = require('./utils');
6572var inherits = utils.inherits;
6573var debug = require('debug')('mocha:suite');
6574var milliseconds = require('ms');
6575var errors = require('./errors');
6576var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
6577
6578/**
6579 * Expose `Suite`.
6580 */
6581
6582exports = module.exports = Suite;
6583
6584/**
6585 * Create a new `Suite` with the given `title` and parent `Suite`.
6586 *
6587 * @public
6588 * @param {Suite} parent - Parent suite (required!)
6589 * @param {string} title - Title
6590 * @return {Suite}
6591 */
6592Suite.create = function(parent, title) {
6593 var suite = new Suite(title, parent.ctx);
6594 suite.parent = parent;
6595 title = suite.fullTitle();
6596 parent.addSuite(suite);
6597 return suite;
6598};
6599
6600/**
6601 * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`.
6602 *
6603 * @public
6604 * @class
6605 * @extends EventEmitter
6606 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter}
6607 * @param {string} title - Suite title.
6608 * @param {Context} parentContext - Parent context instance.
6609 * @param {boolean} [isRoot=false] - Whether this is the root suite.
6610 */
6611function Suite(title, parentContext, isRoot) {
6612 if (!utils.isString(title)) {
6613 throw createInvalidArgumentTypeError(
6614 'Suite argument "title" must be a string. Received type "' +
6615 typeof title +
6616 '"',
6617 'title',
6618 'string'
6619 );
6620 }
6621 this.title = title;
6622 function Context() {}
6623 Context.prototype = parentContext;
6624 this.ctx = new Context();
6625 this.suites = [];
6626 this.tests = [];
6627 this.pending = false;
6628 this._beforeEach = [];
6629 this._beforeAll = [];
6630 this._afterEach = [];
6631 this._afterAll = [];
6632 this.root = isRoot === true;
6633 this._timeout = 2000;
6634 this._enableTimeouts = true;
6635 this._slow = 75;
6636 this._bail = false;
6637 this._retries = -1;
6638 this._onlyTests = [];
6639 this._onlySuites = [];
6640 this.delayed = false;
6641
6642 this.on('newListener', function(event) {
6643 if (deprecatedEvents[event]) {
6644 utils.deprecate(
6645 'Event "' +
6646 event +
6647 '" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'
6648 );
6649 }
6650 });
6651}
6652
6653/**
6654 * Inherit from `EventEmitter.prototype`.
6655 */
6656inherits(Suite, EventEmitter);
6657
6658/**
6659 * Return a clone of this `Suite`.
6660 *
6661 * @private
6662 * @return {Suite}
6663 */
6664Suite.prototype.clone = function() {
6665 var suite = new Suite(this.title);
6666 debug('clone');
6667 suite.ctx = this.ctx;
6668 suite.timeout(this.timeout());
6669 suite.retries(this.retries());
6670 suite.enableTimeouts(this.enableTimeouts());
6671 suite.slow(this.slow());
6672 suite.bail(this.bail());
6673 return suite;
6674};
6675
6676/**
6677 * Set or get timeout `ms` or short-hand such as "2s".
6678 *
6679 * @private
6680 * @param {number|string} ms
6681 * @return {Suite|number} for chaining
6682 */
6683Suite.prototype.timeout = function(ms) {
6684 if (!arguments.length) {
6685 return this._timeout;
6686 }
6687 if (ms.toString() === '0') {
6688 this._enableTimeouts = false;
6689 }
6690 if (typeof ms === 'string') {
6691 ms = milliseconds(ms);
6692 }
6693 debug('timeout %d', ms);
6694 this._timeout = parseInt(ms, 10);
6695 return this;
6696};
6697
6698/**
6699 * Set or get number of times to retry a failed test.
6700 *
6701 * @private
6702 * @param {number|string} n
6703 * @return {Suite|number} for chaining
6704 */
6705Suite.prototype.retries = function(n) {
6706 if (!arguments.length) {
6707 return this._retries;
6708 }
6709 debug('retries %d', n);
6710 this._retries = parseInt(n, 10) || 0;
6711 return this;
6712};
6713
6714/**
6715 * Set or get timeout to `enabled`.
6716 *
6717 * @private
6718 * @param {boolean} enabled
6719 * @return {Suite|boolean} self or enabled
6720 */
6721Suite.prototype.enableTimeouts = function(enabled) {
6722 if (!arguments.length) {
6723 return this._enableTimeouts;
6724 }
6725 debug('enableTimeouts %s', enabled);
6726 this._enableTimeouts = enabled;
6727 return this;
6728};
6729
6730/**
6731 * Set or get slow `ms` or short-hand such as "2s".
6732 *
6733 * @private
6734 * @param {number|string} ms
6735 * @return {Suite|number} for chaining
6736 */
6737Suite.prototype.slow = function(ms) {
6738 if (!arguments.length) {
6739 return this._slow;
6740 }
6741 if (typeof ms === 'string') {
6742 ms = milliseconds(ms);
6743 }
6744 debug('slow %d', ms);
6745 this._slow = ms;
6746 return this;
6747};
6748
6749/**
6750 * Set or get whether to bail after first error.
6751 *
6752 * @private
6753 * @param {boolean} bail
6754 * @return {Suite|number} for chaining
6755 */
6756Suite.prototype.bail = function(bail) {
6757 if (!arguments.length) {
6758 return this._bail;
6759 }
6760 debug('bail %s', bail);
6761 this._bail = bail;
6762 return this;
6763};
6764
6765/**
6766 * Check if this suite or its parent suite is marked as pending.
6767 *
6768 * @private
6769 */
6770Suite.prototype.isPending = function() {
6771 return this.pending || (this.parent && this.parent.isPending());
6772};
6773
6774/**
6775 * Generic hook-creator.
6776 * @private
6777 * @param {string} title - Title of hook
6778 * @param {Function} fn - Hook callback
6779 * @returns {Hook} A new hook
6780 */
6781Suite.prototype._createHook = function(title, fn) {
6782 var hook = new Hook(title, fn);
6783 hook.parent = this;
6784 hook.timeout(this.timeout());
6785 hook.retries(this.retries());
6786 hook.enableTimeouts(this.enableTimeouts());
6787 hook.slow(this.slow());
6788 hook.ctx = this.ctx;
6789 hook.file = this.file;
6790 return hook;
6791};
6792
6793/**
6794 * Run `fn(test[, done])` before running tests.
6795 *
6796 * @private
6797 * @param {string} title
6798 * @param {Function} fn
6799 * @return {Suite} for chaining
6800 */
6801Suite.prototype.beforeAll = function(title, fn) {
6802 if (this.isPending()) {
6803 return this;
6804 }
6805 if (typeof title === 'function') {
6806 fn = title;
6807 title = fn.name;
6808 }
6809 title = '"before all" hook' + (title ? ': ' + title : '');
6810
6811 var hook = this._createHook(title, fn);
6812 this._beforeAll.push(hook);
6813 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
6814 return this;
6815};
6816
6817/**
6818 * Run `fn(test[, done])` after running tests.
6819 *
6820 * @private
6821 * @param {string} title
6822 * @param {Function} fn
6823 * @return {Suite} for chaining
6824 */
6825Suite.prototype.afterAll = function(title, fn) {
6826 if (this.isPending()) {
6827 return this;
6828 }
6829 if (typeof title === 'function') {
6830 fn = title;
6831 title = fn.name;
6832 }
6833 title = '"after all" hook' + (title ? ': ' + title : '');
6834
6835 var hook = this._createHook(title, fn);
6836 this._afterAll.push(hook);
6837 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
6838 return this;
6839};
6840
6841/**
6842 * Run `fn(test[, done])` before each test case.
6843 *
6844 * @private
6845 * @param {string} title
6846 * @param {Function} fn
6847 * @return {Suite} for chaining
6848 */
6849Suite.prototype.beforeEach = function(title, fn) {
6850 if (this.isPending()) {
6851 return this;
6852 }
6853 if (typeof title === 'function') {
6854 fn = title;
6855 title = fn.name;
6856 }
6857 title = '"before each" hook' + (title ? ': ' + title : '');
6858
6859 var hook = this._createHook(title, fn);
6860 this._beforeEach.push(hook);
6861 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
6862 return this;
6863};
6864
6865/**
6866 * Run `fn(test[, done])` after each test case.
6867 *
6868 * @private
6869 * @param {string} title
6870 * @param {Function} fn
6871 * @return {Suite} for chaining
6872 */
6873Suite.prototype.afterEach = function(title, fn) {
6874 if (this.isPending()) {
6875 return this;
6876 }
6877 if (typeof title === 'function') {
6878 fn = title;
6879 title = fn.name;
6880 }
6881 title = '"after each" hook' + (title ? ': ' + title : '');
6882
6883 var hook = this._createHook(title, fn);
6884 this._afterEach.push(hook);
6885 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
6886 return this;
6887};
6888
6889/**
6890 * Add a test `suite`.
6891 *
6892 * @private
6893 * @param {Suite} suite
6894 * @return {Suite} for chaining
6895 */
6896Suite.prototype.addSuite = function(suite) {
6897 suite.parent = this;
6898 suite.root = false;
6899 suite.timeout(this.timeout());
6900 suite.retries(this.retries());
6901 suite.enableTimeouts(this.enableTimeouts());
6902 suite.slow(this.slow());
6903 suite.bail(this.bail());
6904 this.suites.push(suite);
6905 this.emit(constants.EVENT_SUITE_ADD_SUITE, suite);
6906 return this;
6907};
6908
6909/**
6910 * Add a `test` to this suite.
6911 *
6912 * @private
6913 * @param {Test} test
6914 * @return {Suite} for chaining
6915 */
6916Suite.prototype.addTest = function(test) {
6917 test.parent = this;
6918 test.timeout(this.timeout());
6919 test.retries(this.retries());
6920 test.enableTimeouts(this.enableTimeouts());
6921 test.slow(this.slow());
6922 test.ctx = this.ctx;
6923 this.tests.push(test);
6924 this.emit(constants.EVENT_SUITE_ADD_TEST, test);
6925 return this;
6926};
6927
6928/**
6929 * Return the full title generated by recursively concatenating the parent's
6930 * full title.
6931 *
6932 * @memberof Suite
6933 * @public
6934 * @return {string}
6935 */
6936Suite.prototype.fullTitle = function() {
6937 return this.titlePath().join(' ');
6938};
6939
6940/**
6941 * Return the title path generated by recursively concatenating the parent's
6942 * title path.
6943 *
6944 * @memberof Suite
6945 * @public
6946 * @return {string}
6947 */
6948Suite.prototype.titlePath = function() {
6949 var result = [];
6950 if (this.parent) {
6951 result = result.concat(this.parent.titlePath());
6952 }
6953 if (!this.root) {
6954 result.push(this.title);
6955 }
6956 return result;
6957};
6958
6959/**
6960 * Return the total number of tests.
6961 *
6962 * @memberof Suite
6963 * @public
6964 * @return {number}
6965 */
6966Suite.prototype.total = function() {
6967 return (
6968 this.suites.reduce(function(sum, suite) {
6969 return sum + suite.total();
6970 }, 0) + this.tests.length
6971 );
6972};
6973
6974/**
6975 * Iterates through each suite recursively to find all tests. Applies a
6976 * function in the format `fn(test)`.
6977 *
6978 * @private
6979 * @param {Function} fn
6980 * @return {Suite}
6981 */
6982Suite.prototype.eachTest = function(fn) {
6983 this.tests.forEach(fn);
6984 this.suites.forEach(function(suite) {
6985 suite.eachTest(fn);
6986 });
6987 return this;
6988};
6989
6990/**
6991 * This will run the root suite if we happen to be running in delayed mode.
6992 * @private
6993 */
6994Suite.prototype.run = function run() {
6995 if (this.root) {
6996 this.emit(constants.EVENT_ROOT_SUITE_RUN);
6997 }
6998};
6999
7000/**
7001 * Determines whether a suite has an `only` test or suite as a descendant.
7002 *
7003 * @private
7004 * @returns {Boolean}
7005 */
7006Suite.prototype.hasOnly = function hasOnly() {
7007 return (
7008 this._onlyTests.length > 0 ||
7009 this._onlySuites.length > 0 ||
7010 this.suites.some(function(suite) {
7011 return suite.hasOnly();
7012 })
7013 );
7014};
7015
7016/**
7017 * Filter suites based on `isOnly` logic.
7018 *
7019 * @private
7020 * @returns {Boolean}
7021 */
7022Suite.prototype.filterOnly = function filterOnly() {
7023 if (this._onlyTests.length) {
7024 // If the suite contains `only` tests, run those and ignore any nested suites.
7025 this.tests = this._onlyTests;
7026 this.suites = [];
7027 } else {
7028 // Otherwise, do not run any of the tests in this suite.
7029 this.tests = [];
7030 this._onlySuites.forEach(function(onlySuite) {
7031 // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
7032 // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
7033 if (onlySuite.hasOnly()) {
7034 onlySuite.filterOnly();
7035 }
7036 });
7037 // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
7038 var onlySuites = this._onlySuites;
7039 this.suites = this.suites.filter(function(childSuite) {
7040 return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
7041 });
7042 }
7043 // Keep the suite only if there is something to run
7044 return this.tests.length > 0 || this.suites.length > 0;
7045};
7046
7047/**
7048 * Adds a suite to the list of subsuites marked `only`.
7049 *
7050 * @private
7051 * @param {Suite} suite
7052 */
7053Suite.prototype.appendOnlySuite = function(suite) {
7054 this._onlySuites.push(suite);
7055};
7056
7057/**
7058 * Adds a test to the list of tests marked `only`.
7059 *
7060 * @private
7061 * @param {Test} test
7062 */
7063Suite.prototype.appendOnlyTest = function(test) {
7064 this._onlyTests.push(test);
7065};
7066
7067/**
7068 * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants.
7069 * @private
7070 */
7071Suite.prototype.getHooks = function getHooks(name) {
7072 return this['_' + name];
7073};
7074
7075/**
7076 * Cleans up the references to all the deferred functions
7077 * (before/after/beforeEach/afterEach) and tests of a Suite.
7078 * These must be deleted otherwise a memory leak can happen,
7079 * as those functions may reference variables from closures,
7080 * thus those variables can never be garbage collected as long
7081 * as the deferred functions exist.
7082 *
7083 * @private
7084 */
7085Suite.prototype.cleanReferences = function cleanReferences() {
7086 function cleanArrReferences(arr) {
7087 for (var i = 0; i < arr.length; i++) {
7088 delete arr[i].fn;
7089 }
7090 }
7091
7092 if (Array.isArray(this._beforeAll)) {
7093 cleanArrReferences(this._beforeAll);
7094 }
7095
7096 if (Array.isArray(this._beforeEach)) {
7097 cleanArrReferences(this._beforeEach);
7098 }
7099
7100 if (Array.isArray(this._afterAll)) {
7101 cleanArrReferences(this._afterAll);
7102 }
7103
7104 if (Array.isArray(this._afterEach)) {
7105 cleanArrReferences(this._afterEach);
7106 }
7107
7108 for (var i = 0; i < this.tests.length; i++) {
7109 delete this.tests[i].fn;
7110 }
7111};
7112
7113var constants = utils.defineConstants(
7114 /**
7115 * {@link Suite}-related constants.
7116 * @public
7117 * @memberof Suite
7118 * @alias constants
7119 * @readonly
7120 * @static
7121 * @enum {string}
7122 */
7123 {
7124 /**
7125 * Event emitted after a test file has been loaded Not emitted in browser.
7126 */
7127 EVENT_FILE_POST_REQUIRE: 'post-require',
7128 /**
7129 * Event emitted before a test file has been loaded. In browser, this is emitted once an interface has been selected.
7130 */
7131 EVENT_FILE_PRE_REQUIRE: 'pre-require',
7132 /**
7133 * Event emitted immediately after a test file has been loaded. Not emitted in browser.
7134 */
7135 EVENT_FILE_REQUIRE: 'require',
7136 /**
7137 * Event emitted when `global.run()` is called (use with `delay` option)
7138 */
7139 EVENT_ROOT_SUITE_RUN: 'run',
7140
7141 /**
7142 * Namespace for collection of a `Suite`'s "after all" hooks
7143 */
7144 HOOK_TYPE_AFTER_ALL: 'afterAll',
7145 /**
7146 * Namespace for collection of a `Suite`'s "after each" hooks
7147 */
7148 HOOK_TYPE_AFTER_EACH: 'afterEach',
7149 /**
7150 * Namespace for collection of a `Suite`'s "before all" hooks
7151 */
7152 HOOK_TYPE_BEFORE_ALL: 'beforeAll',
7153 /**
7154 * Namespace for collection of a `Suite`'s "before all" hooks
7155 */
7156 HOOK_TYPE_BEFORE_EACH: 'beforeEach',
7157
7158 // the following events are all deprecated
7159
7160 /**
7161 * Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated
7162 */
7163 EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
7164 /**
7165 * Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated
7166 */
7167 EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
7168 /**
7169 * Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated
7170 */
7171 EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
7172 /**
7173 * Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated
7174 */
7175 EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
7176 /**
7177 * Emitted after a child `Suite` has been added to a `Suite`. Deprecated
7178 */
7179 EVENT_SUITE_ADD_SUITE: 'suite',
7180 /**
7181 * Emitted after a `Test` has been added to a `Suite`. Deprecated
7182 */
7183 EVENT_SUITE_ADD_TEST: 'test'
7184 }
7185);
7186
7187/**
7188 * @summary There are no known use cases for these events.
7189 * @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`.
7190 * @todo Remove eventually
7191 * @type {Object<string,boolean>}
7192 * @ignore
7193 */
7194var deprecatedEvents = Object.keys(constants)
7195 .filter(function(constant) {
7196 return constant.substring(0, 15) === 'EVENT_SUITE_ADD';
7197 })
7198 .reduce(function(acc, constant) {
7199 acc[constants[constant]] = true;
7200 return acc;
7201 }, utils.createMap());
7202
7203Suite.constants = constants;
7204
7205},{"./errors":6,"./hook":7,"./utils":38,"debug":45,"events":50,"ms":60}],37:[function(require,module,exports){
7206'use strict';
7207var Runnable = require('./runnable');
7208var utils = require('./utils');
7209var errors = require('./errors');
7210var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
7211var isString = utils.isString;
7212
7213module.exports = Test;
7214
7215/**
7216 * Initialize a new `Test` with the given `title` and callback `fn`.
7217 *
7218 * @public
7219 * @class
7220 * @extends Runnable
7221 * @param {String} title - Test title (required)
7222 * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
7223 */
7224function Test(title, fn) {
7225 if (!isString(title)) {
7226 throw createInvalidArgumentTypeError(
7227 'Test argument "title" should be a string. Received type "' +
7228 typeof title +
7229 '"',
7230 'title',
7231 'string'
7232 );
7233 }
7234 Runnable.call(this, title, fn);
7235 this.pending = !fn;
7236 this.type = 'test';
7237}
7238
7239/**
7240 * Inherit from `Runnable.prototype`.
7241 */
7242utils.inherits(Test, Runnable);
7243
7244Test.prototype.clone = function() {
7245 var test = new Test(this.title, this.fn);
7246 test.timeout(this.timeout());
7247 test.slow(this.slow());
7248 test.enableTimeouts(this.enableTimeouts());
7249 test.retries(this.retries());
7250 test.currentRetry(this.currentRetry());
7251 test.globals(this.globals());
7252 test.parent = this.parent;
7253 test.file = this.file;
7254 test.ctx = this.ctx;
7255 return test;
7256};
7257
7258},{"./errors":6,"./runnable":33,"./utils":38}],38:[function(require,module,exports){
7259(function (process,Buffer){
7260'use strict';
7261
7262/**
7263 * Various utility functions used throughout Mocha's codebase.
7264 * @module utils
7265 */
7266
7267/**
7268 * Module dependencies.
7269 */
7270
7271var fs = require('fs');
7272var path = require('path');
7273var util = require('util');
7274var glob = require('glob');
7275var he = require('he');
7276var errors = require('./errors');
7277var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError;
7278var createMissingArgumentError = errors.createMissingArgumentError;
7279
7280var assign = (exports.assign = require('object.assign').getPolyfill());
7281
7282/**
7283 * Inherit the prototype methods from one constructor into another.
7284 *
7285 * @param {function} ctor - Constructor function which needs to inherit the
7286 * prototype.
7287 * @param {function} superCtor - Constructor function to inherit prototype from.
7288 * @throws {TypeError} if either constructor is null, or if super constructor
7289 * lacks a prototype.
7290 */
7291exports.inherits = util.inherits;
7292
7293/**
7294 * Escape special characters in the given string of html.
7295 *
7296 * @private
7297 * @param {string} html
7298 * @return {string}
7299 */
7300exports.escape = function(html) {
7301 return he.encode(String(html), {useNamedReferences: false});
7302};
7303
7304/**
7305 * Test if the given obj is type of string.
7306 *
7307 * @private
7308 * @param {Object} obj
7309 * @return {boolean}
7310 */
7311exports.isString = function(obj) {
7312 return typeof obj === 'string';
7313};
7314
7315/**
7316 * Watch the given `files` for changes
7317 * and invoke `fn(file)` on modification.
7318 *
7319 * @private
7320 * @param {Array} files
7321 * @param {Function} fn
7322 */
7323exports.watch = function(files, fn) {
7324 var options = {interval: 100};
7325 var debug = require('debug')('mocha:watch');
7326 files.forEach(function(file) {
7327 debug('file %s', file);
7328 fs.watchFile(file, options, function(curr, prev) {
7329 if (prev.mtime < curr.mtime) {
7330 fn(file);
7331 }
7332 });
7333 });
7334};
7335
7336/**
7337 * Predicate to screen `pathname` for further consideration.
7338 *
7339 * @description
7340 * Returns <code>false</code> for pathname referencing:
7341 * <ul>
7342 * <li>'npm' package installation directory
7343 * <li>'git' version control directory
7344 * </ul>
7345 *
7346 * @private
7347 * @param {string} pathname - File or directory name to screen
7348 * @return {boolean} whether pathname should be further considered
7349 * @example
7350 * ['node_modules', 'test.js'].filter(considerFurther); // => ['test.js']
7351 */
7352function considerFurther(pathname) {
7353 var ignore = ['node_modules', '.git'];
7354
7355 return !~ignore.indexOf(pathname);
7356}
7357
7358/**
7359 * Lookup files in the given `dir`.
7360 *
7361 * @description
7362 * Filenames are returned in _traversal_ order by the OS/filesystem.
7363 * **Make no assumption that the names will be sorted in any fashion.**
7364 *
7365 * @private
7366 * @param {string} dir
7367 * @param {string[]} [exts=['js']]
7368 * @param {Array} [ret=[]]
7369 * @return {Array}
7370 */
7371exports.files = function(dir, exts, ret) {
7372 ret = ret || [];
7373 exts = exts || ['js'];
7374
7375 fs.readdirSync(dir)
7376 .filter(considerFurther)
7377 .forEach(function(dirent) {
7378 var pathname = path.join(dir, dirent);
7379 if (fs.lstatSync(pathname).isDirectory()) {
7380 exports.files(pathname, exts, ret);
7381 } else if (hasMatchingExtname(pathname, exts)) {
7382 ret.push(pathname);
7383 }
7384 });
7385
7386 return ret;
7387};
7388
7389/**
7390 * Compute a slug from the given `str`.
7391 *
7392 * @private
7393 * @param {string} str
7394 * @return {string}
7395 */
7396exports.slug = function(str) {
7397 return str
7398 .toLowerCase()
7399 .replace(/ +/g, '-')
7400 .replace(/[^-\w]/g, '');
7401};
7402
7403/**
7404 * Strip the function definition from `str`, and re-indent for pre whitespace.
7405 *
7406 * @param {string} str
7407 * @return {string}
7408 */
7409exports.clean = function(str) {
7410 str = str
7411 .replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
7412 .replace(/^\uFEFF/, '')
7413 // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
7414 .replace(
7415 /^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
7416 '$1$2$3'
7417 );
7418
7419 var spaces = str.match(/^\n?( *)/)[1].length;
7420 var tabs = str.match(/^\n?(\t*)/)[1].length;
7421 var re = new RegExp(
7422 '^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
7423 'gm'
7424 );
7425
7426 str = str.replace(re, '');
7427
7428 return str.trim();
7429};
7430
7431/**
7432 * Parse the given `qs`.
7433 *
7434 * @private
7435 * @param {string} qs
7436 * @return {Object}
7437 */
7438exports.parseQuery = function(qs) {
7439 return qs
7440 .replace('?', '')
7441 .split('&')
7442 .reduce(function(obj, pair) {
7443 var i = pair.indexOf('=');
7444 var key = pair.slice(0, i);
7445 var val = pair.slice(++i);
7446
7447 // Due to how the URLSearchParams API treats spaces
7448 obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
7449
7450 return obj;
7451 }, {});
7452};
7453
7454/**
7455 * Highlight the given string of `js`.
7456 *
7457 * @private
7458 * @param {string} js
7459 * @return {string}
7460 */
7461function highlight(js) {
7462 return js
7463 .replace(/</g, '&lt;')
7464 .replace(/>/g, '&gt;')
7465 .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
7466 .replace(/('.*?')/gm, '<span class="string">$1</span>')
7467 .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
7468 .replace(/(\d+)/gm, '<span class="number">$1</span>')
7469 .replace(
7470 /\bnew[ \t]+(\w+)/gm,
7471 '<span class="keyword">new</span> <span class="init">$1</span>'
7472 )
7473 .replace(
7474 /\b(function|new|throw|return|var|if|else)\b/gm,
7475 '<span class="keyword">$1</span>'
7476 );
7477}
7478
7479/**
7480 * Highlight the contents of tag `name`.
7481 *
7482 * @private
7483 * @param {string} name
7484 */
7485exports.highlightTags = function(name) {
7486 var code = document.getElementById('mocha').getElementsByTagName(name);
7487 for (var i = 0, len = code.length; i < len; ++i) {
7488 code[i].innerHTML = highlight(code[i].innerHTML);
7489 }
7490};
7491
7492/**
7493 * If a value could have properties, and has none, this function is called,
7494 * which returns a string representation of the empty value.
7495 *
7496 * Functions w/ no properties return `'[Function]'`
7497 * Arrays w/ length === 0 return `'[]'`
7498 * Objects w/ no properties return `'{}'`
7499 * All else: return result of `value.toString()`
7500 *
7501 * @private
7502 * @param {*} value The value to inspect.
7503 * @param {string} typeHint The type of the value
7504 * @returns {string}
7505 */
7506function emptyRepresentation(value, typeHint) {
7507 switch (typeHint) {
7508 case 'function':
7509 return '[Function]';
7510 case 'object':
7511 return '{}';
7512 case 'array':
7513 return '[]';
7514 default:
7515 return value.toString();
7516 }
7517}
7518
7519/**
7520 * Takes some variable and asks `Object.prototype.toString()` what it thinks it
7521 * is.
7522 *
7523 * @private
7524 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
7525 * @param {*} value The value to test.
7526 * @returns {string} Computed type
7527 * @example
7528 * type({}) // 'object'
7529 * type([]) // 'array'
7530 * type(1) // 'number'
7531 * type(false) // 'boolean'
7532 * type(Infinity) // 'number'
7533 * type(null) // 'null'
7534 * type(new Date()) // 'date'
7535 * type(/foo/) // 'regexp'
7536 * type('type') // 'string'
7537 * type(global) // 'global'
7538 * type(new String('foo') // 'object'
7539 */
7540var type = (exports.type = function type(value) {
7541 if (value === undefined) {
7542 return 'undefined';
7543 } else if (value === null) {
7544 return 'null';
7545 } else if (Buffer.isBuffer(value)) {
7546 return 'buffer';
7547 }
7548 return Object.prototype.toString
7549 .call(value)
7550 .replace(/^\[.+\s(.+?)]$/, '$1')
7551 .toLowerCase();
7552});
7553
7554/**
7555 * Stringify `value`. Different behavior depending on type of value:
7556 *
7557 * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
7558 * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
7559 * - If `value` is an *empty* object, function, or array, return result of function
7560 * {@link emptyRepresentation}.
7561 * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
7562 * JSON.stringify().
7563 *
7564 * @private
7565 * @see exports.type
7566 * @param {*} value
7567 * @return {string}
7568 */
7569exports.stringify = function(value) {
7570 var typeHint = type(value);
7571
7572 if (!~['object', 'array', 'function'].indexOf(typeHint)) {
7573 if (typeHint === 'buffer') {
7574 var json = Buffer.prototype.toJSON.call(value);
7575 // Based on the toJSON result
7576 return jsonStringify(
7577 json.data && json.type ? json.data : json,
7578 2
7579 ).replace(/,(\n|$)/g, '$1');
7580 }
7581
7582 // IE7/IE8 has a bizarre String constructor; needs to be coerced
7583 // into an array and back to obj.
7584 if (typeHint === 'string' && typeof value === 'object') {
7585 value = value.split('').reduce(function(acc, char, idx) {
7586 acc[idx] = char;
7587 return acc;
7588 }, {});
7589 typeHint = 'object';
7590 } else {
7591 return jsonStringify(value);
7592 }
7593 }
7594
7595 for (var prop in value) {
7596 if (Object.prototype.hasOwnProperty.call(value, prop)) {
7597 return jsonStringify(
7598 exports.canonicalize(value, null, typeHint),
7599 2
7600 ).replace(/,(\n|$)/g, '$1');
7601 }
7602 }
7603
7604 return emptyRepresentation(value, typeHint);
7605};
7606
7607/**
7608 * like JSON.stringify but more sense.
7609 *
7610 * @private
7611 * @param {Object} object
7612 * @param {number=} spaces
7613 * @param {number=} depth
7614 * @returns {*}
7615 */
7616function jsonStringify(object, spaces, depth) {
7617 if (typeof spaces === 'undefined') {
7618 // primitive types
7619 return _stringify(object);
7620 }
7621
7622 depth = depth || 1;
7623 var space = spaces * depth;
7624 var str = Array.isArray(object) ? '[' : '{';
7625 var end = Array.isArray(object) ? ']' : '}';
7626 var length =
7627 typeof object.length === 'number'
7628 ? object.length
7629 : Object.keys(object).length;
7630 // `.repeat()` polyfill
7631 function repeat(s, n) {
7632 return new Array(n).join(s);
7633 }
7634
7635 function _stringify(val) {
7636 switch (type(val)) {
7637 case 'null':
7638 case 'undefined':
7639 val = '[' + val + ']';
7640 break;
7641 case 'array':
7642 case 'object':
7643 val = jsonStringify(val, spaces, depth + 1);
7644 break;
7645 case 'boolean':
7646 case 'regexp':
7647 case 'symbol':
7648 case 'number':
7649 val =
7650 val === 0 && 1 / val === -Infinity // `-0`
7651 ? '-0'
7652 : val.toString();
7653 break;
7654 case 'date':
7655 var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
7656 val = '[Date: ' + sDate + ']';
7657 break;
7658 case 'buffer':
7659 var json = val.toJSON();
7660 // Based on the toJSON result
7661 json = json.data && json.type ? json.data : json;
7662 val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
7663 break;
7664 default:
7665 val =
7666 val === '[Function]' || val === '[Circular]'
7667 ? val
7668 : JSON.stringify(val); // string
7669 }
7670 return val;
7671 }
7672
7673 for (var i in object) {
7674 if (!Object.prototype.hasOwnProperty.call(object, i)) {
7675 continue; // not my business
7676 }
7677 --length;
7678 str +=
7679 '\n ' +
7680 repeat(' ', space) +
7681 (Array.isArray(object) ? '' : '"' + i + '": ') + // key
7682 _stringify(object[i]) + // value
7683 (length ? ',' : ''); // comma
7684 }
7685
7686 return (
7687 str +
7688 // [], {}
7689 (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
7690 );
7691}
7692
7693/**
7694 * Return a new Thing that has the keys in sorted order. Recursive.
7695 *
7696 * If the Thing...
7697 * - has already been seen, return string `'[Circular]'`
7698 * - is `undefined`, return string `'[undefined]'`
7699 * - is `null`, return value `null`
7700 * - is some other primitive, return the value
7701 * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
7702 * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
7703 * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
7704 *
7705 * @private
7706 * @see {@link exports.stringify}
7707 * @param {*} value Thing to inspect. May or may not have properties.
7708 * @param {Array} [stack=[]] Stack of seen values
7709 * @param {string} [typeHint] Type hint
7710 * @return {(Object|Array|Function|string|undefined)}
7711 */
7712exports.canonicalize = function canonicalize(value, stack, typeHint) {
7713 var canonicalizedObj;
7714 /* eslint-disable no-unused-vars */
7715 var prop;
7716 /* eslint-enable no-unused-vars */
7717 typeHint = typeHint || type(value);
7718 function withStack(value, fn) {
7719 stack.push(value);
7720 fn();
7721 stack.pop();
7722 }
7723
7724 stack = stack || [];
7725
7726 if (stack.indexOf(value) !== -1) {
7727 return '[Circular]';
7728 }
7729
7730 switch (typeHint) {
7731 case 'undefined':
7732 case 'buffer':
7733 case 'null':
7734 canonicalizedObj = value;
7735 break;
7736 case 'array':
7737 withStack(value, function() {
7738 canonicalizedObj = value.map(function(item) {
7739 return exports.canonicalize(item, stack);
7740 });
7741 });
7742 break;
7743 case 'function':
7744 /* eslint-disable guard-for-in */
7745 for (prop in value) {
7746 canonicalizedObj = {};
7747 break;
7748 }
7749 /* eslint-enable guard-for-in */
7750 if (!canonicalizedObj) {
7751 canonicalizedObj = emptyRepresentation(value, typeHint);
7752 break;
7753 }
7754 /* falls through */
7755 case 'object':
7756 canonicalizedObj = canonicalizedObj || {};
7757 withStack(value, function() {
7758 Object.keys(value)
7759 .sort()
7760 .forEach(function(key) {
7761 canonicalizedObj[key] = exports.canonicalize(value[key], stack);
7762 });
7763 });
7764 break;
7765 case 'date':
7766 case 'number':
7767 case 'regexp':
7768 case 'boolean':
7769 case 'symbol':
7770 canonicalizedObj = value;
7771 break;
7772 default:
7773 canonicalizedObj = value + '';
7774 }
7775
7776 return canonicalizedObj;
7777};
7778
7779/**
7780 * Determines if pathname has a matching file extension.
7781 *
7782 * @private
7783 * @param {string} pathname - Pathname to check for match.
7784 * @param {string[]} exts - List of file extensions (sans period).
7785 * @return {boolean} whether file extension matches.
7786 * @example
7787 * hasMatchingExtname('foo.html', ['js', 'css']); // => false
7788 */
7789function hasMatchingExtname(pathname, exts) {
7790 var suffix = path.extname(pathname).slice(1);
7791 return exts.some(function(element) {
7792 return suffix === element;
7793 });
7794}
7795
7796/**
7797 * Determines if pathname would be a "hidden" file (or directory) on UN*X.
7798 *
7799 * @description
7800 * On UN*X, pathnames beginning with a full stop (aka dot) are hidden during
7801 * typical usage. Dotfiles, plain-text configuration files, are prime examples.
7802 *
7803 * @see {@link http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html|Origin of Dot File Names}
7804 *
7805 * @private
7806 * @param {string} pathname - Pathname to check for match.
7807 * @return {boolean} whether pathname would be considered a hidden file.
7808 * @example
7809 * isHiddenOnUnix('.profile'); // => true
7810 */
7811function isHiddenOnUnix(pathname) {
7812 return path.basename(pathname)[0] === '.';
7813}
7814
7815/**
7816 * Lookup file names at the given `path`.
7817 *
7818 * @description
7819 * Filenames are returned in _traversal_ order by the OS/filesystem.
7820 * **Make no assumption that the names will be sorted in any fashion.**
7821 *
7822 * @public
7823 * @memberof Mocha.utils
7824 * @todo Fix extension handling
7825 * @param {string} filepath - Base path to start searching from.
7826 * @param {string[]} extensions - File extensions to look for.
7827 * @param {boolean} recursive - Whether to recurse into subdirectories.
7828 * @return {string[]} An array of paths.
7829 * @throws {Error} if no files match pattern.
7830 * @throws {TypeError} if `filepath` is directory and `extensions` not provided.
7831 */
7832exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
7833 var files = [];
7834 var stat;
7835
7836 if (!fs.existsSync(filepath)) {
7837 if (fs.existsSync(filepath + '.js')) {
7838 filepath += '.js';
7839 } else {
7840 // Handle glob
7841 files = glob.sync(filepath);
7842 if (!files.length) {
7843 throw createNoFilesMatchPatternError(
7844 'Cannot find any files matching pattern ' + exports.dQuote(filepath),
7845 filepath
7846 );
7847 }
7848 return files;
7849 }
7850 }
7851
7852 // Handle file
7853 try {
7854 stat = fs.statSync(filepath);
7855 if (stat.isFile()) {
7856 return filepath;
7857 }
7858 } catch (err) {
7859 // ignore error
7860 return;
7861 }
7862
7863 // Handle directory
7864 fs.readdirSync(filepath).forEach(function(dirent) {
7865 var pathname = path.join(filepath, dirent);
7866 var stat;
7867
7868 try {
7869 stat = fs.statSync(pathname);
7870 if (stat.isDirectory()) {
7871 if (recursive) {
7872 files = files.concat(lookupFiles(pathname, extensions, recursive));
7873 }
7874 return;
7875 }
7876 } catch (err) {
7877 // ignore error
7878 return;
7879 }
7880 if (!extensions) {
7881 throw createMissingArgumentError(
7882 util.format(
7883 'Argument %s required when argument %s is a directory',
7884 exports.sQuote('extensions'),
7885 exports.sQuote('filepath')
7886 ),
7887 'extensions',
7888 'array'
7889 );
7890 }
7891
7892 if (
7893 !stat.isFile() ||
7894 !hasMatchingExtname(pathname, extensions) ||
7895 isHiddenOnUnix(pathname)
7896 ) {
7897 return;
7898 }
7899 files.push(pathname);
7900 });
7901
7902 return files;
7903};
7904
7905/**
7906 * process.emitWarning or a polyfill
7907 * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options
7908 * @ignore
7909 */
7910function emitWarning(msg, type) {
7911 if (process.emitWarning) {
7912 process.emitWarning(msg, type);
7913 } else {
7914 process.nextTick(function() {
7915 console.warn(type + ': ' + msg);
7916 });
7917 }
7918}
7919
7920/**
7921 * Show a deprecation warning. Each distinct message is only displayed once.
7922 * Ignores empty messages.
7923 *
7924 * @param {string} [msg] - Warning to print
7925 * @private
7926 */
7927exports.deprecate = function deprecate(msg) {
7928 msg = String(msg);
7929 if (msg && !deprecate.cache[msg]) {
7930 deprecate.cache[msg] = true;
7931 emitWarning(msg, 'DeprecationWarning');
7932 }
7933};
7934exports.deprecate.cache = {};
7935
7936/**
7937 * Show a generic warning.
7938 * Ignores empty messages.
7939 *
7940 * @param {string} [msg] - Warning to print
7941 * @private
7942 */
7943exports.warn = function warn(msg) {
7944 if (msg) {
7945 emitWarning(msg);
7946 }
7947};
7948
7949/**
7950 * @summary
7951 * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
7952 * @description
7953 * When invoking this function you get a filter function that get the Error.stack as an input,
7954 * and return a prettify output.
7955 * (i.e: strip Mocha and internal node functions from stack trace).
7956 * @returns {Function}
7957 */
7958exports.stackTraceFilter = function() {
7959 // TODO: Replace with `process.browser`
7960 var is = typeof document === 'undefined' ? {node: true} : {browser: true};
7961 var slash = path.sep;
7962 var cwd;
7963 if (is.node) {
7964 cwd = process.cwd() + slash;
7965 } else {
7966 cwd = (typeof location === 'undefined'
7967 ? window.location
7968 : location
7969 ).href.replace(/\/[^/]*$/, '/');
7970 slash = '/';
7971 }
7972
7973 function isMochaInternal(line) {
7974 return (
7975 ~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
7976 ~line.indexOf(slash + 'mocha.js')
7977 );
7978 }
7979
7980 function isNodeInternal(line) {
7981 return (
7982 ~line.indexOf('(timers.js:') ||
7983 ~line.indexOf('(events.js:') ||
7984 ~line.indexOf('(node.js:') ||
7985 ~line.indexOf('(module.js:') ||
7986 ~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
7987 false
7988 );
7989 }
7990
7991 return function(stack) {
7992 stack = stack.split('\n');
7993
7994 stack = stack.reduce(function(list, line) {
7995 if (isMochaInternal(line)) {
7996 return list;
7997 }
7998
7999 if (is.node && isNodeInternal(line)) {
8000 return list;
8001 }
8002
8003 // Clean up cwd(absolute)
8004 if (/:\d+:\d+\)?$/.test(line)) {
8005 line = line.replace('(' + cwd, '(');
8006 }
8007
8008 list.push(line);
8009 return list;
8010 }, []);
8011
8012 return stack.join('\n');
8013 };
8014};
8015
8016/**
8017 * Crude, but effective.
8018 * @public
8019 * @param {*} value
8020 * @returns {boolean} Whether or not `value` is a Promise
8021 */
8022exports.isPromise = function isPromise(value) {
8023 return (
8024 typeof value === 'object' &&
8025 value !== null &&
8026 typeof value.then === 'function'
8027 );
8028};
8029
8030/**
8031 * Clamps a numeric value to an inclusive range.
8032 *
8033 * @param {number} value - Value to be clamped.
8034 * @param {numer[]} range - Two element array specifying [min, max] range.
8035 * @returns {number} clamped value
8036 */
8037exports.clamp = function clamp(value, range) {
8038 return Math.min(Math.max(value, range[0]), range[1]);
8039};
8040
8041/**
8042 * Single quote text by combining with undirectional ASCII quotation marks.
8043 *
8044 * @description
8045 * Provides a simple means of markup for quoting text to be used in output.
8046 * Use this to quote names of variables, methods, and packages.
8047 *
8048 * <samp>package 'foo' cannot be found</samp>
8049 *
8050 * @private
8051 * @param {string} str - Value to be quoted.
8052 * @returns {string} quoted value
8053 * @example
8054 * sQuote('n') // => 'n'
8055 */
8056exports.sQuote = function(str) {
8057 return "'" + str + "'";
8058};
8059
8060/**
8061 * Double quote text by combining with undirectional ASCII quotation marks.
8062 *
8063 * @description
8064 * Provides a simple means of markup for quoting text to be used in output.
8065 * Use this to quote names of datatypes, classes, pathnames, and strings.
8066 *
8067 * <samp>argument 'value' must be "string" or "number"</samp>
8068 *
8069 * @private
8070 * @param {string} str - Value to be quoted.
8071 * @returns {string} quoted value
8072 * @example
8073 * dQuote('number') // => "number"
8074 */
8075exports.dQuote = function(str) {
8076 return '"' + str + '"';
8077};
8078
8079/**
8080 * Provides simplistic message translation for dealing with plurality.
8081 *
8082 * @description
8083 * Use this to create messages which need to be singular or plural.
8084 * Some languages have several plural forms, so _complete_ message clauses
8085 * are preferable to generating the message on the fly.
8086 *
8087 * @private
8088 * @param {number} n - Non-negative integer
8089 * @param {string} msg1 - Message to be used in English for `n = 1`
8090 * @param {string} msg2 - Message to be used in English for `n = 0, 2, 3, ...`
8091 * @returns {string} message corresponding to value of `n`
8092 * @example
8093 * var sprintf = require('util').format;
8094 * var pkgs = ['one', 'two'];
8095 * var msg = sprintf(
8096 * ngettext(
8097 * pkgs.length,
8098 * 'cannot load package: %s',
8099 * 'cannot load packages: %s'
8100 * ),
8101 * pkgs.map(sQuote).join(', ')
8102 * );
8103 * console.log(msg); // => cannot load packages: 'one', 'two'
8104 */
8105exports.ngettext = function(n, msg1, msg2) {
8106 if (typeof n === 'number' && n >= 0) {
8107 return n === 1 ? msg1 : msg2;
8108 }
8109};
8110
8111/**
8112 * It's a noop.
8113 * @public
8114 */
8115exports.noop = function() {};
8116
8117/**
8118 * Creates a map-like object.
8119 *
8120 * @description
8121 * A "map" is an object with no prototype, for our purposes. In some cases
8122 * this would be more appropriate than a `Map`, especially if your environment
8123 * doesn't support it. Recommended for use in Mocha's public APIs.
8124 *
8125 * @public
8126 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map}
8127 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#Custom_and_Null_objects|MDN:Object.create - Custom objects}
8128 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign}
8129 * @param {...*} [obj] - Arguments to `Object.assign()`.
8130 * @returns {Object} An object with no prototype, having `...obj` properties
8131 */
8132exports.createMap = function(obj) {
8133 return assign.apply(
8134 null,
8135 [Object.create(null)].concat(Array.prototype.slice.call(arguments))
8136 );
8137};
8138
8139/**
8140 * Creates a read-only map-like object.
8141 *
8142 * @description
8143 * This differs from {@link module:utils.createMap createMap} only in that
8144 * the argument must be non-empty, because the result is frozen.
8145 *
8146 * @see {@link module:utils.createMap createMap}
8147 * @param {...*} [obj] - Arguments to `Object.assign()`.
8148 * @returns {Object} A frozen object with no prototype, having `...obj` properties
8149 * @throws {TypeError} if argument is not a non-empty object.
8150 */
8151exports.defineConstants = function(obj) {
8152 if (type(obj) !== 'object' || !Object.keys(obj).length) {
8153 throw new TypeError('Invalid argument; expected a non-empty object');
8154 }
8155 return Object.freeze(exports.createMap(obj));
8156};
8157
8158}).call(this,require('_process'),require("buffer").Buffer)
8159},{"./errors":6,"_process":68,"buffer":43,"debug":45,"fs":42,"glob":42,"he":54,"object.assign":64,"path":42,"util":88}],39:[function(require,module,exports){
8160'use strict'
8161
8162exports.byteLength = byteLength
8163exports.toByteArray = toByteArray
8164exports.fromByteArray = fromByteArray
8165
8166var lookup = []
8167var revLookup = []
8168var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
8169
8170var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
8171for (var i = 0, len = code.length; i < len; ++i) {
8172 lookup[i] = code[i]
8173 revLookup[code.charCodeAt(i)] = i
8174}
8175
8176// Support decoding URL-safe base64 strings, as Node.js does.
8177// See: https://en.wikipedia.org/wiki/Base64#URL_applications
8178revLookup['-'.charCodeAt(0)] = 62
8179revLookup['_'.charCodeAt(0)] = 63
8180
8181function getLens (b64) {
8182 var len = b64.length
8183
8184 if (len % 4 > 0) {
8185 throw new Error('Invalid string. Length must be a multiple of 4')
8186 }
8187
8188 // Trim off extra bytes after placeholder bytes are found
8189 // See: https://github.com/beatgammit/base64-js/issues/42
8190 var validLen = b64.indexOf('=')
8191 if (validLen === -1) validLen = len
8192
8193 var placeHoldersLen = validLen === len
8194 ? 0
8195 : 4 - (validLen % 4)
8196
8197 return [validLen, placeHoldersLen]
8198}
8199
8200// base64 is 4/3 + up to two characters of the original data
8201function byteLength (b64) {
8202 var lens = getLens(b64)
8203 var validLen = lens[0]
8204 var placeHoldersLen = lens[1]
8205 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
8206}
8207
8208function _byteLength (b64, validLen, placeHoldersLen) {
8209 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
8210}
8211
8212function toByteArray (b64) {
8213 var tmp
8214 var lens = getLens(b64)
8215 var validLen = lens[0]
8216 var placeHoldersLen = lens[1]
8217
8218 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
8219
8220 var curByte = 0
8221
8222 // if there are placeholders, only get up to the last complete 4 chars
8223 var len = placeHoldersLen > 0
8224 ? validLen - 4
8225 : validLen
8226
8227 for (var i = 0; i < len; i += 4) {
8228 tmp =
8229 (revLookup[b64.charCodeAt(i)] << 18) |
8230 (revLookup[b64.charCodeAt(i + 1)] << 12) |
8231 (revLookup[b64.charCodeAt(i + 2)] << 6) |
8232 revLookup[b64.charCodeAt(i + 3)]
8233 arr[curByte++] = (tmp >> 16) & 0xFF
8234 arr[curByte++] = (tmp >> 8) & 0xFF
8235 arr[curByte++] = tmp & 0xFF
8236 }
8237
8238 if (placeHoldersLen === 2) {
8239 tmp =
8240 (revLookup[b64.charCodeAt(i)] << 2) |
8241 (revLookup[b64.charCodeAt(i + 1)] >> 4)
8242 arr[curByte++] = tmp & 0xFF
8243 }
8244
8245 if (placeHoldersLen === 1) {
8246 tmp =
8247 (revLookup[b64.charCodeAt(i)] << 10) |
8248 (revLookup[b64.charCodeAt(i + 1)] << 4) |
8249 (revLookup[b64.charCodeAt(i + 2)] >> 2)
8250 arr[curByte++] = (tmp >> 8) & 0xFF
8251 arr[curByte++] = tmp & 0xFF
8252 }
8253
8254 return arr
8255}
8256
8257function tripletToBase64 (num) {
8258 return lookup[num >> 18 & 0x3F] +
8259 lookup[num >> 12 & 0x3F] +
8260 lookup[num >> 6 & 0x3F] +
8261 lookup[num & 0x3F]
8262}
8263
8264function encodeChunk (uint8, start, end) {
8265 var tmp
8266 var output = []
8267 for (var i = start; i < end; i += 3) {
8268 tmp =
8269 ((uint8[i] << 16) & 0xFF0000) +
8270 ((uint8[i + 1] << 8) & 0xFF00) +
8271 (uint8[i + 2] & 0xFF)
8272 output.push(tripletToBase64(tmp))
8273 }
8274 return output.join('')
8275}
8276
8277function fromByteArray (uint8) {
8278 var tmp
8279 var len = uint8.length
8280 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
8281 var parts = []
8282 var maxChunkLength = 16383 // must be multiple of 3
8283
8284 // go through the array every three bytes, we'll deal with trailing stuff later
8285 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
8286 parts.push(encodeChunk(
8287 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
8288 ))
8289 }
8290
8291 // pad the end with zeros, but make sure to not forget the extra bytes
8292 if (extraBytes === 1) {
8293 tmp = uint8[len - 1]
8294 parts.push(
8295 lookup[tmp >> 2] +
8296 lookup[(tmp << 4) & 0x3F] +
8297 '=='
8298 )
8299 } else if (extraBytes === 2) {
8300 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
8301 parts.push(
8302 lookup[tmp >> 10] +
8303 lookup[(tmp >> 4) & 0x3F] +
8304 lookup[(tmp << 2) & 0x3F] +
8305 '='
8306 )
8307 }
8308
8309 return parts.join('')
8310}
8311
8312},{}],40:[function(require,module,exports){
8313
8314},{}],41:[function(require,module,exports){
8315(function (process){
8316var WritableStream = require('stream').Writable
8317var inherits = require('util').inherits
8318
8319module.exports = BrowserStdout
8320
8321
8322inherits(BrowserStdout, WritableStream)
8323
8324function BrowserStdout(opts) {
8325 if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
8326
8327 opts = opts || {}
8328 WritableStream.call(this, opts)
8329 this.label = (opts.label !== undefined) ? opts.label : 'stdout'
8330}
8331
8332BrowserStdout.prototype._write = function(chunks, encoding, cb) {
8333 var output = chunks.toString ? chunks.toString() : chunks
8334 if (this.label === false) {
8335 console.log(output)
8336 } else {
8337 console.log(this.label+':', output)
8338 }
8339 process.nextTick(cb)
8340}
8341
8342}).call(this,require('_process'))
8343},{"_process":68,"stream":83,"util":88}],42:[function(require,module,exports){
8344arguments[4][40][0].apply(exports,arguments)
8345},{"dup":40}],43:[function(require,module,exports){
8346/*!
8347 * The buffer module from node.js, for the browser.
8348 *
8349 * @author Feross Aboukhadijeh <https://feross.org>
8350 * @license MIT
8351 */
8352/* eslint-disable no-proto */
8353
8354'use strict'
8355
8356var base64 = require('base64-js')
8357var ieee754 = require('ieee754')
8358
8359exports.Buffer = Buffer
8360exports.SlowBuffer = SlowBuffer
8361exports.INSPECT_MAX_BYTES = 50
8362
8363var K_MAX_LENGTH = 0x7fffffff
8364exports.kMaxLength = K_MAX_LENGTH
8365
8366/**
8367 * If `Buffer.TYPED_ARRAY_SUPPORT`:
8368 * === true Use Uint8Array implementation (fastest)
8369 * === false Print warning and recommend using `buffer` v4.x which has an Object
8370 * implementation (most compatible, even IE6)
8371 *
8372 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
8373 * Opera 11.6+, iOS 4.2+.
8374 *
8375 * We report that the browser does not support typed arrays if the are not subclassable
8376 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
8377 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
8378 * for __proto__ and has a buggy typed array implementation.
8379 */
8380Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
8381
8382if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
8383 typeof console.error === 'function') {
8384 console.error(
8385 'This browser lacks typed array (Uint8Array) support which is required by ' +
8386 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
8387 )
8388}
8389
8390function typedArraySupport () {
8391 // Can typed array instances can be augmented?
8392 try {
8393 var arr = new Uint8Array(1)
8394 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
8395 return arr.foo() === 42
8396 } catch (e) {
8397 return false
8398 }
8399}
8400
8401Object.defineProperty(Buffer.prototype, 'parent', {
8402 get: function () {
8403 if (!(this instanceof Buffer)) {
8404 return undefined
8405 }
8406 return this.buffer
8407 }
8408})
8409
8410Object.defineProperty(Buffer.prototype, 'offset', {
8411 get: function () {
8412 if (!(this instanceof Buffer)) {
8413 return undefined
8414 }
8415 return this.byteOffset
8416 }
8417})
8418
8419function createBuffer (length) {
8420 if (length > K_MAX_LENGTH) {
8421 throw new RangeError('Invalid typed array length')
8422 }
8423 // Return an augmented `Uint8Array` instance
8424 var buf = new Uint8Array(length)
8425 buf.__proto__ = Buffer.prototype
8426 return buf
8427}
8428
8429/**
8430 * The Buffer constructor returns instances of `Uint8Array` that have their
8431 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
8432 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
8433 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
8434 * returns a single octet.
8435 *
8436 * The `Uint8Array` prototype remains unmodified.
8437 */
8438
8439function Buffer (arg, encodingOrOffset, length) {
8440 // Common case.
8441 if (typeof arg === 'number') {
8442 if (typeof encodingOrOffset === 'string') {
8443 throw new Error(
8444 'If encoding is specified then the first argument must be a string'
8445 )
8446 }
8447 return allocUnsafe(arg)
8448 }
8449 return from(arg, encodingOrOffset, length)
8450}
8451
8452// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
8453if (typeof Symbol !== 'undefined' && Symbol.species &&
8454 Buffer[Symbol.species] === Buffer) {
8455 Object.defineProperty(Buffer, Symbol.species, {
8456 value: null,
8457 configurable: true,
8458 enumerable: false,
8459 writable: false
8460 })
8461}
8462
8463Buffer.poolSize = 8192 // not used by this implementation
8464
8465function from (value, encodingOrOffset, length) {
8466 if (typeof value === 'number') {
8467 throw new TypeError('"value" argument must not be a number')
8468 }
8469
8470 if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) {
8471 return fromArrayBuffer(value, encodingOrOffset, length)
8472 }
8473
8474 if (typeof value === 'string') {
8475 return fromString(value, encodingOrOffset)
8476 }
8477
8478 return fromObject(value)
8479}
8480
8481/**
8482 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
8483 * if value is a number.
8484 * Buffer.from(str[, encoding])
8485 * Buffer.from(array)
8486 * Buffer.from(buffer)
8487 * Buffer.from(arrayBuffer[, byteOffset[, length]])
8488 **/
8489Buffer.from = function (value, encodingOrOffset, length) {
8490 return from(value, encodingOrOffset, length)
8491}
8492
8493// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
8494// https://github.com/feross/buffer/pull/148
8495Buffer.prototype.__proto__ = Uint8Array.prototype
8496Buffer.__proto__ = Uint8Array
8497
8498function assertSize (size) {
8499 if (typeof size !== 'number') {
8500 throw new TypeError('"size" argument must be of type number')
8501 } else if (size < 0) {
8502 throw new RangeError('"size" argument must not be negative')
8503 }
8504}
8505
8506function alloc (size, fill, encoding) {
8507 assertSize(size)
8508 if (size <= 0) {
8509 return createBuffer(size)
8510 }
8511 if (fill !== undefined) {
8512 // Only pay attention to encoding if it's a string. This
8513 // prevents accidentally sending in a number that would
8514 // be interpretted as a start offset.
8515 return typeof encoding === 'string'
8516 ? createBuffer(size).fill(fill, encoding)
8517 : createBuffer(size).fill(fill)
8518 }
8519 return createBuffer(size)
8520}
8521
8522/**
8523 * Creates a new filled Buffer instance.
8524 * alloc(size[, fill[, encoding]])
8525 **/
8526Buffer.alloc = function (size, fill, encoding) {
8527 return alloc(size, fill, encoding)
8528}
8529
8530function allocUnsafe (size) {
8531 assertSize(size)
8532 return createBuffer(size < 0 ? 0 : checked(size) | 0)
8533}
8534
8535/**
8536 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
8537 * */
8538Buffer.allocUnsafe = function (size) {
8539 return allocUnsafe(size)
8540}
8541/**
8542 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
8543 */
8544Buffer.allocUnsafeSlow = function (size) {
8545 return allocUnsafe(size)
8546}
8547
8548function fromString (string, encoding) {
8549 if (typeof encoding !== 'string' || encoding === '') {
8550 encoding = 'utf8'
8551 }
8552
8553 if (!Buffer.isEncoding(encoding)) {
8554 throw new TypeError('Unknown encoding: ' + encoding)
8555 }
8556
8557 var length = byteLength(string, encoding) | 0
8558 var buf = createBuffer(length)
8559
8560 var actual = buf.write(string, encoding)
8561
8562 if (actual !== length) {
8563 // Writing a hex string, for example, that contains invalid characters will
8564 // cause everything after the first invalid character to be ignored. (e.g.
8565 // 'abxxcd' will be treated as 'ab')
8566 buf = buf.slice(0, actual)
8567 }
8568
8569 return buf
8570}
8571
8572function fromArrayLike (array) {
8573 var length = array.length < 0 ? 0 : checked(array.length) | 0
8574 var buf = createBuffer(length)
8575 for (var i = 0; i < length; i += 1) {
8576 buf[i] = array[i] & 255
8577 }
8578 return buf
8579}
8580
8581function fromArrayBuffer (array, byteOffset, length) {
8582 if (byteOffset < 0 || array.byteLength < byteOffset) {
8583 throw new RangeError('"offset" is outside of buffer bounds')
8584 }
8585
8586 if (array.byteLength < byteOffset + (length || 0)) {
8587 throw new RangeError('"length" is outside of buffer bounds')
8588 }
8589
8590 var buf
8591 if (byteOffset === undefined && length === undefined) {
8592 buf = new Uint8Array(array)
8593 } else if (length === undefined) {
8594 buf = new Uint8Array(array, byteOffset)
8595 } else {
8596 buf = new Uint8Array(array, byteOffset, length)
8597 }
8598
8599 // Return an augmented `Uint8Array` instance
8600 buf.__proto__ = Buffer.prototype
8601 return buf
8602}
8603
8604function fromObject (obj) {
8605 if (Buffer.isBuffer(obj)) {
8606 var len = checked(obj.length) | 0
8607 var buf = createBuffer(len)
8608
8609 if (buf.length === 0) {
8610 return buf
8611 }
8612
8613 obj.copy(buf, 0, 0, len)
8614 return buf
8615 }
8616
8617 if (obj) {
8618 if (ArrayBuffer.isView(obj) || 'length' in obj) {
8619 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
8620 return createBuffer(0)
8621 }
8622 return fromArrayLike(obj)
8623 }
8624
8625 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
8626 return fromArrayLike(obj.data)
8627 }
8628 }
8629
8630 throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
8631}
8632
8633function checked (length) {
8634 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
8635 // length is NaN (which is otherwise coerced to zero.)
8636 if (length >= K_MAX_LENGTH) {
8637 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
8638 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
8639 }
8640 return length | 0
8641}
8642
8643function SlowBuffer (length) {
8644 if (+length != length) { // eslint-disable-line eqeqeq
8645 length = 0
8646 }
8647 return Buffer.alloc(+length)
8648}
8649
8650Buffer.isBuffer = function isBuffer (b) {
8651 return b != null && b._isBuffer === true
8652}
8653
8654Buffer.compare = function compare (a, b) {
8655 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
8656 throw new TypeError('Arguments must be Buffers')
8657 }
8658
8659 if (a === b) return 0
8660
8661 var x = a.length
8662 var y = b.length
8663
8664 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
8665 if (a[i] !== b[i]) {
8666 x = a[i]
8667 y = b[i]
8668 break
8669 }
8670 }
8671
8672 if (x < y) return -1
8673 if (y < x) return 1
8674 return 0
8675}
8676
8677Buffer.isEncoding = function isEncoding (encoding) {
8678 switch (String(encoding).toLowerCase()) {
8679 case 'hex':
8680 case 'utf8':
8681 case 'utf-8':
8682 case 'ascii':
8683 case 'latin1':
8684 case 'binary':
8685 case 'base64':
8686 case 'ucs2':
8687 case 'ucs-2':
8688 case 'utf16le':
8689 case 'utf-16le':
8690 return true
8691 default:
8692 return false
8693 }
8694}
8695
8696Buffer.concat = function concat (list, length) {
8697 if (!Array.isArray(list)) {
8698 throw new TypeError('"list" argument must be an Array of Buffers')
8699 }
8700
8701 if (list.length === 0) {
8702 return Buffer.alloc(0)
8703 }
8704
8705 var i
8706 if (length === undefined) {
8707 length = 0
8708 for (i = 0; i < list.length; ++i) {
8709 length += list[i].length
8710 }
8711 }
8712
8713 var buffer = Buffer.allocUnsafe(length)
8714 var pos = 0
8715 for (i = 0; i < list.length; ++i) {
8716 var buf = list[i]
8717 if (ArrayBuffer.isView(buf)) {
8718 buf = Buffer.from(buf)
8719 }
8720 if (!Buffer.isBuffer(buf)) {
8721 throw new TypeError('"list" argument must be an Array of Buffers')
8722 }
8723 buf.copy(buffer, pos)
8724 pos += buf.length
8725 }
8726 return buffer
8727}
8728
8729function byteLength (string, encoding) {
8730 if (Buffer.isBuffer(string)) {
8731 return string.length
8732 }
8733 if (ArrayBuffer.isView(string) || isArrayBuffer(string)) {
8734 return string.byteLength
8735 }
8736 if (typeof string !== 'string') {
8737 string = '' + string
8738 }
8739
8740 var len = string.length
8741 if (len === 0) return 0
8742
8743 // Use a for loop to avoid recursion
8744 var loweredCase = false
8745 for (;;) {
8746 switch (encoding) {
8747 case 'ascii':
8748 case 'latin1':
8749 case 'binary':
8750 return len
8751 case 'utf8':
8752 case 'utf-8':
8753 case undefined:
8754 return utf8ToBytes(string).length
8755 case 'ucs2':
8756 case 'ucs-2':
8757 case 'utf16le':
8758 case 'utf-16le':
8759 return len * 2
8760 case 'hex':
8761 return len >>> 1
8762 case 'base64':
8763 return base64ToBytes(string).length
8764 default:
8765 if (loweredCase) return utf8ToBytes(string).length // assume utf8
8766 encoding = ('' + encoding).toLowerCase()
8767 loweredCase = true
8768 }
8769 }
8770}
8771Buffer.byteLength = byteLength
8772
8773function slowToString (encoding, start, end) {
8774 var loweredCase = false
8775
8776 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
8777 // property of a typed array.
8778
8779 // This behaves neither like String nor Uint8Array in that we set start/end
8780 // to their upper/lower bounds if the value passed is out of range.
8781 // undefined is handled specially as per ECMA-262 6th Edition,
8782 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
8783 if (start === undefined || start < 0) {
8784 start = 0
8785 }
8786 // Return early if start > this.length. Done here to prevent potential uint32
8787 // coercion fail below.
8788 if (start > this.length) {
8789 return ''
8790 }
8791
8792 if (end === undefined || end > this.length) {
8793 end = this.length
8794 }
8795
8796 if (end <= 0) {
8797 return ''
8798 }
8799
8800 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
8801 end >>>= 0
8802 start >>>= 0
8803
8804 if (end <= start) {
8805 return ''
8806 }
8807
8808 if (!encoding) encoding = 'utf8'
8809
8810 while (true) {
8811 switch (encoding) {
8812 case 'hex':
8813 return hexSlice(this, start, end)
8814
8815 case 'utf8':
8816 case 'utf-8':
8817 return utf8Slice(this, start, end)
8818
8819 case 'ascii':
8820 return asciiSlice(this, start, end)
8821
8822 case 'latin1':
8823 case 'binary':
8824 return latin1Slice(this, start, end)
8825
8826 case 'base64':
8827 return base64Slice(this, start, end)
8828
8829 case 'ucs2':
8830 case 'ucs-2':
8831 case 'utf16le':
8832 case 'utf-16le':
8833 return utf16leSlice(this, start, end)
8834
8835 default:
8836 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
8837 encoding = (encoding + '').toLowerCase()
8838 loweredCase = true
8839 }
8840 }
8841}
8842
8843// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
8844// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
8845// reliably in a browserify context because there could be multiple different
8846// copies of the 'buffer' package in use. This method works even for Buffer
8847// instances that were created from another copy of the `buffer` package.
8848// See: https://github.com/feross/buffer/issues/154
8849Buffer.prototype._isBuffer = true
8850
8851function swap (b, n, m) {
8852 var i = b[n]
8853 b[n] = b[m]
8854 b[m] = i
8855}
8856
8857Buffer.prototype.swap16 = function swap16 () {
8858 var len = this.length
8859 if (len % 2 !== 0) {
8860 throw new RangeError('Buffer size must be a multiple of 16-bits')
8861 }
8862 for (var i = 0; i < len; i += 2) {
8863 swap(this, i, i + 1)
8864 }
8865 return this
8866}
8867
8868Buffer.prototype.swap32 = function swap32 () {
8869 var len = this.length
8870 if (len % 4 !== 0) {
8871 throw new RangeError('Buffer size must be a multiple of 32-bits')
8872 }
8873 for (var i = 0; i < len; i += 4) {
8874 swap(this, i, i + 3)
8875 swap(this, i + 1, i + 2)
8876 }
8877 return this
8878}
8879
8880Buffer.prototype.swap64 = function swap64 () {
8881 var len = this.length
8882 if (len % 8 !== 0) {
8883 throw new RangeError('Buffer size must be a multiple of 64-bits')
8884 }
8885 for (var i = 0; i < len; i += 8) {
8886 swap(this, i, i + 7)
8887 swap(this, i + 1, i + 6)
8888 swap(this, i + 2, i + 5)
8889 swap(this, i + 3, i + 4)
8890 }
8891 return this
8892}
8893
8894Buffer.prototype.toString = function toString () {
8895 var length = this.length
8896 if (length === 0) return ''
8897 if (arguments.length === 0) return utf8Slice(this, 0, length)
8898 return slowToString.apply(this, arguments)
8899}
8900
8901Buffer.prototype.toLocaleString = Buffer.prototype.toString
8902
8903Buffer.prototype.equals = function equals (b) {
8904 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
8905 if (this === b) return true
8906 return Buffer.compare(this, b) === 0
8907}
8908
8909Buffer.prototype.inspect = function inspect () {
8910 var str = ''
8911 var max = exports.INSPECT_MAX_BYTES
8912 if (this.length > 0) {
8913 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
8914 if (this.length > max) str += ' ... '
8915 }
8916 return '<Buffer ' + str + '>'
8917}
8918
8919Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
8920 if (!Buffer.isBuffer(target)) {
8921 throw new TypeError('Argument must be a Buffer')
8922 }
8923
8924 if (start === undefined) {
8925 start = 0
8926 }
8927 if (end === undefined) {
8928 end = target ? target.length : 0
8929 }
8930 if (thisStart === undefined) {
8931 thisStart = 0
8932 }
8933 if (thisEnd === undefined) {
8934 thisEnd = this.length
8935 }
8936
8937 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
8938 throw new RangeError('out of range index')
8939 }
8940
8941 if (thisStart >= thisEnd && start >= end) {
8942 return 0
8943 }
8944 if (thisStart >= thisEnd) {
8945 return -1
8946 }
8947 if (start >= end) {
8948 return 1
8949 }
8950
8951 start >>>= 0
8952 end >>>= 0
8953 thisStart >>>= 0
8954 thisEnd >>>= 0
8955
8956 if (this === target) return 0
8957
8958 var x = thisEnd - thisStart
8959 var y = end - start
8960 var len = Math.min(x, y)
8961
8962 var thisCopy = this.slice(thisStart, thisEnd)
8963 var targetCopy = target.slice(start, end)
8964
8965 for (var i = 0; i < len; ++i) {
8966 if (thisCopy[i] !== targetCopy[i]) {
8967 x = thisCopy[i]
8968 y = targetCopy[i]
8969 break
8970 }
8971 }
8972
8973 if (x < y) return -1
8974 if (y < x) return 1
8975 return 0
8976}
8977
8978// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
8979// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
8980//
8981// Arguments:
8982// - buffer - a Buffer to search
8983// - val - a string, Buffer, or number
8984// - byteOffset - an index into `buffer`; will be clamped to an int32
8985// - encoding - an optional encoding, relevant is val is a string
8986// - dir - true for indexOf, false for lastIndexOf
8987function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
8988 // Empty buffer means no match
8989 if (buffer.length === 0) return -1
8990
8991 // Normalize byteOffset
8992 if (typeof byteOffset === 'string') {
8993 encoding = byteOffset
8994 byteOffset = 0
8995 } else if (byteOffset > 0x7fffffff) {
8996 byteOffset = 0x7fffffff
8997 } else if (byteOffset < -0x80000000) {
8998 byteOffset = -0x80000000
8999 }
9000 byteOffset = +byteOffset // Coerce to Number.
9001 if (numberIsNaN(byteOffset)) {
9002 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
9003 byteOffset = dir ? 0 : (buffer.length - 1)
9004 }
9005
9006 // Normalize byteOffset: negative offsets start from the end of the buffer
9007 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
9008 if (byteOffset >= buffer.length) {
9009 if (dir) return -1
9010 else byteOffset = buffer.length - 1
9011 } else if (byteOffset < 0) {
9012 if (dir) byteOffset = 0
9013 else return -1
9014 }
9015
9016 // Normalize val
9017 if (typeof val === 'string') {
9018 val = Buffer.from(val, encoding)
9019 }
9020
9021 // Finally, search either indexOf (if dir is true) or lastIndexOf
9022 if (Buffer.isBuffer(val)) {
9023 // Special case: looking for empty string/buffer always fails
9024 if (val.length === 0) {
9025 return -1
9026 }
9027 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
9028 } else if (typeof val === 'number') {
9029 val = val & 0xFF // Search for a byte value [0-255]
9030 if (typeof Uint8Array.prototype.indexOf === 'function') {
9031 if (dir) {
9032 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
9033 } else {
9034 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
9035 }
9036 }
9037 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
9038 }
9039
9040 throw new TypeError('val must be string, number or Buffer')
9041}
9042
9043function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
9044 var indexSize = 1
9045 var arrLength = arr.length
9046 var valLength = val.length
9047
9048 if (encoding !== undefined) {
9049 encoding = String(encoding).toLowerCase()
9050 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
9051 encoding === 'utf16le' || encoding === 'utf-16le') {
9052 if (arr.length < 2 || val.length < 2) {
9053 return -1
9054 }
9055 indexSize = 2
9056 arrLength /= 2
9057 valLength /= 2
9058 byteOffset /= 2
9059 }
9060 }
9061
9062 function read (buf, i) {
9063 if (indexSize === 1) {
9064 return buf[i]
9065 } else {
9066 return buf.readUInt16BE(i * indexSize)
9067 }
9068 }
9069
9070 var i
9071 if (dir) {
9072 var foundIndex = -1
9073 for (i = byteOffset; i < arrLength; i++) {
9074 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
9075 if (foundIndex === -1) foundIndex = i
9076 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
9077 } else {
9078 if (foundIndex !== -1) i -= i - foundIndex
9079 foundIndex = -1
9080 }
9081 }
9082 } else {
9083 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
9084 for (i = byteOffset; i >= 0; i--) {
9085 var found = true
9086 for (var j = 0; j < valLength; j++) {
9087 if (read(arr, i + j) !== read(val, j)) {
9088 found = false
9089 break
9090 }
9091 }
9092 if (found) return i
9093 }
9094 }
9095
9096 return -1
9097}
9098
9099Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
9100 return this.indexOf(val, byteOffset, encoding) !== -1
9101}
9102
9103Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
9104 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
9105}
9106
9107Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
9108 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
9109}
9110
9111function hexWrite (buf, string, offset, length) {
9112 offset = Number(offset) || 0
9113 var remaining = buf.length - offset
9114 if (!length) {
9115 length = remaining
9116 } else {
9117 length = Number(length)
9118 if (length > remaining) {
9119 length = remaining
9120 }
9121 }
9122
9123 var strLen = string.length
9124
9125 if (length > strLen / 2) {
9126 length = strLen / 2
9127 }
9128 for (var i = 0; i < length; ++i) {
9129 var parsed = parseInt(string.substr(i * 2, 2), 16)
9130 if (numberIsNaN(parsed)) return i
9131 buf[offset + i] = parsed
9132 }
9133 return i
9134}
9135
9136function utf8Write (buf, string, offset, length) {
9137 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
9138}
9139
9140function asciiWrite (buf, string, offset, length) {
9141 return blitBuffer(asciiToBytes(string), buf, offset, length)
9142}
9143
9144function latin1Write (buf, string, offset, length) {
9145 return asciiWrite(buf, string, offset, length)
9146}
9147
9148function base64Write (buf, string, offset, length) {
9149 return blitBuffer(base64ToBytes(string), buf, offset, length)
9150}
9151
9152function ucs2Write (buf, string, offset, length) {
9153 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
9154}
9155
9156Buffer.prototype.write = function write (string, offset, length, encoding) {
9157 // Buffer#write(string)
9158 if (offset === undefined) {
9159 encoding = 'utf8'
9160 length = this.length
9161 offset = 0
9162 // Buffer#write(string, encoding)
9163 } else if (length === undefined && typeof offset === 'string') {
9164 encoding = offset
9165 length = this.length
9166 offset = 0
9167 // Buffer#write(string, offset[, length][, encoding])
9168 } else if (isFinite(offset)) {
9169 offset = offset >>> 0
9170 if (isFinite(length)) {
9171 length = length >>> 0
9172 if (encoding === undefined) encoding = 'utf8'
9173 } else {
9174 encoding = length
9175 length = undefined
9176 }
9177 } else {
9178 throw new Error(
9179 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
9180 )
9181 }
9182
9183 var remaining = this.length - offset
9184 if (length === undefined || length > remaining) length = remaining
9185
9186 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
9187 throw new RangeError('Attempt to write outside buffer bounds')
9188 }
9189
9190 if (!encoding) encoding = 'utf8'
9191
9192 var loweredCase = false
9193 for (;;) {
9194 switch (encoding) {
9195 case 'hex':
9196 return hexWrite(this, string, offset, length)
9197
9198 case 'utf8':
9199 case 'utf-8':
9200 return utf8Write(this, string, offset, length)
9201
9202 case 'ascii':
9203 return asciiWrite(this, string, offset, length)
9204
9205 case 'latin1':
9206 case 'binary':
9207 return latin1Write(this, string, offset, length)
9208
9209 case 'base64':
9210 // Warning: maxLength not taken into account in base64Write
9211 return base64Write(this, string, offset, length)
9212
9213 case 'ucs2':
9214 case 'ucs-2':
9215 case 'utf16le':
9216 case 'utf-16le':
9217 return ucs2Write(this, string, offset, length)
9218
9219 default:
9220 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
9221 encoding = ('' + encoding).toLowerCase()
9222 loweredCase = true
9223 }
9224 }
9225}
9226
9227Buffer.prototype.toJSON = function toJSON () {
9228 return {
9229 type: 'Buffer',
9230 data: Array.prototype.slice.call(this._arr || this, 0)
9231 }
9232}
9233
9234function base64Slice (buf, start, end) {
9235 if (start === 0 && end === buf.length) {
9236 return base64.fromByteArray(buf)
9237 } else {
9238 return base64.fromByteArray(buf.slice(start, end))
9239 }
9240}
9241
9242function utf8Slice (buf, start, end) {
9243 end = Math.min(buf.length, end)
9244 var res = []
9245
9246 var i = start
9247 while (i < end) {
9248 var firstByte = buf[i]
9249 var codePoint = null
9250 var bytesPerSequence = (firstByte > 0xEF) ? 4
9251 : (firstByte > 0xDF) ? 3
9252 : (firstByte > 0xBF) ? 2
9253 : 1
9254
9255 if (i + bytesPerSequence <= end) {
9256 var secondByte, thirdByte, fourthByte, tempCodePoint
9257
9258 switch (bytesPerSequence) {
9259 case 1:
9260 if (firstByte < 0x80) {
9261 codePoint = firstByte
9262 }
9263 break
9264 case 2:
9265 secondByte = buf[i + 1]
9266 if ((secondByte & 0xC0) === 0x80) {
9267 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
9268 if (tempCodePoint > 0x7F) {
9269 codePoint = tempCodePoint
9270 }
9271 }
9272 break
9273 case 3:
9274 secondByte = buf[i + 1]
9275 thirdByte = buf[i + 2]
9276 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
9277 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
9278 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
9279 codePoint = tempCodePoint
9280 }
9281 }
9282 break
9283 case 4:
9284 secondByte = buf[i + 1]
9285 thirdByte = buf[i + 2]
9286 fourthByte = buf[i + 3]
9287 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
9288 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
9289 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
9290 codePoint = tempCodePoint
9291 }
9292 }
9293 }
9294 }
9295
9296 if (codePoint === null) {
9297 // we did not generate a valid codePoint so insert a
9298 // replacement char (U+FFFD) and advance only 1 byte
9299 codePoint = 0xFFFD
9300 bytesPerSequence = 1
9301 } else if (codePoint > 0xFFFF) {
9302 // encode to utf16 (surrogate pair dance)
9303 codePoint -= 0x10000
9304 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
9305 codePoint = 0xDC00 | codePoint & 0x3FF
9306 }
9307
9308 res.push(codePoint)
9309 i += bytesPerSequence
9310 }
9311
9312 return decodeCodePointsArray(res)
9313}
9314
9315// Based on http://stackoverflow.com/a/22747272/680742, the browser with
9316// the lowest limit is Chrome, with 0x10000 args.
9317// We go 1 magnitude less, for safety
9318var MAX_ARGUMENTS_LENGTH = 0x1000
9319
9320function decodeCodePointsArray (codePoints) {
9321 var len = codePoints.length
9322 if (len <= MAX_ARGUMENTS_LENGTH) {
9323 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
9324 }
9325
9326 // Decode in chunks to avoid "call stack size exceeded".
9327 var res = ''
9328 var i = 0
9329 while (i < len) {
9330 res += String.fromCharCode.apply(
9331 String,
9332 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
9333 )
9334 }
9335 return res
9336}
9337
9338function asciiSlice (buf, start, end) {
9339 var ret = ''
9340 end = Math.min(buf.length, end)
9341
9342 for (var i = start; i < end; ++i) {
9343 ret += String.fromCharCode(buf[i] & 0x7F)
9344 }
9345 return ret
9346}
9347
9348function latin1Slice (buf, start, end) {
9349 var ret = ''
9350 end = Math.min(buf.length, end)
9351
9352 for (var i = start; i < end; ++i) {
9353 ret += String.fromCharCode(buf[i])
9354 }
9355 return ret
9356}
9357
9358function hexSlice (buf, start, end) {
9359 var len = buf.length
9360
9361 if (!start || start < 0) start = 0
9362 if (!end || end < 0 || end > len) end = len
9363
9364 var out = ''
9365 for (var i = start; i < end; ++i) {
9366 out += toHex(buf[i])
9367 }
9368 return out
9369}
9370
9371function utf16leSlice (buf, start, end) {
9372 var bytes = buf.slice(start, end)
9373 var res = ''
9374 for (var i = 0; i < bytes.length; i += 2) {
9375 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
9376 }
9377 return res
9378}
9379
9380Buffer.prototype.slice = function slice (start, end) {
9381 var len = this.length
9382 start = ~~start
9383 end = end === undefined ? len : ~~end
9384
9385 if (start < 0) {
9386 start += len
9387 if (start < 0) start = 0
9388 } else if (start > len) {
9389 start = len
9390 }
9391
9392 if (end < 0) {
9393 end += len
9394 if (end < 0) end = 0
9395 } else if (end > len) {
9396 end = len
9397 }
9398
9399 if (end < start) end = start
9400
9401 var newBuf = this.subarray(start, end)
9402 // Return an augmented `Uint8Array` instance
9403 newBuf.__proto__ = Buffer.prototype
9404 return newBuf
9405}
9406
9407/*
9408 * Need to make sure that buffer isn't trying to write out of bounds.
9409 */
9410function checkOffset (offset, ext, length) {
9411 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
9412 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
9413}
9414
9415Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
9416 offset = offset >>> 0
9417 byteLength = byteLength >>> 0
9418 if (!noAssert) checkOffset(offset, byteLength, this.length)
9419
9420 var val = this[offset]
9421 var mul = 1
9422 var i = 0
9423 while (++i < byteLength && (mul *= 0x100)) {
9424 val += this[offset + i] * mul
9425 }
9426
9427 return val
9428}
9429
9430Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
9431 offset = offset >>> 0
9432 byteLength = byteLength >>> 0
9433 if (!noAssert) {
9434 checkOffset(offset, byteLength, this.length)
9435 }
9436
9437 var val = this[offset + --byteLength]
9438 var mul = 1
9439 while (byteLength > 0 && (mul *= 0x100)) {
9440 val += this[offset + --byteLength] * mul
9441 }
9442
9443 return val
9444}
9445
9446Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
9447 offset = offset >>> 0
9448 if (!noAssert) checkOffset(offset, 1, this.length)
9449 return this[offset]
9450}
9451
9452Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
9453 offset = offset >>> 0
9454 if (!noAssert) checkOffset(offset, 2, this.length)
9455 return this[offset] | (this[offset + 1] << 8)
9456}
9457
9458Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
9459 offset = offset >>> 0
9460 if (!noAssert) checkOffset(offset, 2, this.length)
9461 return (this[offset] << 8) | this[offset + 1]
9462}
9463
9464Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
9465 offset = offset >>> 0
9466 if (!noAssert) checkOffset(offset, 4, this.length)
9467
9468 return ((this[offset]) |
9469 (this[offset + 1] << 8) |
9470 (this[offset + 2] << 16)) +
9471 (this[offset + 3] * 0x1000000)
9472}
9473
9474Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
9475 offset = offset >>> 0
9476 if (!noAssert) checkOffset(offset, 4, this.length)
9477
9478 return (this[offset] * 0x1000000) +
9479 ((this[offset + 1] << 16) |
9480 (this[offset + 2] << 8) |
9481 this[offset + 3])
9482}
9483
9484Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
9485 offset = offset >>> 0
9486 byteLength = byteLength >>> 0
9487 if (!noAssert) checkOffset(offset, byteLength, this.length)
9488
9489 var val = this[offset]
9490 var mul = 1
9491 var i = 0
9492 while (++i < byteLength && (mul *= 0x100)) {
9493 val += this[offset + i] * mul
9494 }
9495 mul *= 0x80
9496
9497 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
9498
9499 return val
9500}
9501
9502Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
9503 offset = offset >>> 0
9504 byteLength = byteLength >>> 0
9505 if (!noAssert) checkOffset(offset, byteLength, this.length)
9506
9507 var i = byteLength
9508 var mul = 1
9509 var val = this[offset + --i]
9510 while (i > 0 && (mul *= 0x100)) {
9511 val += this[offset + --i] * mul
9512 }
9513 mul *= 0x80
9514
9515 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
9516
9517 return val
9518}
9519
9520Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
9521 offset = offset >>> 0
9522 if (!noAssert) checkOffset(offset, 1, this.length)
9523 if (!(this[offset] & 0x80)) return (this[offset])
9524 return ((0xff - this[offset] + 1) * -1)
9525}
9526
9527Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
9528 offset = offset >>> 0
9529 if (!noAssert) checkOffset(offset, 2, this.length)
9530 var val = this[offset] | (this[offset + 1] << 8)
9531 return (val & 0x8000) ? val | 0xFFFF0000 : val
9532}
9533
9534Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
9535 offset = offset >>> 0
9536 if (!noAssert) checkOffset(offset, 2, this.length)
9537 var val = this[offset + 1] | (this[offset] << 8)
9538 return (val & 0x8000) ? val | 0xFFFF0000 : val
9539}
9540
9541Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
9542 offset = offset >>> 0
9543 if (!noAssert) checkOffset(offset, 4, this.length)
9544
9545 return (this[offset]) |
9546 (this[offset + 1] << 8) |
9547 (this[offset + 2] << 16) |
9548 (this[offset + 3] << 24)
9549}
9550
9551Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
9552 offset = offset >>> 0
9553 if (!noAssert) checkOffset(offset, 4, this.length)
9554
9555 return (this[offset] << 24) |
9556 (this[offset + 1] << 16) |
9557 (this[offset + 2] << 8) |
9558 (this[offset + 3])
9559}
9560
9561Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
9562 offset = offset >>> 0
9563 if (!noAssert) checkOffset(offset, 4, this.length)
9564 return ieee754.read(this, offset, true, 23, 4)
9565}
9566
9567Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
9568 offset = offset >>> 0
9569 if (!noAssert) checkOffset(offset, 4, this.length)
9570 return ieee754.read(this, offset, false, 23, 4)
9571}
9572
9573Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
9574 offset = offset >>> 0
9575 if (!noAssert) checkOffset(offset, 8, this.length)
9576 return ieee754.read(this, offset, true, 52, 8)
9577}
9578
9579Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
9580 offset = offset >>> 0
9581 if (!noAssert) checkOffset(offset, 8, this.length)
9582 return ieee754.read(this, offset, false, 52, 8)
9583}
9584
9585function checkInt (buf, value, offset, ext, max, min) {
9586 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
9587 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
9588 if (offset + ext > buf.length) throw new RangeError('Index out of range')
9589}
9590
9591Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
9592 value = +value
9593 offset = offset >>> 0
9594 byteLength = byteLength >>> 0
9595 if (!noAssert) {
9596 var maxBytes = Math.pow(2, 8 * byteLength) - 1
9597 checkInt(this, value, offset, byteLength, maxBytes, 0)
9598 }
9599
9600 var mul = 1
9601 var i = 0
9602 this[offset] = value & 0xFF
9603 while (++i < byteLength && (mul *= 0x100)) {
9604 this[offset + i] = (value / mul) & 0xFF
9605 }
9606
9607 return offset + byteLength
9608}
9609
9610Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
9611 value = +value
9612 offset = offset >>> 0
9613 byteLength = byteLength >>> 0
9614 if (!noAssert) {
9615 var maxBytes = Math.pow(2, 8 * byteLength) - 1
9616 checkInt(this, value, offset, byteLength, maxBytes, 0)
9617 }
9618
9619 var i = byteLength - 1
9620 var mul = 1
9621 this[offset + i] = value & 0xFF
9622 while (--i >= 0 && (mul *= 0x100)) {
9623 this[offset + i] = (value / mul) & 0xFF
9624 }
9625
9626 return offset + byteLength
9627}
9628
9629Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
9630 value = +value
9631 offset = offset >>> 0
9632 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
9633 this[offset] = (value & 0xff)
9634 return offset + 1
9635}
9636
9637Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
9638 value = +value
9639 offset = offset >>> 0
9640 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
9641 this[offset] = (value & 0xff)
9642 this[offset + 1] = (value >>> 8)
9643 return offset + 2
9644}
9645
9646Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
9647 value = +value
9648 offset = offset >>> 0
9649 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
9650 this[offset] = (value >>> 8)
9651 this[offset + 1] = (value & 0xff)
9652 return offset + 2
9653}
9654
9655Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
9656 value = +value
9657 offset = offset >>> 0
9658 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
9659 this[offset + 3] = (value >>> 24)
9660 this[offset + 2] = (value >>> 16)
9661 this[offset + 1] = (value >>> 8)
9662 this[offset] = (value & 0xff)
9663 return offset + 4
9664}
9665
9666Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
9667 value = +value
9668 offset = offset >>> 0
9669 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
9670 this[offset] = (value >>> 24)
9671 this[offset + 1] = (value >>> 16)
9672 this[offset + 2] = (value >>> 8)
9673 this[offset + 3] = (value & 0xff)
9674 return offset + 4
9675}
9676
9677Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
9678 value = +value
9679 offset = offset >>> 0
9680 if (!noAssert) {
9681 var limit = Math.pow(2, (8 * byteLength) - 1)
9682
9683 checkInt(this, value, offset, byteLength, limit - 1, -limit)
9684 }
9685
9686 var i = 0
9687 var mul = 1
9688 var sub = 0
9689 this[offset] = value & 0xFF
9690 while (++i < byteLength && (mul *= 0x100)) {
9691 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
9692 sub = 1
9693 }
9694 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
9695 }
9696
9697 return offset + byteLength
9698}
9699
9700Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
9701 value = +value
9702 offset = offset >>> 0
9703 if (!noAssert) {
9704 var limit = Math.pow(2, (8 * byteLength) - 1)
9705
9706 checkInt(this, value, offset, byteLength, limit - 1, -limit)
9707 }
9708
9709 var i = byteLength - 1
9710 var mul = 1
9711 var sub = 0
9712 this[offset + i] = value & 0xFF
9713 while (--i >= 0 && (mul *= 0x100)) {
9714 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
9715 sub = 1
9716 }
9717 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
9718 }
9719
9720 return offset + byteLength
9721}
9722
9723Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
9724 value = +value
9725 offset = offset >>> 0
9726 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
9727 if (value < 0) value = 0xff + value + 1
9728 this[offset] = (value & 0xff)
9729 return offset + 1
9730}
9731
9732Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
9733 value = +value
9734 offset = offset >>> 0
9735 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
9736 this[offset] = (value & 0xff)
9737 this[offset + 1] = (value >>> 8)
9738 return offset + 2
9739}
9740
9741Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
9742 value = +value
9743 offset = offset >>> 0
9744 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
9745 this[offset] = (value >>> 8)
9746 this[offset + 1] = (value & 0xff)
9747 return offset + 2
9748}
9749
9750Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
9751 value = +value
9752 offset = offset >>> 0
9753 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
9754 this[offset] = (value & 0xff)
9755 this[offset + 1] = (value >>> 8)
9756 this[offset + 2] = (value >>> 16)
9757 this[offset + 3] = (value >>> 24)
9758 return offset + 4
9759}
9760
9761Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
9762 value = +value
9763 offset = offset >>> 0
9764 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
9765 if (value < 0) value = 0xffffffff + value + 1
9766 this[offset] = (value >>> 24)
9767 this[offset + 1] = (value >>> 16)
9768 this[offset + 2] = (value >>> 8)
9769 this[offset + 3] = (value & 0xff)
9770 return offset + 4
9771}
9772
9773function checkIEEE754 (buf, value, offset, ext, max, min) {
9774 if (offset + ext > buf.length) throw new RangeError('Index out of range')
9775 if (offset < 0) throw new RangeError('Index out of range')
9776}
9777
9778function writeFloat (buf, value, offset, littleEndian, noAssert) {
9779 value = +value
9780 offset = offset >>> 0
9781 if (!noAssert) {
9782 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
9783 }
9784 ieee754.write(buf, value, offset, littleEndian, 23, 4)
9785 return offset + 4
9786}
9787
9788Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
9789 return writeFloat(this, value, offset, true, noAssert)
9790}
9791
9792Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
9793 return writeFloat(this, value, offset, false, noAssert)
9794}
9795
9796function writeDouble (buf, value, offset, littleEndian, noAssert) {
9797 value = +value
9798 offset = offset >>> 0
9799 if (!noAssert) {
9800 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
9801 }
9802 ieee754.write(buf, value, offset, littleEndian, 52, 8)
9803 return offset + 8
9804}
9805
9806Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
9807 return writeDouble(this, value, offset, true, noAssert)
9808}
9809
9810Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
9811 return writeDouble(this, value, offset, false, noAssert)
9812}
9813
9814// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
9815Buffer.prototype.copy = function copy (target, targetStart, start, end) {
9816 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
9817 if (!start) start = 0
9818 if (!end && end !== 0) end = this.length
9819 if (targetStart >= target.length) targetStart = target.length
9820 if (!targetStart) targetStart = 0
9821 if (end > 0 && end < start) end = start
9822
9823 // Copy 0 bytes; we're done
9824 if (end === start) return 0
9825 if (target.length === 0 || this.length === 0) return 0
9826
9827 // Fatal error conditions
9828 if (targetStart < 0) {
9829 throw new RangeError('targetStart out of bounds')
9830 }
9831 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
9832 if (end < 0) throw new RangeError('sourceEnd out of bounds')
9833
9834 // Are we oob?
9835 if (end > this.length) end = this.length
9836 if (target.length - targetStart < end - start) {
9837 end = target.length - targetStart + start
9838 }
9839
9840 var len = end - start
9841
9842 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
9843 // Use built-in when available, missing from IE11
9844 this.copyWithin(targetStart, start, end)
9845 } else if (this === target && start < targetStart && targetStart < end) {
9846 // descending copy from end
9847 for (var i = len - 1; i >= 0; --i) {
9848 target[i + targetStart] = this[i + start]
9849 }
9850 } else {
9851 Uint8Array.prototype.set.call(
9852 target,
9853 this.subarray(start, end),
9854 targetStart
9855 )
9856 }
9857
9858 return len
9859}
9860
9861// Usage:
9862// buffer.fill(number[, offset[, end]])
9863// buffer.fill(buffer[, offset[, end]])
9864// buffer.fill(string[, offset[, end]][, encoding])
9865Buffer.prototype.fill = function fill (val, start, end, encoding) {
9866 // Handle string cases:
9867 if (typeof val === 'string') {
9868 if (typeof start === 'string') {
9869 encoding = start
9870 start = 0
9871 end = this.length
9872 } else if (typeof end === 'string') {
9873 encoding = end
9874 end = this.length
9875 }
9876 if (encoding !== undefined && typeof encoding !== 'string') {
9877 throw new TypeError('encoding must be a string')
9878 }
9879 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
9880 throw new TypeError('Unknown encoding: ' + encoding)
9881 }
9882 if (val.length === 1) {
9883 var code = val.charCodeAt(0)
9884 if ((encoding === 'utf8' && code < 128) ||
9885 encoding === 'latin1') {
9886 // Fast path: If `val` fits into a single byte, use that numeric value.
9887 val = code
9888 }
9889 }
9890 } else if (typeof val === 'number') {
9891 val = val & 255
9892 }
9893
9894 // Invalid ranges are not set to a default, so can range check early.
9895 if (start < 0 || this.length < start || this.length < end) {
9896 throw new RangeError('Out of range index')
9897 }
9898
9899 if (end <= start) {
9900 return this
9901 }
9902
9903 start = start >>> 0
9904 end = end === undefined ? this.length : end >>> 0
9905
9906 if (!val) val = 0
9907
9908 var i
9909 if (typeof val === 'number') {
9910 for (i = start; i < end; ++i) {
9911 this[i] = val
9912 }
9913 } else {
9914 var bytes = Buffer.isBuffer(val)
9915 ? val
9916 : new Buffer(val, encoding)
9917 var len = bytes.length
9918 if (len === 0) {
9919 throw new TypeError('The value "' + val +
9920 '" is invalid for argument "value"')
9921 }
9922 for (i = 0; i < end - start; ++i) {
9923 this[i + start] = bytes[i % len]
9924 }
9925 }
9926
9927 return this
9928}
9929
9930// HELPER FUNCTIONS
9931// ================
9932
9933var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
9934
9935function base64clean (str) {
9936 // Node takes equal signs as end of the Base64 encoding
9937 str = str.split('=')[0]
9938 // Node strips out invalid characters like \n and \t from the string, base64-js does not
9939 str = str.trim().replace(INVALID_BASE64_RE, '')
9940 // Node converts strings with length < 2 to ''
9941 if (str.length < 2) return ''
9942 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
9943 while (str.length % 4 !== 0) {
9944 str = str + '='
9945 }
9946 return str
9947}
9948
9949function toHex (n) {
9950 if (n < 16) return '0' + n.toString(16)
9951 return n.toString(16)
9952}
9953
9954function utf8ToBytes (string, units) {
9955 units = units || Infinity
9956 var codePoint
9957 var length = string.length
9958 var leadSurrogate = null
9959 var bytes = []
9960
9961 for (var i = 0; i < length; ++i) {
9962 codePoint = string.charCodeAt(i)
9963
9964 // is surrogate component
9965 if (codePoint > 0xD7FF && codePoint < 0xE000) {
9966 // last char was a lead
9967 if (!leadSurrogate) {
9968 // no lead yet
9969 if (codePoint > 0xDBFF) {
9970 // unexpected trail
9971 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9972 continue
9973 } else if (i + 1 === length) {
9974 // unpaired lead
9975 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9976 continue
9977 }
9978
9979 // valid lead
9980 leadSurrogate = codePoint
9981
9982 continue
9983 }
9984
9985 // 2 leads in a row
9986 if (codePoint < 0xDC00) {
9987 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9988 leadSurrogate = codePoint
9989 continue
9990 }
9991
9992 // valid surrogate pair
9993 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
9994 } else if (leadSurrogate) {
9995 // valid bmp char, but last char was a lead
9996 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
9997 }
9998
9999 leadSurrogate = null
10000
10001 // encode utf8
10002 if (codePoint < 0x80) {
10003 if ((units -= 1) < 0) break
10004 bytes.push(codePoint)
10005 } else if (codePoint < 0x800) {
10006 if ((units -= 2) < 0) break
10007 bytes.push(
10008 codePoint >> 0x6 | 0xC0,
10009 codePoint & 0x3F | 0x80
10010 )
10011 } else if (codePoint < 0x10000) {
10012 if ((units -= 3) < 0) break
10013 bytes.push(
10014 codePoint >> 0xC | 0xE0,
10015 codePoint >> 0x6 & 0x3F | 0x80,
10016 codePoint & 0x3F | 0x80
10017 )
10018 } else if (codePoint < 0x110000) {
10019 if ((units -= 4) < 0) break
10020 bytes.push(
10021 codePoint >> 0x12 | 0xF0,
10022 codePoint >> 0xC & 0x3F | 0x80,
10023 codePoint >> 0x6 & 0x3F | 0x80,
10024 codePoint & 0x3F | 0x80
10025 )
10026 } else {
10027 throw new Error('Invalid code point')
10028 }
10029 }
10030
10031 return bytes
10032}
10033
10034function asciiToBytes (str) {
10035 var byteArray = []
10036 for (var i = 0; i < str.length; ++i) {
10037 // Node's code seems to be doing this and not & 0x7F..
10038 byteArray.push(str.charCodeAt(i) & 0xFF)
10039 }
10040 return byteArray
10041}
10042
10043function utf16leToBytes (str, units) {
10044 var c, hi, lo
10045 var byteArray = []
10046 for (var i = 0; i < str.length; ++i) {
10047 if ((units -= 2) < 0) break
10048
10049 c = str.charCodeAt(i)
10050 hi = c >> 8
10051 lo = c % 256
10052 byteArray.push(lo)
10053 byteArray.push(hi)
10054 }
10055
10056 return byteArray
10057}
10058
10059function base64ToBytes (str) {
10060 return base64.toByteArray(base64clean(str))
10061}
10062
10063function blitBuffer (src, dst, offset, length) {
10064 for (var i = 0; i < length; ++i) {
10065 if ((i + offset >= dst.length) || (i >= src.length)) break
10066 dst[i + offset] = src[i]
10067 }
10068 return i
10069}
10070
10071// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
10072// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
10073function isArrayBuffer (obj) {
10074 return obj instanceof ArrayBuffer ||
10075 (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
10076 typeof obj.byteLength === 'number')
10077}
10078
10079function numberIsNaN (obj) {
10080 return obj !== obj // eslint-disable-line no-self-compare
10081}
10082
10083},{"base64-js":39,"ieee754":55}],44:[function(require,module,exports){
10084(function (Buffer){
10085// Copyright Joyent, Inc. and other Node contributors.
10086//
10087// Permission is hereby granted, free of charge, to any person obtaining a
10088// copy of this software and associated documentation files (the
10089// "Software"), to deal in the Software without restriction, including
10090// without limitation the rights to use, copy, modify, merge, publish,
10091// distribute, sublicense, and/or sell copies of the Software, and to permit
10092// persons to whom the Software is furnished to do so, subject to the
10093// following conditions:
10094//
10095// The above copyright notice and this permission notice shall be included
10096// in all copies or substantial portions of the Software.
10097//
10098// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10099// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10100// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10101// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10102// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10103// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10104// USE OR OTHER DEALINGS IN THE SOFTWARE.
10105
10106// NOTE: These type checking functions intentionally don't use `instanceof`
10107// because it is fragile and can be easily faked with `Object.create()`.
10108
10109function isArray(arg) {
10110 if (Array.isArray) {
10111 return Array.isArray(arg);
10112 }
10113 return objectToString(arg) === '[object Array]';
10114}
10115exports.isArray = isArray;
10116
10117function isBoolean(arg) {
10118 return typeof arg === 'boolean';
10119}
10120exports.isBoolean = isBoolean;
10121
10122function isNull(arg) {
10123 return arg === null;
10124}
10125exports.isNull = isNull;
10126
10127function isNullOrUndefined(arg) {
10128 return arg == null;
10129}
10130exports.isNullOrUndefined = isNullOrUndefined;
10131
10132function isNumber(arg) {
10133 return typeof arg === 'number';
10134}
10135exports.isNumber = isNumber;
10136
10137function isString(arg) {
10138 return typeof arg === 'string';
10139}
10140exports.isString = isString;
10141
10142function isSymbol(arg) {
10143 return typeof arg === 'symbol';
10144}
10145exports.isSymbol = isSymbol;
10146
10147function isUndefined(arg) {
10148 return arg === void 0;
10149}
10150exports.isUndefined = isUndefined;
10151
10152function isRegExp(re) {
10153 return objectToString(re) === '[object RegExp]';
10154}
10155exports.isRegExp = isRegExp;
10156
10157function isObject(arg) {
10158 return typeof arg === 'object' && arg !== null;
10159}
10160exports.isObject = isObject;
10161
10162function isDate(d) {
10163 return objectToString(d) === '[object Date]';
10164}
10165exports.isDate = isDate;
10166
10167function isError(e) {
10168 return (objectToString(e) === '[object Error]' || e instanceof Error);
10169}
10170exports.isError = isError;
10171
10172function isFunction(arg) {
10173 return typeof arg === 'function';
10174}
10175exports.isFunction = isFunction;
10176
10177function isPrimitive(arg) {
10178 return arg === null ||
10179 typeof arg === 'boolean' ||
10180 typeof arg === 'number' ||
10181 typeof arg === 'string' ||
10182 typeof arg === 'symbol' || // ES6 symbol
10183 typeof arg === 'undefined';
10184}
10185exports.isPrimitive = isPrimitive;
10186
10187exports.isBuffer = Buffer.isBuffer;
10188
10189function objectToString(o) {
10190 return Object.prototype.toString.call(o);
10191}
10192
10193}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
10194},{"../../is-buffer/index.js":57}],45:[function(require,module,exports){
10195(function (process){
10196"use strict";
10197
10198function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
10199
10200/* eslint-env browser */
10201
10202/**
10203 * This is the web browser implementation of `debug()`.
10204 */
10205exports.log = log;
10206exports.formatArgs = formatArgs;
10207exports.save = save;
10208exports.load = load;
10209exports.useColors = useColors;
10210exports.storage = localstorage();
10211/**
10212 * Colors.
10213 */
10214
10215exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
10216/**
10217 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
10218 * and the Firebug extension (any Firefox version) are known
10219 * to support "%c" CSS customizations.
10220 *
10221 * TODO: add a `localStorage` variable to explicitly enable/disable colors
10222 */
10223// eslint-disable-next-line complexity
10224
10225function useColors() {
10226 // NB: In an Electron preload script, document will be defined but not fully
10227 // initialized. Since we know we're in Chrome, we'll just detect this case
10228 // explicitly
10229 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
10230 return true;
10231 } // Internet Explorer and Edge do not support colors.
10232
10233
10234 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
10235 return false;
10236 } // Is webkit? http://stackoverflow.com/a/16459606/376773
10237 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
10238
10239
10240 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
10241 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
10242 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
10243 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
10244 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
10245}
10246/**
10247 * Colorize log arguments if enabled.
10248 *
10249 * @api public
10250 */
10251
10252
10253function formatArgs(args) {
10254 args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
10255
10256 if (!this.useColors) {
10257 return;
10258 }
10259
10260 var c = 'color: ' + this.color;
10261 args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
10262 // arguments passed either before or after the %c, so we need to
10263 // figure out the correct index to insert the CSS into
10264
10265 var index = 0;
10266 var lastC = 0;
10267 args[0].replace(/%[a-zA-Z%]/g, function (match) {
10268 if (match === '%%') {
10269 return;
10270 }
10271
10272 index++;
10273
10274 if (match === '%c') {
10275 // We only are interested in the *last* %c
10276 // (the user may have provided their own)
10277 lastC = index;
10278 }
10279 });
10280 args.splice(lastC, 0, c);
10281}
10282/**
10283 * Invokes `console.log()` when available.
10284 * No-op when `console.log` is not a "function".
10285 *
10286 * @api public
10287 */
10288
10289
10290function log() {
10291 var _console;
10292
10293 // This hackery is required for IE8/9, where
10294 // the `console.log` function doesn't have 'apply'
10295 return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
10296}
10297/**
10298 * Save `namespaces`.
10299 *
10300 * @param {String} namespaces
10301 * @api private
10302 */
10303
10304
10305function save(namespaces) {
10306 try {
10307 if (namespaces) {
10308 exports.storage.setItem('debug', namespaces);
10309 } else {
10310 exports.storage.removeItem('debug');
10311 }
10312 } catch (error) {// Swallow
10313 // XXX (@Qix-) should we be logging these?
10314 }
10315}
10316/**
10317 * Load `namespaces`.
10318 *
10319 * @return {String} returns the previously persisted debug modes
10320 * @api private
10321 */
10322
10323
10324function load() {
10325 var r;
10326
10327 try {
10328 r = exports.storage.getItem('debug');
10329 } catch (error) {} // Swallow
10330 // XXX (@Qix-) should we be logging these?
10331 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
10332
10333
10334 if (!r && typeof process !== 'undefined' && 'env' in process) {
10335 r = process.env.DEBUG;
10336 }
10337
10338 return r;
10339}
10340/**
10341 * Localstorage attempts to return the localstorage.
10342 *
10343 * This is necessary because safari throws
10344 * when a user disables cookies/localstorage
10345 * and you attempt to access it.
10346 *
10347 * @return {LocalStorage}
10348 * @api private
10349 */
10350
10351
10352function localstorage() {
10353 try {
10354 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
10355 // The Browser also has localStorage in the global context.
10356 return localStorage;
10357 } catch (error) {// Swallow
10358 // XXX (@Qix-) should we be logging these?
10359 }
10360}
10361
10362module.exports = require('./common')(exports);
10363var formatters = module.exports.formatters;
10364/**
10365 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
10366 */
10367
10368formatters.j = function (v) {
10369 try {
10370 return JSON.stringify(v);
10371 } catch (error) {
10372 return '[UnexpectedJSONParseError]: ' + error.message;
10373 }
10374};
10375
10376
10377}).call(this,require('_process'))
10378},{"./common":46,"_process":68}],46:[function(require,module,exports){
10379"use strict";
10380
10381/**
10382 * This is the common logic for both the Node.js and web browser
10383 * implementations of `debug()`.
10384 */
10385function setup(env) {
10386 createDebug.debug = createDebug;
10387 createDebug.default = createDebug;
10388 createDebug.coerce = coerce;
10389 createDebug.disable = disable;
10390 createDebug.enable = enable;
10391 createDebug.enabled = enabled;
10392 createDebug.humanize = require('ms');
10393 Object.keys(env).forEach(function (key) {
10394 createDebug[key] = env[key];
10395 });
10396 /**
10397 * Active `debug` instances.
10398 */
10399
10400 createDebug.instances = [];
10401 /**
10402 * The currently active debug mode names, and names to skip.
10403 */
10404
10405 createDebug.names = [];
10406 createDebug.skips = [];
10407 /**
10408 * Map of special "%n" handling functions, for the debug "format" argument.
10409 *
10410 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
10411 */
10412
10413 createDebug.formatters = {};
10414 /**
10415 * Selects a color for a debug namespace
10416 * @param {String} namespace The namespace string for the for the debug instance to be colored
10417 * @return {Number|String} An ANSI color code for the given namespace
10418 * @api private
10419 */
10420
10421 function selectColor(namespace) {
10422 var hash = 0;
10423
10424 for (var i = 0; i < namespace.length; i++) {
10425 hash = (hash << 5) - hash + namespace.charCodeAt(i);
10426 hash |= 0; // Convert to 32bit integer
10427 }
10428
10429 return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
10430 }
10431
10432 createDebug.selectColor = selectColor;
10433 /**
10434 * Create a debugger with the given `namespace`.
10435 *
10436 * @param {String} namespace
10437 * @return {Function}
10438 * @api public
10439 */
10440
10441 function createDebug(namespace) {
10442 var prevTime;
10443
10444 function debug() {
10445 // Disabled?
10446 if (!debug.enabled) {
10447 return;
10448 }
10449
10450 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10451 args[_key] = arguments[_key];
10452 }
10453
10454 var self = debug; // Set `diff` timestamp
10455
10456 var curr = Number(new Date());
10457 var ms = curr - (prevTime || curr);
10458 self.diff = ms;
10459 self.prev = prevTime;
10460 self.curr = curr;
10461 prevTime = curr;
10462 args[0] = createDebug.coerce(args[0]);
10463
10464 if (typeof args[0] !== 'string') {
10465 // Anything else let's inspect with %O
10466 args.unshift('%O');
10467 } // Apply any `formatters` transformations
10468
10469
10470 var index = 0;
10471 args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
10472 // If we encounter an escaped % then don't increase the array index
10473 if (match === '%%') {
10474 return match;
10475 }
10476
10477 index++;
10478 var formatter = createDebug.formatters[format];
10479
10480 if (typeof formatter === 'function') {
10481 var val = args[index];
10482 match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
10483
10484 args.splice(index, 1);
10485 index--;
10486 }
10487
10488 return match;
10489 }); // Apply env-specific formatting (colors, etc.)
10490
10491 createDebug.formatArgs.call(self, args);
10492 var logFn = self.log || createDebug.log;
10493 logFn.apply(self, args);
10494 }
10495
10496 debug.namespace = namespace;
10497 debug.enabled = createDebug.enabled(namespace);
10498 debug.useColors = createDebug.useColors();
10499 debug.color = selectColor(namespace);
10500 debug.destroy = destroy;
10501 debug.extend = extend; // Debug.formatArgs = formatArgs;
10502 // debug.rawLog = rawLog;
10503 // env-specific initialization logic for debug instances
10504
10505 if (typeof createDebug.init === 'function') {
10506 createDebug.init(debug);
10507 }
10508
10509 createDebug.instances.push(debug);
10510 return debug;
10511 }
10512
10513 function destroy() {
10514 var index = createDebug.instances.indexOf(this);
10515
10516 if (index !== -1) {
10517 createDebug.instances.splice(index, 1);
10518 return true;
10519 }
10520
10521 return false;
10522 }
10523
10524 function extend(namespace, delimiter) {
10525 return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
10526 }
10527 /**
10528 * Enables a debug mode by namespaces. This can include modes
10529 * separated by a colon and wildcards.
10530 *
10531 * @param {String} namespaces
10532 * @api public
10533 */
10534
10535
10536 function enable(namespaces) {
10537 createDebug.save(namespaces);
10538 createDebug.names = [];
10539 createDebug.skips = [];
10540 var i;
10541 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
10542 var len = split.length;
10543
10544 for (i = 0; i < len; i++) {
10545 if (!split[i]) {
10546 // ignore empty strings
10547 continue;
10548 }
10549
10550 namespaces = split[i].replace(/\*/g, '.*?');
10551
10552 if (namespaces[0] === '-') {
10553 createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
10554 } else {
10555 createDebug.names.push(new RegExp('^' + namespaces + '$'));
10556 }
10557 }
10558
10559 for (i = 0; i < createDebug.instances.length; i++) {
10560 var instance = createDebug.instances[i];
10561 instance.enabled = createDebug.enabled(instance.namespace);
10562 }
10563 }
10564 /**
10565 * Disable debug output.
10566 *
10567 * @api public
10568 */
10569
10570
10571 function disable() {
10572 createDebug.enable('');
10573 }
10574 /**
10575 * Returns true if the given mode name is enabled, false otherwise.
10576 *
10577 * @param {String} name
10578 * @return {Boolean}
10579 * @api public
10580 */
10581
10582
10583 function enabled(name) {
10584 if (name[name.length - 1] === '*') {
10585 return true;
10586 }
10587
10588 var i;
10589 var len;
10590
10591 for (i = 0, len = createDebug.skips.length; i < len; i++) {
10592 if (createDebug.skips[i].test(name)) {
10593 return false;
10594 }
10595 }
10596
10597 for (i = 0, len = createDebug.names.length; i < len; i++) {
10598 if (createDebug.names[i].test(name)) {
10599 return true;
10600 }
10601 }
10602
10603 return false;
10604 }
10605 /**
10606 * Coerce `val`.
10607 *
10608 * @param {Mixed} val
10609 * @return {Mixed}
10610 * @api private
10611 */
10612
10613
10614 function coerce(val) {
10615 if (val instanceof Error) {
10616 return val.stack || val.message;
10617 }
10618
10619 return val;
10620 }
10621
10622 createDebug.enable(createDebug.load());
10623 return createDebug;
10624}
10625
10626module.exports = setup;
10627
10628
10629},{"ms":60}],47:[function(require,module,exports){
10630'use strict';
10631
10632var keys = require('object-keys');
10633var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
10634
10635var toStr = Object.prototype.toString;
10636var concat = Array.prototype.concat;
10637var origDefineProperty = Object.defineProperty;
10638
10639var isFunction = function (fn) {
10640 return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
10641};
10642
10643var arePropertyDescriptorsSupported = function () {
10644 var obj = {};
10645 try {
10646 origDefineProperty(obj, 'x', { enumerable: false, value: obj });
10647 // eslint-disable-next-line no-unused-vars, no-restricted-syntax
10648 for (var _ in obj) { // jscs:ignore disallowUnusedVariables
10649 return false;
10650 }
10651 return obj.x === obj;
10652 } catch (e) { /* this is IE 8. */
10653 return false;
10654 }
10655};
10656var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
10657
10658var defineProperty = function (object, name, value, predicate) {
10659 if (name in object && (!isFunction(predicate) || !predicate())) {
10660 return;
10661 }
10662 if (supportsDescriptors) {
10663 origDefineProperty(object, name, {
10664 configurable: true,
10665 enumerable: false,
10666 value: value,
10667 writable: true
10668 });
10669 } else {
10670 object[name] = value;
10671 }
10672};
10673
10674var defineProperties = function (object, map) {
10675 var predicates = arguments.length > 2 ? arguments[2] : {};
10676 var props = keys(map);
10677 if (hasSymbols) {
10678 props = concat.call(props, Object.getOwnPropertySymbols(map));
10679 }
10680 for (var i = 0; i < props.length; i += 1) {
10681 defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
10682 }
10683};
10684
10685defineProperties.supportsDescriptors = !!supportsDescriptors;
10686
10687module.exports = defineProperties;
10688
10689},{"object-keys":61}],48:[function(require,module,exports){
10690/*!
10691
10692 diff v3.5.0
10693
10694Software License Agreement (BSD License)
10695
10696Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
10697
10698All rights reserved.
10699
10700Redistribution and use of this software in source and binary forms, with or without modification,
10701are permitted provided that the following conditions are met:
10702
10703* Redistributions of source code must retain the above
10704 copyright notice, this list of conditions and the
10705 following disclaimer.
10706
10707* Redistributions in binary form must reproduce the above
10708 copyright notice, this list of conditions and the
10709 following disclaimer in the documentation and/or other
10710 materials provided with the distribution.
10711
10712* Neither the name of Kevin Decker nor the names of its
10713 contributors may be used to endorse or promote products
10714 derived from this software without specific prior
10715 written permission.
10716
10717THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
10718IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
10719FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
10720CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10721DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10722DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
10723IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
10724OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10725@license
10726*/
10727(function webpackUniversalModuleDefinition(root, factory) {
10728 if(typeof exports === 'object' && typeof module === 'object')
10729 module.exports = factory();
10730 else if(false)
10731 define([], factory);
10732 else if(typeof exports === 'object')
10733 exports["JsDiff"] = factory();
10734 else
10735 root["JsDiff"] = factory();
10736})(this, function() {
10737return /******/ (function(modules) { // webpackBootstrap
10738/******/ // The module cache
10739/******/ var installedModules = {};
10740
10741/******/ // The require function
10742/******/ function __webpack_require__(moduleId) {
10743
10744/******/ // Check if module is in cache
10745/******/ if(installedModules[moduleId])
10746/******/ return installedModules[moduleId].exports;
10747
10748/******/ // Create a new module (and put it into the cache)
10749/******/ var module = installedModules[moduleId] = {
10750/******/ exports: {},
10751/******/ id: moduleId,
10752/******/ loaded: false
10753/******/ };
10754
10755/******/ // Execute the module function
10756/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
10757
10758/******/ // Flag the module as loaded
10759/******/ module.loaded = true;
10760
10761/******/ // Return the exports of the module
10762/******/ return module.exports;
10763/******/ }
10764
10765
10766/******/ // expose the modules object (__webpack_modules__)
10767/******/ __webpack_require__.m = modules;
10768
10769/******/ // expose the module cache
10770/******/ __webpack_require__.c = installedModules;
10771
10772/******/ // __webpack_public_path__
10773/******/ __webpack_require__.p = "";
10774
10775/******/ // Load entry module and return exports
10776/******/ return __webpack_require__(0);
10777/******/ })
10778/************************************************************************/
10779/******/ ([
10780/* 0 */
10781/***/ (function(module, exports, __webpack_require__) {
10782
10783 /*istanbul ignore start*/'use strict';
10784
10785 exports.__esModule = true;
10786 exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined;
10787
10788 /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
10789
10790 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
10791
10792 /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/;
10793
10794 var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/;
10795
10796 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
10797
10798 var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/;
10799
10800 var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/;
10801
10802 var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/;
10803
10804 var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/;
10805
10806 var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/;
10807
10808 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
10809
10810 var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/;
10811
10812 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
10813
10814 var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/;
10815
10816 var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/;
10817
10818 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
10819
10820 /* See LICENSE file for terms of use */
10821
10822 /*
10823 * Text diff implementation.
10824 *
10825 * This library supports the following APIS:
10826 * JsDiff.diffChars: Character by character diff
10827 * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
10828 * JsDiff.diffLines: Line based diff
10829 *
10830 * JsDiff.diffCss: Diff targeted at CSS content
10831 *
10832 * These methods are based on the implementation proposed in
10833 * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
10834 * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
10835 */
10836 exports. /*istanbul ignore end*/Diff = _base2['default'];
10837 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
10838 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
10839 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
10840 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
10841 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
10842 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
10843 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
10844 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
10845 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
10846 /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
10847 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
10848 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
10849 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
10850 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
10851 /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
10852 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge;
10853 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
10854 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
10855 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize;
10856
10857
10858
10859/***/ }),
10860/* 1 */
10861/***/ (function(module, exports) {
10862
10863 /*istanbul ignore start*/'use strict';
10864
10865 exports.__esModule = true;
10866 exports['default'] = /*istanbul ignore end*/Diff;
10867 function Diff() {}
10868
10869 Diff.prototype = {
10870 /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
10871 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
10872
10873 var callback = options.callback;
10874 if (typeof options === 'function') {
10875 callback = options;
10876 options = {};
10877 }
10878 this.options = options;
10879
10880 var self = this;
10881
10882 function done(value) {
10883 if (callback) {
10884 setTimeout(function () {
10885 callback(undefined, value);
10886 }, 0);
10887 return true;
10888 } else {
10889 return value;
10890 }
10891 }
10892
10893 // Allow subclasses to massage the input prior to running
10894 oldString = this.castInput(oldString);
10895 newString = this.castInput(newString);
10896
10897 oldString = this.removeEmpty(this.tokenize(oldString));
10898 newString = this.removeEmpty(this.tokenize(newString));
10899
10900 var newLen = newString.length,
10901 oldLen = oldString.length;
10902 var editLength = 1;
10903 var maxEditLength = newLen + oldLen;
10904 var bestPath = [{ newPos: -1, components: [] }];
10905
10906 // Seed editLength = 0, i.e. the content starts with the same values
10907 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
10908 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
10909 // Identity per the equality and tokenizer
10910 return done([{ value: this.join(newString), count: newString.length }]);
10911 }
10912
10913 // Main worker method. checks all permutations of a given edit length for acceptance.
10914 function execEditLength() {
10915 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
10916 var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
10917 var addPath = bestPath[diagonalPath - 1],
10918 removePath = bestPath[diagonalPath + 1],
10919 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
10920 if (addPath) {
10921 // No one else is going to attempt to use this value, clear it
10922 bestPath[diagonalPath - 1] = undefined;
10923 }
10924
10925 var canAdd = addPath && addPath.newPos + 1 < newLen,
10926 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
10927 if (!canAdd && !canRemove) {
10928 // If this path is a terminal then prune
10929 bestPath[diagonalPath] = undefined;
10930 continue;
10931 }
10932
10933 // Select the diagonal that we want to branch from. We select the prior
10934 // path whose position in the new string is the farthest from the origin
10935 // and does not pass the bounds of the diff graph
10936 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
10937 basePath = clonePath(removePath);
10938 self.pushComponent(basePath.components, undefined, true);
10939 } else {
10940 basePath = addPath; // No need to clone, we've pulled it from the list
10941 basePath.newPos++;
10942 self.pushComponent(basePath.components, true, undefined);
10943 }
10944
10945 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
10946
10947 // If we have hit the end of both strings, then we are done
10948 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
10949 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
10950 } else {
10951 // Otherwise track this path as a potential candidate and continue.
10952 bestPath[diagonalPath] = basePath;
10953 }
10954 }
10955
10956 editLength++;
10957 }
10958
10959 // Performs the length of edit iteration. Is a bit fugly as this has to support the
10960 // sync and async mode which is never fun. Loops over execEditLength until a value
10961 // is produced.
10962 if (callback) {
10963 (function exec() {
10964 setTimeout(function () {
10965 // This should not happen, but we want to be safe.
10966 /* istanbul ignore next */
10967 if (editLength > maxEditLength) {
10968 return callback();
10969 }
10970
10971 if (!execEditLength()) {
10972 exec();
10973 }
10974 }, 0);
10975 })();
10976 } else {
10977 while (editLength <= maxEditLength) {
10978 var ret = execEditLength();
10979 if (ret) {
10980 return ret;
10981 }
10982 }
10983 }
10984 },
10985 /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
10986 var last = components[components.length - 1];
10987 if (last && last.added === added && last.removed === removed) {
10988 // We need to clone here as the component clone operation is just
10989 // as shallow array clone
10990 components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
10991 } else {
10992 components.push({ count: 1, added: added, removed: removed });
10993 }
10994 },
10995 /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
10996 var newLen = newString.length,
10997 oldLen = oldString.length,
10998 newPos = basePath.newPos,
10999 oldPos = newPos - diagonalPath,
11000 commonCount = 0;
11001 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
11002 newPos++;
11003 oldPos++;
11004 commonCount++;
11005 }
11006
11007 if (commonCount) {
11008 basePath.components.push({ count: commonCount });
11009 }
11010
11011 basePath.newPos = newPos;
11012 return oldPos;
11013 },
11014 /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
11015 if (this.options.comparator) {
11016 return this.options.comparator(left, right);
11017 } else {
11018 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
11019 }
11020 },
11021 /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
11022 var ret = [];
11023 for (var i = 0; i < array.length; i++) {
11024 if (array[i]) {
11025 ret.push(array[i]);
11026 }
11027 }
11028 return ret;
11029 },
11030 /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
11031 return value;
11032 },
11033 /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
11034 return value.split('');
11035 },
11036 /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
11037 return chars.join('');
11038 }
11039 };
11040
11041 function buildValues(diff, components, newString, oldString, useLongestToken) {
11042 var componentPos = 0,
11043 componentLen = components.length,
11044 newPos = 0,
11045 oldPos = 0;
11046
11047 for (; componentPos < componentLen; componentPos++) {
11048 var component = components[componentPos];
11049 if (!component.removed) {
11050 if (!component.added && useLongestToken) {
11051 var value = newString.slice(newPos, newPos + component.count);
11052 value = value.map(function (value, i) {
11053 var oldValue = oldString[oldPos + i];
11054 return oldValue.length > value.length ? oldValue : value;
11055 });
11056
11057 component.value = diff.join(value);
11058 } else {
11059 component.value = diff.join(newString.slice(newPos, newPos + component.count));
11060 }
11061 newPos += component.count;
11062
11063 // Common case
11064 if (!component.added) {
11065 oldPos += component.count;
11066 }
11067 } else {
11068 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
11069 oldPos += component.count;
11070
11071 // Reverse add and remove so removes are output first to match common convention
11072 // The diffing algorithm is tied to add then remove output and this is the simplest
11073 // route to get the desired output with minimal overhead.
11074 if (componentPos && components[componentPos - 1].added) {
11075 var tmp = components[componentPos - 1];
11076 components[componentPos - 1] = components[componentPos];
11077 components[componentPos] = tmp;
11078 }
11079 }
11080 }
11081
11082 // Special case handle for when one terminal is ignored (i.e. whitespace).
11083 // For this case we merge the terminal into the prior string and drop the change.
11084 // This is only available for string mode.
11085 var lastComponent = components[componentLen - 1];
11086 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
11087 components[componentLen - 2].value += lastComponent.value;
11088 components.pop();
11089 }
11090
11091 return components;
11092 }
11093
11094 function clonePath(path) {
11095 return { newPos: path.newPos, components: path.components.slice(0) };
11096 }
11097
11098
11099
11100/***/ }),
11101/* 2 */
11102/***/ (function(module, exports, __webpack_require__) {
11103
11104 /*istanbul ignore start*/'use strict';
11105
11106 exports.__esModule = true;
11107 exports.characterDiff = undefined;
11108 exports. /*istanbul ignore end*/diffChars = diffChars;
11109
11110 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11111
11112 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11113
11114 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11115
11116 /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11117 function diffChars(oldStr, newStr, options) {
11118 return characterDiff.diff(oldStr, newStr, options);
11119 }
11120
11121
11122
11123/***/ }),
11124/* 3 */
11125/***/ (function(module, exports, __webpack_require__) {
11126
11127 /*istanbul ignore start*/'use strict';
11128
11129 exports.__esModule = true;
11130 exports.wordDiff = undefined;
11131 exports. /*istanbul ignore end*/diffWords = diffWords;
11132 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
11133
11134 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11135
11136 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11137
11138 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
11139
11140 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11141
11142 /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
11143 //
11144 // Ranges and exceptions:
11145 // Latin-1 Supplement, 0080–00FF
11146 // - U+00D7 × Multiplication sign
11147 // - U+00F7 ÷ Division sign
11148 // Latin Extended-A, 0100–017F
11149 // Latin Extended-B, 0180–024F
11150 // IPA Extensions, 0250–02AF
11151 // Spacing Modifier Letters, 02B0–02FF
11152 // - U+02C7 ˇ &#711; Caron
11153 // - U+02D8 ˘ &#728; Breve
11154 // - U+02D9 ˙ &#729; Dot Above
11155 // - U+02DA ˚ &#730; Ring Above
11156 // - U+02DB ˛ &#731; Ogonek
11157 // - U+02DC ˜ &#732; Small Tilde
11158 // - U+02DD ˝ &#733; Double Acute Accent
11159 // Latin Extended Additional, 1E00–1EFF
11160 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
11161
11162 var reWhitespace = /\S/;
11163
11164 var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11165 wordDiff.equals = function (left, right) {
11166 if (this.options.ignoreCase) {
11167 left = left.toLowerCase();
11168 right = right.toLowerCase();
11169 }
11170 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
11171 };
11172 wordDiff.tokenize = function (value) {
11173 var tokens = value.split(/(\s+|\b)/);
11174
11175 // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
11176 for (var i = 0; i < tokens.length - 1; i++) {
11177 // If we have an empty string in the next field and we have only word chars before and after, merge
11178 if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
11179 tokens[i] += tokens[i + 2];
11180 tokens.splice(i + 1, 2);
11181 i--;
11182 }
11183 }
11184
11185 return tokens;
11186 };
11187
11188 function diffWords(oldStr, newStr, options) {
11189 options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
11190 return wordDiff.diff(oldStr, newStr, options);
11191 }
11192
11193 function diffWordsWithSpace(oldStr, newStr, options) {
11194 return wordDiff.diff(oldStr, newStr, options);
11195 }
11196
11197
11198
11199/***/ }),
11200/* 4 */
11201/***/ (function(module, exports) {
11202
11203 /*istanbul ignore start*/'use strict';
11204
11205 exports.__esModule = true;
11206 exports. /*istanbul ignore end*/generateOptions = generateOptions;
11207 function generateOptions(options, defaults) {
11208 if (typeof options === 'function') {
11209 defaults.callback = options;
11210 } else if (options) {
11211 for (var name in options) {
11212 /* istanbul ignore else */
11213 if (options.hasOwnProperty(name)) {
11214 defaults[name] = options[name];
11215 }
11216 }
11217 }
11218 return defaults;
11219 }
11220
11221
11222
11223/***/ }),
11224/* 5 */
11225/***/ (function(module, exports, __webpack_require__) {
11226
11227 /*istanbul ignore start*/'use strict';
11228
11229 exports.__esModule = true;
11230 exports.lineDiff = undefined;
11231 exports. /*istanbul ignore end*/diffLines = diffLines;
11232 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
11233
11234 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11235
11236 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11237
11238 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
11239
11240 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11241
11242 /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11243 lineDiff.tokenize = function (value) {
11244 var retLines = [],
11245 linesAndNewlines = value.split(/(\n|\r\n)/);
11246
11247 // Ignore the final empty token that occurs if the string ends with a new line
11248 if (!linesAndNewlines[linesAndNewlines.length - 1]) {
11249 linesAndNewlines.pop();
11250 }
11251
11252 // Merge the content and line separators into single tokens
11253 for (var i = 0; i < linesAndNewlines.length; i++) {
11254 var line = linesAndNewlines[i];
11255
11256 if (i % 2 && !this.options.newlineIsToken) {
11257 retLines[retLines.length - 1] += line;
11258 } else {
11259 if (this.options.ignoreWhitespace) {
11260 line = line.trim();
11261 }
11262 retLines.push(line);
11263 }
11264 }
11265
11266 return retLines;
11267 };
11268
11269 function diffLines(oldStr, newStr, callback) {
11270 return lineDiff.diff(oldStr, newStr, callback);
11271 }
11272 function diffTrimmedLines(oldStr, newStr, callback) {
11273 var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
11274 return lineDiff.diff(oldStr, newStr, options);
11275 }
11276
11277
11278
11279/***/ }),
11280/* 6 */
11281/***/ (function(module, exports, __webpack_require__) {
11282
11283 /*istanbul ignore start*/'use strict';
11284
11285 exports.__esModule = true;
11286 exports.sentenceDiff = undefined;
11287 exports. /*istanbul ignore end*/diffSentences = diffSentences;
11288
11289 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11290
11291 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11292
11293 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11294
11295 /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11296 sentenceDiff.tokenize = function (value) {
11297 return value.split(/(\S.+?[.!?])(?=\s+|$)/);
11298 };
11299
11300 function diffSentences(oldStr, newStr, callback) {
11301 return sentenceDiff.diff(oldStr, newStr, callback);
11302 }
11303
11304
11305
11306/***/ }),
11307/* 7 */
11308/***/ (function(module, exports, __webpack_require__) {
11309
11310 /*istanbul ignore start*/'use strict';
11311
11312 exports.__esModule = true;
11313 exports.cssDiff = undefined;
11314 exports. /*istanbul ignore end*/diffCss = diffCss;
11315
11316 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11317
11318 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11319
11320 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11321
11322 /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11323 cssDiff.tokenize = function (value) {
11324 return value.split(/([{}:;,]|\s+)/);
11325 };
11326
11327 function diffCss(oldStr, newStr, callback) {
11328 return cssDiff.diff(oldStr, newStr, callback);
11329 }
11330
11331
11332
11333/***/ }),
11334/* 8 */
11335/***/ (function(module, exports, __webpack_require__) {
11336
11337 /*istanbul ignore start*/'use strict';
11338
11339 exports.__esModule = true;
11340 exports.jsonDiff = undefined;
11341
11342 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
11343
11344 exports. /*istanbul ignore end*/diffJson = diffJson;
11345 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
11346
11347 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11348
11349 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11350
11351 /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
11352
11353 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11354
11355 /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
11356
11357 var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11358 // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
11359 // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
11360 jsonDiff.useLongestToken = true;
11361
11362 jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
11363 jsonDiff.castInput = function (value) {
11364 /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
11365 undefinedReplacement = _options.undefinedReplacement,
11366 _options$stringifyRep = _options.stringifyReplacer,
11367 stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
11368 return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
11369 );
11370 } : _options$stringifyRep;
11371
11372
11373 return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
11374 };
11375 jsonDiff.equals = function (left, right) {
11376 return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
11377 );
11378 };
11379
11380 function diffJson(oldObj, newObj, options) {
11381 return jsonDiff.diff(oldObj, newObj, options);
11382 }
11383
11384 // This function handles the presence of circular references by bailing out when encountering an
11385 // object that is already on the "stack" of items being processed. Accepts an optional replacer
11386 function canonicalize(obj, stack, replacementStack, replacer, key) {
11387 stack = stack || [];
11388 replacementStack = replacementStack || [];
11389
11390 if (replacer) {
11391 obj = replacer(key, obj);
11392 }
11393
11394 var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11395
11396 for (i = 0; i < stack.length; i += 1) {
11397 if (stack[i] === obj) {
11398 return replacementStack[i];
11399 }
11400 }
11401
11402 var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11403
11404 if ('[object Array]' === objectPrototypeToString.call(obj)) {
11405 stack.push(obj);
11406 canonicalizedObj = new Array(obj.length);
11407 replacementStack.push(canonicalizedObj);
11408 for (i = 0; i < obj.length; i += 1) {
11409 canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
11410 }
11411 stack.pop();
11412 replacementStack.pop();
11413 return canonicalizedObj;
11414 }
11415
11416 if (obj && obj.toJSON) {
11417 obj = obj.toJSON();
11418 }
11419
11420 if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
11421 stack.push(obj);
11422 canonicalizedObj = {};
11423 replacementStack.push(canonicalizedObj);
11424 var sortedKeys = [],
11425 _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11426 for (_key in obj) {
11427 /* istanbul ignore else */
11428 if (obj.hasOwnProperty(_key)) {
11429 sortedKeys.push(_key);
11430 }
11431 }
11432 sortedKeys.sort();
11433 for (i = 0; i < sortedKeys.length; i += 1) {
11434 _key = sortedKeys[i];
11435 canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
11436 }
11437 stack.pop();
11438 replacementStack.pop();
11439 } else {
11440 canonicalizedObj = obj;
11441 }
11442 return canonicalizedObj;
11443 }
11444
11445
11446
11447/***/ }),
11448/* 9 */
11449/***/ (function(module, exports, __webpack_require__) {
11450
11451 /*istanbul ignore start*/'use strict';
11452
11453 exports.__esModule = true;
11454 exports.arrayDiff = undefined;
11455 exports. /*istanbul ignore end*/diffArrays = diffArrays;
11456
11457 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11458
11459 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11460
11461 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11462
11463 /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11464 arrayDiff.tokenize = function (value) {
11465 return value.slice();
11466 };
11467 arrayDiff.join = arrayDiff.removeEmpty = function (value) {
11468 return value;
11469 };
11470
11471 function diffArrays(oldArr, newArr, callback) {
11472 return arrayDiff.diff(oldArr, newArr, callback);
11473 }
11474
11475
11476
11477/***/ }),
11478/* 10 */
11479/***/ (function(module, exports, __webpack_require__) {
11480
11481 /*istanbul ignore start*/'use strict';
11482
11483 exports.__esModule = true;
11484 exports. /*istanbul ignore end*/applyPatch = applyPatch;
11485 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
11486
11487 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
11488
11489 var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/;
11490
11491 /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
11492
11493 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11494
11495 /*istanbul ignore end*/function applyPatch(source, uniDiff) {
11496 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11497
11498 if (typeof uniDiff === 'string') {
11499 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
11500 }
11501
11502 if (Array.isArray(uniDiff)) {
11503 if (uniDiff.length > 1) {
11504 throw new Error('applyPatch only works with a single input.');
11505 }
11506
11507 uniDiff = uniDiff[0];
11508 }
11509
11510 // Apply the diff to the input
11511 var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
11512 delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
11513 hunks = uniDiff.hunks,
11514 compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
11515 return (/*istanbul ignore end*/line === patchContent
11516 );
11517 },
11518 errorCount = 0,
11519 fuzzFactor = options.fuzzFactor || 0,
11520 minLine = 0,
11521 offset = 0,
11522 removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
11523 addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11524
11525 /**
11526 * Checks if the hunk exactly fits on the provided location
11527 */
11528 function hunkFits(hunk, toPos) {
11529 for (var j = 0; j < hunk.lines.length; j++) {
11530 var line = hunk.lines[j],
11531 operation = line.length > 0 ? line[0] : ' ',
11532 content = line.length > 0 ? line.substr(1) : line;
11533
11534 if (operation === ' ' || operation === '-') {
11535 // Context sanity check
11536 if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
11537 errorCount++;
11538
11539 if (errorCount > fuzzFactor) {
11540 return false;
11541 }
11542 }
11543 toPos++;
11544 }
11545 }
11546
11547 return true;
11548 }
11549
11550 // Search best fit offsets for each hunk based on the previous ones
11551 for (var i = 0; i < hunks.length; i++) {
11552 var hunk = hunks[i],
11553 maxLine = lines.length - hunk.oldLines,
11554 localOffset = 0,
11555 toPos = offset + hunk.oldStart - 1;
11556
11557 var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
11558
11559 for (; localOffset !== undefined; localOffset = iterator()) {
11560 if (hunkFits(hunk, toPos + localOffset)) {
11561 hunk.offset = offset += localOffset;
11562 break;
11563 }
11564 }
11565
11566 if (localOffset === undefined) {
11567 return false;
11568 }
11569
11570 // Set lower text limit to end of the current hunk, so next ones don't try
11571 // to fit over already patched text
11572 minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
11573 }
11574
11575 // Apply patch hunks
11576 var diffOffset = 0;
11577 for (var _i = 0; _i < hunks.length; _i++) {
11578 var _hunk = hunks[_i],
11579 _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
11580 diffOffset += _hunk.newLines - _hunk.oldLines;
11581
11582 if (_toPos < 0) {
11583 // Creating a new file
11584 _toPos = 0;
11585 }
11586
11587 for (var j = 0; j < _hunk.lines.length; j++) {
11588 var line = _hunk.lines[j],
11589 operation = line.length > 0 ? line[0] : ' ',
11590 content = line.length > 0 ? line.substr(1) : line,
11591 delimiter = _hunk.linedelimiters[j];
11592
11593 if (operation === ' ') {
11594 _toPos++;
11595 } else if (operation === '-') {
11596 lines.splice(_toPos, 1);
11597 delimiters.splice(_toPos, 1);
11598 /* istanbul ignore else */
11599 } else if (operation === '+') {
11600 lines.splice(_toPos, 0, content);
11601 delimiters.splice(_toPos, 0, delimiter);
11602 _toPos++;
11603 } else if (operation === '\\') {
11604 var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
11605 if (previousOperation === '+') {
11606 removeEOFNL = true;
11607 } else if (previousOperation === '-') {
11608 addEOFNL = true;
11609 }
11610 }
11611 }
11612 }
11613
11614 // Handle EOFNL insertion/removal
11615 if (removeEOFNL) {
11616 while (!lines[lines.length - 1]) {
11617 lines.pop();
11618 delimiters.pop();
11619 }
11620 } else if (addEOFNL) {
11621 lines.push('');
11622 delimiters.push('\n');
11623 }
11624 for (var _k = 0; _k < lines.length - 1; _k++) {
11625 lines[_k] = lines[_k] + delimiters[_k];
11626 }
11627 return lines.join('');
11628 }
11629
11630 // Wrapper that supports multiple file patches via callbacks.
11631 function applyPatches(uniDiff, options) {
11632 if (typeof uniDiff === 'string') {
11633 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
11634 }
11635
11636 var currentIndex = 0;
11637 function processIndex() {
11638 var index = uniDiff[currentIndex++];
11639 if (!index) {
11640 return options.complete();
11641 }
11642
11643 options.loadFile(index, function (err, data) {
11644 if (err) {
11645 return options.complete(err);
11646 }
11647
11648 var updatedContent = applyPatch(data, index, options);
11649 options.patched(index, updatedContent, function (err) {
11650 if (err) {
11651 return options.complete(err);
11652 }
11653
11654 processIndex();
11655 });
11656 });
11657 }
11658 processIndex();
11659 }
11660
11661
11662
11663/***/ }),
11664/* 11 */
11665/***/ (function(module, exports) {
11666
11667 /*istanbul ignore start*/'use strict';
11668
11669 exports.__esModule = true;
11670 exports. /*istanbul ignore end*/parsePatch = parsePatch;
11671 function parsePatch(uniDiff) {
11672 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
11673
11674 var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
11675 delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
11676 list = [],
11677 i = 0;
11678
11679 function parseIndex() {
11680 var index = {};
11681 list.push(index);
11682
11683 // Parse diff metadata
11684 while (i < diffstr.length) {
11685 var line = diffstr[i];
11686
11687 // File header found, end parsing diff metadata
11688 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
11689 break;
11690 }
11691
11692 // Diff index
11693 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
11694 if (header) {
11695 index.index = header[1];
11696 }
11697
11698 i++;
11699 }
11700
11701 // Parse file headers if they are defined. Unified diff requires them, but
11702 // there's no technical issues to have an isolated hunk without file header
11703 parseFileHeader(index);
11704 parseFileHeader(index);
11705
11706 // Parse hunks
11707 index.hunks = [];
11708
11709 while (i < diffstr.length) {
11710 var _line = diffstr[i];
11711
11712 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
11713 break;
11714 } else if (/^@@/.test(_line)) {
11715 index.hunks.push(parseHunk());
11716 } else if (_line && options.strict) {
11717 // Ignore unexpected content unless in strict mode
11718 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
11719 } else {
11720 i++;
11721 }
11722 }
11723 }
11724
11725 // Parses the --- and +++ headers, if none are found, no lines
11726 // are consumed.
11727 function parseFileHeader(index) {
11728 var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
11729 if (fileHeader) {
11730 var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
11731 var data = fileHeader[2].split('\t', 2);
11732 var fileName = data[0].replace(/\\\\/g, '\\');
11733 if (/^".*"$/.test(fileName)) {
11734 fileName = fileName.substr(1, fileName.length - 2);
11735 }
11736 index[keyPrefix + 'FileName'] = fileName;
11737 index[keyPrefix + 'Header'] = (data[1] || '').trim();
11738
11739 i++;
11740 }
11741 }
11742
11743 // Parses a hunk
11744 // This assumes that we are at the start of a hunk.
11745 function parseHunk() {
11746 var chunkHeaderIndex = i,
11747 chunkHeaderLine = diffstr[i++],
11748 chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
11749
11750 var hunk = {
11751 oldStart: +chunkHeader[1],
11752 oldLines: +chunkHeader[2] || 1,
11753 newStart: +chunkHeader[3],
11754 newLines: +chunkHeader[4] || 1,
11755 lines: [],
11756 linedelimiters: []
11757 };
11758
11759 var addCount = 0,
11760 removeCount = 0;
11761 for (; i < diffstr.length; i++) {
11762 // Lines starting with '---' could be mistaken for the "remove line" operation
11763 // But they could be the header for the next file. Therefore prune such cases out.
11764 if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
11765 break;
11766 }
11767 var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
11768
11769 if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
11770 hunk.lines.push(diffstr[i]);
11771 hunk.linedelimiters.push(delimiters[i] || '\n');
11772
11773 if (operation === '+') {
11774 addCount++;
11775 } else if (operation === '-') {
11776 removeCount++;
11777 } else if (operation === ' ') {
11778 addCount++;
11779 removeCount++;
11780 }
11781 } else {
11782 break;
11783 }
11784 }
11785
11786 // Handle the empty block count case
11787 if (!addCount && hunk.newLines === 1) {
11788 hunk.newLines = 0;
11789 }
11790 if (!removeCount && hunk.oldLines === 1) {
11791 hunk.oldLines = 0;
11792 }
11793
11794 // Perform optional sanity checking
11795 if (options.strict) {
11796 if (addCount !== hunk.newLines) {
11797 throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
11798 }
11799 if (removeCount !== hunk.oldLines) {
11800 throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
11801 }
11802 }
11803
11804 return hunk;
11805 }
11806
11807 while (i < diffstr.length) {
11808 parseIndex();
11809 }
11810
11811 return list;
11812 }
11813
11814
11815
11816/***/ }),
11817/* 12 */
11818/***/ (function(module, exports) {
11819
11820 /*istanbul ignore start*/"use strict";
11821
11822 exports.__esModule = true;
11823
11824 exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
11825 var wantForward = true,
11826 backwardExhausted = false,
11827 forwardExhausted = false,
11828 localOffset = 1;
11829
11830 return function iterator() {
11831 if (wantForward && !forwardExhausted) {
11832 if (backwardExhausted) {
11833 localOffset++;
11834 } else {
11835 wantForward = false;
11836 }
11837
11838 // Check if trying to fit beyond text length, and if not, check it fits
11839 // after offset location (or desired location on first iteration)
11840 if (start + localOffset <= maxLine) {
11841 return localOffset;
11842 }
11843
11844 forwardExhausted = true;
11845 }
11846
11847 if (!backwardExhausted) {
11848 if (!forwardExhausted) {
11849 wantForward = true;
11850 }
11851
11852 // Check if trying to fit before text beginning, and if not, check it fits
11853 // before offset location
11854 if (minLine <= start - localOffset) {
11855 return -localOffset++;
11856 }
11857
11858 backwardExhausted = true;
11859 return iterator();
11860 }
11861
11862 // We tried to fit hunk before text beginning and beyond text length, then
11863 // hunk can't fit on the text. Return undefined
11864 };
11865 };
11866
11867
11868
11869/***/ }),
11870/* 13 */
11871/***/ (function(module, exports, __webpack_require__) {
11872
11873 /*istanbul ignore start*/'use strict';
11874
11875 exports.__esModule = true;
11876 exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
11877 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
11878
11879 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
11880
11881 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
11882
11883 var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/;
11884
11885 /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
11886
11887 /*istanbul ignore end*/function calcLineCount(hunk) {
11888 /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
11889 oldLines = _calcOldNewLineCount.oldLines,
11890 newLines = _calcOldNewLineCount.newLines;
11891
11892 if (oldLines !== undefined) {
11893 hunk.oldLines = oldLines;
11894 } else {
11895 delete hunk.oldLines;
11896 }
11897
11898 if (newLines !== undefined) {
11899 hunk.newLines = newLines;
11900 } else {
11901 delete hunk.newLines;
11902 }
11903 }
11904
11905 function merge(mine, theirs, base) {
11906 mine = loadPatch(mine, base);
11907 theirs = loadPatch(theirs, base);
11908
11909 var ret = {};
11910
11911 // For index we just let it pass through as it doesn't have any necessary meaning.
11912 // Leaving sanity checks on this to the API consumer that may know more about the
11913 // meaning in their own context.
11914 if (mine.index || theirs.index) {
11915 ret.index = mine.index || theirs.index;
11916 }
11917
11918 if (mine.newFileName || theirs.newFileName) {
11919 if (!fileNameChanged(mine)) {
11920 // No header or no change in ours, use theirs (and ours if theirs does not exist)
11921 ret.oldFileName = theirs.oldFileName || mine.oldFileName;
11922 ret.newFileName = theirs.newFileName || mine.newFileName;
11923 ret.oldHeader = theirs.oldHeader || mine.oldHeader;
11924 ret.newHeader = theirs.newHeader || mine.newHeader;
11925 } else if (!fileNameChanged(theirs)) {
11926 // No header or no change in theirs, use ours
11927 ret.oldFileName = mine.oldFileName;
11928 ret.newFileName = mine.newFileName;
11929 ret.oldHeader = mine.oldHeader;
11930 ret.newHeader = mine.newHeader;
11931 } else {
11932 // Both changed... figure it out
11933 ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
11934 ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
11935 ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
11936 ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
11937 }
11938 }
11939
11940 ret.hunks = [];
11941
11942 var mineIndex = 0,
11943 theirsIndex = 0,
11944 mineOffset = 0,
11945 theirsOffset = 0;
11946
11947 while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
11948 var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
11949 theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
11950
11951 if (hunkBefore(mineCurrent, theirsCurrent)) {
11952 // This patch does not overlap with any of the others, yay.
11953 ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
11954 mineIndex++;
11955 theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
11956 } else if (hunkBefore(theirsCurrent, mineCurrent)) {
11957 // This patch does not overlap with any of the others, yay.
11958 ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
11959 theirsIndex++;
11960 mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
11961 } else {
11962 // Overlap, merge as best we can
11963 var mergedHunk = {
11964 oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
11965 oldLines: 0,
11966 newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
11967 newLines: 0,
11968 lines: []
11969 };
11970 mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
11971 theirsIndex++;
11972 mineIndex++;
11973
11974 ret.hunks.push(mergedHunk);
11975 }
11976 }
11977
11978 return ret;
11979 }
11980
11981 function loadPatch(param, base) {
11982 if (typeof param === 'string') {
11983 if (/^@@/m.test(param) || /^Index:/m.test(param)) {
11984 return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0]
11985 );
11986 }
11987
11988 if (!base) {
11989 throw new Error('Must provide a base reference or pass in a patch');
11990 }
11991 return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
11992 );
11993 }
11994
11995 return param;
11996 }
11997
11998 function fileNameChanged(patch) {
11999 return patch.newFileName && patch.newFileName !== patch.oldFileName;
12000 }
12001
12002 function selectField(index, mine, theirs) {
12003 if (mine === theirs) {
12004 return mine;
12005 } else {
12006 index.conflict = true;
12007 return { mine: mine, theirs: theirs };
12008 }
12009 }
12010
12011 function hunkBefore(test, check) {
12012 return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
12013 }
12014
12015 function cloneHunk(hunk, offset) {
12016 return {
12017 oldStart: hunk.oldStart, oldLines: hunk.oldLines,
12018 newStart: hunk.newStart + offset, newLines: hunk.newLines,
12019 lines: hunk.lines
12020 };
12021 }
12022
12023 function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
12024 // This will generally result in a conflicted hunk, but there are cases where the context
12025 // is the only overlap where we can successfully merge the content here.
12026 var mine = { offset: mineOffset, lines: mineLines, index: 0 },
12027 their = { offset: theirOffset, lines: theirLines, index: 0 };
12028
12029 // Handle any leading content
12030 insertLeading(hunk, mine, their);
12031 insertLeading(hunk, their, mine);
12032
12033 // Now in the overlap content. Scan through and select the best changes from each.
12034 while (mine.index < mine.lines.length && their.index < their.lines.length) {
12035 var mineCurrent = mine.lines[mine.index],
12036 theirCurrent = their.lines[their.index];
12037
12038 if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
12039 // Both modified ...
12040 mutualChange(hunk, mine, their);
12041 } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
12042 /*istanbul ignore start*/var _hunk$lines;
12043
12044 /*istanbul ignore end*/ // Mine inserted
12045 /*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine)));
12046 } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
12047 /*istanbul ignore start*/var _hunk$lines2;
12048
12049 /*istanbul ignore end*/ // Theirs inserted
12050 /*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their)));
12051 } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
12052 // Mine removed or edited
12053 removal(hunk, mine, their);
12054 } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
12055 // Their removed or edited
12056 removal(hunk, their, mine, true);
12057 } else if (mineCurrent === theirCurrent) {
12058 // Context identity
12059 hunk.lines.push(mineCurrent);
12060 mine.index++;
12061 their.index++;
12062 } else {
12063 // Context mismatch
12064 conflict(hunk, collectChange(mine), collectChange(their));
12065 }
12066 }
12067
12068 // Now push anything that may be remaining
12069 insertTrailing(hunk, mine);
12070 insertTrailing(hunk, their);
12071
12072 calcLineCount(hunk);
12073 }
12074
12075 function mutualChange(hunk, mine, their) {
12076 var myChanges = collectChange(mine),
12077 theirChanges = collectChange(their);
12078
12079 if (allRemoves(myChanges) && allRemoves(theirChanges)) {
12080 // Special case for remove changes that are supersets of one another
12081 if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
12082 /*istanbul ignore start*/var _hunk$lines3;
12083
12084 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
12085 return;
12086 } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
12087 /*istanbul ignore start*/var _hunk$lines4;
12088
12089 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges));
12090 return;
12091 }
12092 } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
12093 /*istanbul ignore start*/var _hunk$lines5;
12094
12095 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges));
12096 return;
12097 }
12098
12099 conflict(hunk, myChanges, theirChanges);
12100 }
12101
12102 function removal(hunk, mine, their, swap) {
12103 var myChanges = collectChange(mine),
12104 theirChanges = collectContext(their, myChanges);
12105 if (theirChanges.merged) {
12106 /*istanbul ignore start*/var _hunk$lines6;
12107
12108 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged));
12109 } else {
12110 conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
12111 }
12112 }
12113
12114 function conflict(hunk, mine, their) {
12115 hunk.conflict = true;
12116 hunk.lines.push({
12117 conflict: true,
12118 mine: mine,
12119 theirs: their
12120 });
12121 }
12122
12123 function insertLeading(hunk, insert, their) {
12124 while (insert.offset < their.offset && insert.index < insert.lines.length) {
12125 var line = insert.lines[insert.index++];
12126 hunk.lines.push(line);
12127 insert.offset++;
12128 }
12129 }
12130 function insertTrailing(hunk, insert) {
12131 while (insert.index < insert.lines.length) {
12132 var line = insert.lines[insert.index++];
12133 hunk.lines.push(line);
12134 }
12135 }
12136
12137 function collectChange(state) {
12138 var ret = [],
12139 operation = state.lines[state.index][0];
12140 while (state.index < state.lines.length) {
12141 var line = state.lines[state.index];
12142
12143 // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
12144 if (operation === '-' && line[0] === '+') {
12145 operation = '+';
12146 }
12147
12148 if (operation === line[0]) {
12149 ret.push(line);
12150 state.index++;
12151 } else {
12152 break;
12153 }
12154 }
12155
12156 return ret;
12157 }
12158 function collectContext(state, matchChanges) {
12159 var changes = [],
12160 merged = [],
12161 matchIndex = 0,
12162 contextChanges = false,
12163 conflicted = false;
12164 while (matchIndex < matchChanges.length && state.index < state.lines.length) {
12165 var change = state.lines[state.index],
12166 match = matchChanges[matchIndex];
12167
12168 // Once we've hit our add, then we are done
12169 if (match[0] === '+') {
12170 break;
12171 }
12172
12173 contextChanges = contextChanges || change[0] !== ' ';
12174
12175 merged.push(match);
12176 matchIndex++;
12177
12178 // Consume any additions in the other block as a conflict to attempt
12179 // to pull in the remaining context after this
12180 if (change[0] === '+') {
12181 conflicted = true;
12182
12183 while (change[0] === '+') {
12184 changes.push(change);
12185 change = state.lines[++state.index];
12186 }
12187 }
12188
12189 if (match.substr(1) === change.substr(1)) {
12190 changes.push(change);
12191 state.index++;
12192 } else {
12193 conflicted = true;
12194 }
12195 }
12196
12197 if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
12198 conflicted = true;
12199 }
12200
12201 if (conflicted) {
12202 return changes;
12203 }
12204
12205 while (matchIndex < matchChanges.length) {
12206 merged.push(matchChanges[matchIndex++]);
12207 }
12208
12209 return {
12210 merged: merged,
12211 changes: changes
12212 };
12213 }
12214
12215 function allRemoves(changes) {
12216 return changes.reduce(function (prev, change) {
12217 return prev && change[0] === '-';
12218 }, true);
12219 }
12220 function skipRemoveSuperset(state, removeChanges, delta) {
12221 for (var i = 0; i < delta; i++) {
12222 var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
12223 if (state.lines[state.index + i] !== ' ' + changeContent) {
12224 return false;
12225 }
12226 }
12227
12228 state.index += delta;
12229 return true;
12230 }
12231
12232 function calcOldNewLineCount(lines) {
12233 var oldLines = 0;
12234 var newLines = 0;
12235
12236 lines.forEach(function (line) {
12237 if (typeof line !== 'string') {
12238 var myCount = calcOldNewLineCount(line.mine);
12239 var theirCount = calcOldNewLineCount(line.theirs);
12240
12241 if (oldLines !== undefined) {
12242 if (myCount.oldLines === theirCount.oldLines) {
12243 oldLines += myCount.oldLines;
12244 } else {
12245 oldLines = undefined;
12246 }
12247 }
12248
12249 if (newLines !== undefined) {
12250 if (myCount.newLines === theirCount.newLines) {
12251 newLines += myCount.newLines;
12252 } else {
12253 newLines = undefined;
12254 }
12255 }
12256 } else {
12257 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
12258 newLines++;
12259 }
12260 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
12261 oldLines++;
12262 }
12263 }
12264 });
12265
12266 return { oldLines: oldLines, newLines: newLines };
12267 }
12268
12269
12270
12271/***/ }),
12272/* 14 */
12273/***/ (function(module, exports, __webpack_require__) {
12274
12275 /*istanbul ignore start*/'use strict';
12276
12277 exports.__esModule = true;
12278 exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
12279 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
12280 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
12281
12282 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
12283
12284 /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
12285
12286 /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
12287 if (!options) {
12288 options = {};
12289 }
12290 if (typeof options.context === 'undefined') {
12291 options.context = 4;
12292 }
12293
12294 var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
12295 diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
12296
12297 function contextLines(lines) {
12298 return lines.map(function (entry) {
12299 return ' ' + entry;
12300 });
12301 }
12302
12303 var hunks = [];
12304 var oldRangeStart = 0,
12305 newRangeStart = 0,
12306 curRange = [],
12307 oldLine = 1,
12308 newLine = 1;
12309
12310 /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
12311 var current = diff[i],
12312 lines = current.lines || current.value.replace(/\n$/, '').split('\n');
12313 current.lines = lines;
12314
12315 if (current.added || current.removed) {
12316 /*istanbul ignore start*/var _curRange;
12317
12318 /*istanbul ignore end*/ // If we have previous context, start with that
12319 if (!oldRangeStart) {
12320 var prev = diff[i - 1];
12321 oldRangeStart = oldLine;
12322 newRangeStart = newLine;
12323
12324 if (prev) {
12325 curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
12326 oldRangeStart -= curRange.length;
12327 newRangeStart -= curRange.length;
12328 }
12329 }
12330
12331 // Output our changes
12332 /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) {
12333 return (current.added ? '+' : '-') + entry;
12334 })));
12335
12336 // Track the updated file position
12337 if (current.added) {
12338 newLine += lines.length;
12339 } else {
12340 oldLine += lines.length;
12341 }
12342 } else {
12343 // Identical context lines. Track line changes
12344 if (oldRangeStart) {
12345 // Close out any changes that have been output (or join overlapping)
12346 if (lines.length <= options.context * 2 && i < diff.length - 2) {
12347 /*istanbul ignore start*/var _curRange2;
12348
12349 /*istanbul ignore end*/ // Overlapping
12350 /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines)));
12351 } else {
12352 /*istanbul ignore start*/var _curRange3;
12353
12354 /*istanbul ignore end*/ // end the range and output
12355 var contextSize = Math.min(lines.length, options.context);
12356 /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize))));
12357
12358 var hunk = {
12359 oldStart: oldRangeStart,
12360 oldLines: oldLine - oldRangeStart + contextSize,
12361 newStart: newRangeStart,
12362 newLines: newLine - newRangeStart + contextSize,
12363 lines: curRange
12364 };
12365 if (i >= diff.length - 2 && lines.length <= options.context) {
12366 // EOF is inside this hunk
12367 var oldEOFNewline = /\n$/.test(oldStr);
12368 var newEOFNewline = /\n$/.test(newStr);
12369 if (lines.length == 0 && !oldEOFNewline) {
12370 // special case: old has no eol and no trailing context; no-nl can end up before adds
12371 curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
12372 } else if (!oldEOFNewline || !newEOFNewline) {
12373 curRange.push('\\ No newline at end of file');
12374 }
12375 }
12376 hunks.push(hunk);
12377
12378 oldRangeStart = 0;
12379 newRangeStart = 0;
12380 curRange = [];
12381 }
12382 }
12383 oldLine += lines.length;
12384 newLine += lines.length;
12385 }
12386 };
12387
12388 for (var i = 0; i < diff.length; i++) {
12389 /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
12390 }
12391
12392 return {
12393 oldFileName: oldFileName, newFileName: newFileName,
12394 oldHeader: oldHeader, newHeader: newHeader,
12395 hunks: hunks
12396 };
12397 }
12398
12399 function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
12400 var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
12401
12402 var ret = [];
12403 if (oldFileName == newFileName) {
12404 ret.push('Index: ' + oldFileName);
12405 }
12406 ret.push('===================================================================');
12407 ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
12408 ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
12409
12410 for (var i = 0; i < diff.hunks.length; i++) {
12411 var hunk = diff.hunks[i];
12412 ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
12413 ret.push.apply(ret, hunk.lines);
12414 }
12415
12416 return ret.join('\n') + '\n';
12417 }
12418
12419 function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
12420 return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
12421 }
12422
12423
12424
12425/***/ }),
12426/* 15 */
12427/***/ (function(module, exports) {
12428
12429 /*istanbul ignore start*/"use strict";
12430
12431 exports.__esModule = true;
12432 exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
12433 /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
12434 function arrayEqual(a, b) {
12435 if (a.length !== b.length) {
12436 return false;
12437 }
12438
12439 return arrayStartsWith(a, b);
12440 }
12441
12442 function arrayStartsWith(array, start) {
12443 if (start.length > array.length) {
12444 return false;
12445 }
12446
12447 for (var i = 0; i < start.length; i++) {
12448 if (start[i] !== array[i]) {
12449 return false;
12450 }
12451 }
12452
12453 return true;
12454 }
12455
12456
12457
12458/***/ }),
12459/* 16 */
12460/***/ (function(module, exports) {
12461
12462 /*istanbul ignore start*/"use strict";
12463
12464 exports.__esModule = true;
12465 exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
12466 // See: http://code.google.com/p/google-diff-match-patch/wiki/API
12467 function convertChangesToDMP(changes) {
12468 var ret = [],
12469 change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
12470 operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
12471 for (var i = 0; i < changes.length; i++) {
12472 change = changes[i];
12473 if (change.added) {
12474 operation = 1;
12475 } else if (change.removed) {
12476 operation = -1;
12477 } else {
12478 operation = 0;
12479 }
12480
12481 ret.push([operation, change.value]);
12482 }
12483 return ret;
12484 }
12485
12486
12487
12488/***/ }),
12489/* 17 */
12490/***/ (function(module, exports) {
12491
12492 /*istanbul ignore start*/'use strict';
12493
12494 exports.__esModule = true;
12495 exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
12496 function convertChangesToXML(changes) {
12497 var ret = [];
12498 for (var i = 0; i < changes.length; i++) {
12499 var change = changes[i];
12500 if (change.added) {
12501 ret.push('<ins>');
12502 } else if (change.removed) {
12503 ret.push('<del>');
12504 }
12505
12506 ret.push(escapeHTML(change.value));
12507
12508 if (change.added) {
12509 ret.push('</ins>');
12510 } else if (change.removed) {
12511 ret.push('</del>');
12512 }
12513 }
12514 return ret.join('');
12515 }
12516
12517 function escapeHTML(s) {
12518 var n = s;
12519 n = n.replace(/&/g, '&amp;');
12520 n = n.replace(/</g, '&lt;');
12521 n = n.replace(/>/g, '&gt;');
12522 n = n.replace(/"/g, '&quot;');
12523
12524 return n;
12525 }
12526
12527
12528
12529/***/ })
12530/******/ ])
12531});
12532;
12533},{}],49:[function(require,module,exports){
12534'use strict';
12535
12536var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
12537
12538module.exports = function (str) {
12539 if (typeof str !== 'string') {
12540 throw new TypeError('Expected a string');
12541 }
12542
12543 return str.replace(matchOperatorsRe, '\\$&');
12544};
12545
12546},{}],50:[function(require,module,exports){
12547// Copyright Joyent, Inc. and other Node contributors.
12548//
12549// Permission is hereby granted, free of charge, to any person obtaining a
12550// copy of this software and associated documentation files (the
12551// "Software"), to deal in the Software without restriction, including
12552// without limitation the rights to use, copy, modify, merge, publish,
12553// distribute, sublicense, and/or sell copies of the Software, and to permit
12554// persons to whom the Software is furnished to do so, subject to the
12555// following conditions:
12556//
12557// The above copyright notice and this permission notice shall be included
12558// in all copies or substantial portions of the Software.
12559//
12560// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12561// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12562// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12563// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12564// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12565// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12566// USE OR OTHER DEALINGS IN THE SOFTWARE.
12567
12568var objectCreate = Object.create || objectCreatePolyfill
12569var objectKeys = Object.keys || objectKeysPolyfill
12570var bind = Function.prototype.bind || functionBindPolyfill
12571
12572function EventEmitter() {
12573 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
12574 this._events = objectCreate(null);
12575 this._eventsCount = 0;
12576 }
12577
12578 this._maxListeners = this._maxListeners || undefined;
12579}
12580module.exports = EventEmitter;
12581
12582// Backwards-compat with node 0.10.x
12583EventEmitter.EventEmitter = EventEmitter;
12584
12585EventEmitter.prototype._events = undefined;
12586EventEmitter.prototype._maxListeners = undefined;
12587
12588// By default EventEmitters will print a warning if more than 10 listeners are
12589// added to it. This is a useful default which helps finding memory leaks.
12590var defaultMaxListeners = 10;
12591
12592var hasDefineProperty;
12593try {
12594 var o = {};
12595 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
12596 hasDefineProperty = o.x === 0;
12597} catch (err) { hasDefineProperty = false }
12598if (hasDefineProperty) {
12599 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
12600 enumerable: true,
12601 get: function() {
12602 return defaultMaxListeners;
12603 },
12604 set: function(arg) {
12605 // check whether the input is a positive number (whose value is zero or
12606 // greater and not a NaN).
12607 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
12608 throw new TypeError('"defaultMaxListeners" must be a positive number');
12609 defaultMaxListeners = arg;
12610 }
12611 });
12612} else {
12613 EventEmitter.defaultMaxListeners = defaultMaxListeners;
12614}
12615
12616// Obviously not all Emitters should be limited to 10. This function allows
12617// that to be increased. Set to zero for unlimited.
12618EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
12619 if (typeof n !== 'number' || n < 0 || isNaN(n))
12620 throw new TypeError('"n" argument must be a positive number');
12621 this._maxListeners = n;
12622 return this;
12623};
12624
12625function $getMaxListeners(that) {
12626 if (that._maxListeners === undefined)
12627 return EventEmitter.defaultMaxListeners;
12628 return that._maxListeners;
12629}
12630
12631EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
12632 return $getMaxListeners(this);
12633};
12634
12635// These standalone emit* functions are used to optimize calling of event
12636// handlers for fast cases because emit() itself often has a variable number of
12637// arguments and can be deoptimized because of that. These functions always have
12638// the same number of arguments and thus do not get deoptimized, so the code
12639// inside them can execute faster.
12640function emitNone(handler, isFn, self) {
12641 if (isFn)
12642 handler.call(self);
12643 else {
12644 var len = handler.length;
12645 var listeners = arrayClone(handler, len);
12646 for (var i = 0; i < len; ++i)
12647 listeners[i].call(self);
12648 }
12649}
12650function emitOne(handler, isFn, self, arg1) {
12651 if (isFn)
12652 handler.call(self, arg1);
12653 else {
12654 var len = handler.length;
12655 var listeners = arrayClone(handler, len);
12656 for (var i = 0; i < len; ++i)
12657 listeners[i].call(self, arg1);
12658 }
12659}
12660function emitTwo(handler, isFn, self, arg1, arg2) {
12661 if (isFn)
12662 handler.call(self, arg1, arg2);
12663 else {
12664 var len = handler.length;
12665 var listeners = arrayClone(handler, len);
12666 for (var i = 0; i < len; ++i)
12667 listeners[i].call(self, arg1, arg2);
12668 }
12669}
12670function emitThree(handler, isFn, self, arg1, arg2, arg3) {
12671 if (isFn)
12672 handler.call(self, arg1, arg2, arg3);
12673 else {
12674 var len = handler.length;
12675 var listeners = arrayClone(handler, len);
12676 for (var i = 0; i < len; ++i)
12677 listeners[i].call(self, arg1, arg2, arg3);
12678 }
12679}
12680
12681function emitMany(handler, isFn, self, args) {
12682 if (isFn)
12683 handler.apply(self, args);
12684 else {
12685 var len = handler.length;
12686 var listeners = arrayClone(handler, len);
12687 for (var i = 0; i < len; ++i)
12688 listeners[i].apply(self, args);
12689 }
12690}
12691
12692EventEmitter.prototype.emit = function emit(type) {
12693 var er, handler, len, args, i, events;
12694 var doError = (type === 'error');
12695
12696 events = this._events;
12697 if (events)
12698 doError = (doError && events.error == null);
12699 else if (!doError)
12700 return false;
12701
12702 // If there is no 'error' event listener then throw.
12703 if (doError) {
12704 if (arguments.length > 1)
12705 er = arguments[1];
12706 if (er instanceof Error) {
12707 throw er; // Unhandled 'error' event
12708 } else {
12709 // At least give some kind of context to the user
12710 var err = new Error('Unhandled "error" event. (' + er + ')');
12711 err.context = er;
12712 throw err;
12713 }
12714 return false;
12715 }
12716
12717 handler = events[type];
12718
12719 if (!handler)
12720 return false;
12721
12722 var isFn = typeof handler === 'function';
12723 len = arguments.length;
12724 switch (len) {
12725 // fast cases
12726 case 1:
12727 emitNone(handler, isFn, this);
12728 break;
12729 case 2:
12730 emitOne(handler, isFn, this, arguments[1]);
12731 break;
12732 case 3:
12733 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
12734 break;
12735 case 4:
12736 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
12737 break;
12738 // slower
12739 default:
12740 args = new Array(len - 1);
12741 for (i = 1; i < len; i++)
12742 args[i - 1] = arguments[i];
12743 emitMany(handler, isFn, this, args);
12744 }
12745
12746 return true;
12747};
12748
12749function _addListener(target, type, listener, prepend) {
12750 var m;
12751 var events;
12752 var existing;
12753
12754 if (typeof listener !== 'function')
12755 throw new TypeError('"listener" argument must be a function');
12756
12757 events = target._events;
12758 if (!events) {
12759 events = target._events = objectCreate(null);
12760 target._eventsCount = 0;
12761 } else {
12762 // To avoid recursion in the case that type === "newListener"! Before
12763 // adding it to the listeners, first emit "newListener".
12764 if (events.newListener) {
12765 target.emit('newListener', type,
12766 listener.listener ? listener.listener : listener);
12767
12768 // Re-assign `events` because a newListener handler could have caused the
12769 // this._events to be assigned to a new object
12770 events = target._events;
12771 }
12772 existing = events[type];
12773 }
12774
12775 if (!existing) {
12776 // Optimize the case of one listener. Don't need the extra array object.
12777 existing = events[type] = listener;
12778 ++target._eventsCount;
12779 } else {
12780 if (typeof existing === 'function') {
12781 // Adding the second element, need to change to array.
12782 existing = events[type] =
12783 prepend ? [listener, existing] : [existing, listener];
12784 } else {
12785 // If we've already got an array, just append.
12786 if (prepend) {
12787 existing.unshift(listener);
12788 } else {
12789 existing.push(listener);
12790 }
12791 }
12792
12793 // Check for listener leak
12794 if (!existing.warned) {
12795 m = $getMaxListeners(target);
12796 if (m && m > 0 && existing.length > m) {
12797 existing.warned = true;
12798 var w = new Error('Possible EventEmitter memory leak detected. ' +
12799 existing.length + ' "' + String(type) + '" listeners ' +
12800 'added. Use emitter.setMaxListeners() to ' +
12801 'increase limit.');
12802 w.name = 'MaxListenersExceededWarning';
12803 w.emitter = target;
12804 w.type = type;
12805 w.count = existing.length;
12806 if (typeof console === 'object' && console.warn) {
12807 console.warn('%s: %s', w.name, w.message);
12808 }
12809 }
12810 }
12811 }
12812
12813 return target;
12814}
12815
12816EventEmitter.prototype.addListener = function addListener(type, listener) {
12817 return _addListener(this, type, listener, false);
12818};
12819
12820EventEmitter.prototype.on = EventEmitter.prototype.addListener;
12821
12822EventEmitter.prototype.prependListener =
12823 function prependListener(type, listener) {
12824 return _addListener(this, type, listener, true);
12825 };
12826
12827function onceWrapper() {
12828 if (!this.fired) {
12829 this.target.removeListener(this.type, this.wrapFn);
12830 this.fired = true;
12831 switch (arguments.length) {
12832 case 0:
12833 return this.listener.call(this.target);
12834 case 1:
12835 return this.listener.call(this.target, arguments[0]);
12836 case 2:
12837 return this.listener.call(this.target, arguments[0], arguments[1]);
12838 case 3:
12839 return this.listener.call(this.target, arguments[0], arguments[1],
12840 arguments[2]);
12841 default:
12842 var args = new Array(arguments.length);
12843 for (var i = 0; i < args.length; ++i)
12844 args[i] = arguments[i];
12845 this.listener.apply(this.target, args);
12846 }
12847 }
12848}
12849
12850function _onceWrap(target, type, listener) {
12851 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
12852 var wrapped = bind.call(onceWrapper, state);
12853 wrapped.listener = listener;
12854 state.wrapFn = wrapped;
12855 return wrapped;
12856}
12857
12858EventEmitter.prototype.once = function once(type, listener) {
12859 if (typeof listener !== 'function')
12860 throw new TypeError('"listener" argument must be a function');
12861 this.on(type, _onceWrap(this, type, listener));
12862 return this;
12863};
12864
12865EventEmitter.prototype.prependOnceListener =
12866 function prependOnceListener(type, listener) {
12867 if (typeof listener !== 'function')
12868 throw new TypeError('"listener" argument must be a function');
12869 this.prependListener(type, _onceWrap(this, type, listener));
12870 return this;
12871 };
12872
12873// Emits a 'removeListener' event if and only if the listener was removed.
12874EventEmitter.prototype.removeListener =
12875 function removeListener(type, listener) {
12876 var list, events, position, i, originalListener;
12877
12878 if (typeof listener !== 'function')
12879 throw new TypeError('"listener" argument must be a function');
12880
12881 events = this._events;
12882 if (!events)
12883 return this;
12884
12885 list = events[type];
12886 if (!list)
12887 return this;
12888
12889 if (list === listener || list.listener === listener) {
12890 if (--this._eventsCount === 0)
12891 this._events = objectCreate(null);
12892 else {
12893 delete events[type];
12894 if (events.removeListener)
12895 this.emit('removeListener', type, list.listener || listener);
12896 }
12897 } else if (typeof list !== 'function') {
12898 position = -1;
12899
12900 for (i = list.length - 1; i >= 0; i--) {
12901 if (list[i] === listener || list[i].listener === listener) {
12902 originalListener = list[i].listener;
12903 position = i;
12904 break;
12905 }
12906 }
12907
12908 if (position < 0)
12909 return this;
12910
12911 if (position === 0)
12912 list.shift();
12913 else
12914 spliceOne(list, position);
12915
12916 if (list.length === 1)
12917 events[type] = list[0];
12918
12919 if (events.removeListener)
12920 this.emit('removeListener', type, originalListener || listener);
12921 }
12922
12923 return this;
12924 };
12925
12926EventEmitter.prototype.removeAllListeners =
12927 function removeAllListeners(type) {
12928 var listeners, events, i;
12929
12930 events = this._events;
12931 if (!events)
12932 return this;
12933
12934 // not listening for removeListener, no need to emit
12935 if (!events.removeListener) {
12936 if (arguments.length === 0) {
12937 this._events = objectCreate(null);
12938 this._eventsCount = 0;
12939 } else if (events[type]) {
12940 if (--this._eventsCount === 0)
12941 this._events = objectCreate(null);
12942 else
12943 delete events[type];
12944 }
12945 return this;
12946 }
12947
12948 // emit removeListener for all listeners on all events
12949 if (arguments.length === 0) {
12950 var keys = objectKeys(events);
12951 var key;
12952 for (i = 0; i < keys.length; ++i) {
12953 key = keys[i];
12954 if (key === 'removeListener') continue;
12955 this.removeAllListeners(key);
12956 }
12957 this.removeAllListeners('removeListener');
12958 this._events = objectCreate(null);
12959 this._eventsCount = 0;
12960 return this;
12961 }
12962
12963 listeners = events[type];
12964
12965 if (typeof listeners === 'function') {
12966 this.removeListener(type, listeners);
12967 } else if (listeners) {
12968 // LIFO order
12969 for (i = listeners.length - 1; i >= 0; i--) {
12970 this.removeListener(type, listeners[i]);
12971 }
12972 }
12973
12974 return this;
12975 };
12976
12977function _listeners(target, type, unwrap) {
12978 var events = target._events;
12979
12980 if (!events)
12981 return [];
12982
12983 var evlistener = events[type];
12984 if (!evlistener)
12985 return [];
12986
12987 if (typeof evlistener === 'function')
12988 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
12989
12990 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
12991}
12992
12993EventEmitter.prototype.listeners = function listeners(type) {
12994 return _listeners(this, type, true);
12995};
12996
12997EventEmitter.prototype.rawListeners = function rawListeners(type) {
12998 return _listeners(this, type, false);
12999};
13000
13001EventEmitter.listenerCount = function(emitter, type) {
13002 if (typeof emitter.listenerCount === 'function') {
13003 return emitter.listenerCount(type);
13004 } else {
13005 return listenerCount.call(emitter, type);
13006 }
13007};
13008
13009EventEmitter.prototype.listenerCount = listenerCount;
13010function listenerCount(type) {
13011 var events = this._events;
13012
13013 if (events) {
13014 var evlistener = events[type];
13015
13016 if (typeof evlistener === 'function') {
13017 return 1;
13018 } else if (evlistener) {
13019 return evlistener.length;
13020 }
13021 }
13022
13023 return 0;
13024}
13025
13026EventEmitter.prototype.eventNames = function eventNames() {
13027 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
13028};
13029
13030// About 1.5x faster than the two-arg version of Array#splice().
13031function spliceOne(list, index) {
13032 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
13033 list[i] = list[k];
13034 list.pop();
13035}
13036
13037function arrayClone(arr, n) {
13038 var copy = new Array(n);
13039 for (var i = 0; i < n; ++i)
13040 copy[i] = arr[i];
13041 return copy;
13042}
13043
13044function unwrapListeners(arr) {
13045 var ret = new Array(arr.length);
13046 for (var i = 0; i < ret.length; ++i) {
13047 ret[i] = arr[i].listener || arr[i];
13048 }
13049 return ret;
13050}
13051
13052function objectCreatePolyfill(proto) {
13053 var F = function() {};
13054 F.prototype = proto;
13055 return new F;
13056}
13057function objectKeysPolyfill(obj) {
13058 var keys = [];
13059 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
13060 keys.push(k);
13061 }
13062 return k;
13063}
13064function functionBindPolyfill(context) {
13065 var fn = this;
13066 return function () {
13067 return fn.apply(context, arguments);
13068 };
13069}
13070
13071},{}],51:[function(require,module,exports){
13072'use strict';
13073
13074/* eslint no-invalid-this: 1 */
13075
13076var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
13077var slice = Array.prototype.slice;
13078var toStr = Object.prototype.toString;
13079var funcType = '[object Function]';
13080
13081module.exports = function bind(that) {
13082 var target = this;
13083 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
13084 throw new TypeError(ERROR_MESSAGE + target);
13085 }
13086 var args = slice.call(arguments, 1);
13087
13088 var bound;
13089 var binder = function () {
13090 if (this instanceof bound) {
13091 var result = target.apply(
13092 this,
13093 args.concat(slice.call(arguments))
13094 );
13095 if (Object(result) === result) {
13096 return result;
13097 }
13098 return this;
13099 } else {
13100 return target.apply(
13101 that,
13102 args.concat(slice.call(arguments))
13103 );
13104 }
13105 };
13106
13107 var boundLength = Math.max(0, target.length - args.length);
13108 var boundArgs = [];
13109 for (var i = 0; i < boundLength; i++) {
13110 boundArgs.push('$' + i);
13111 }
13112
13113 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
13114
13115 if (target.prototype) {
13116 var Empty = function Empty() {};
13117 Empty.prototype = target.prototype;
13118 bound.prototype = new Empty();
13119 Empty.prototype = null;
13120 }
13121
13122 return bound;
13123};
13124
13125},{}],52:[function(require,module,exports){
13126'use strict';
13127
13128var implementation = require('./implementation');
13129
13130module.exports = Function.prototype.bind || implementation;
13131
13132},{"./implementation":51}],53:[function(require,module,exports){
13133'use strict';
13134
13135/* eslint complexity: [2, 17], max-statements: [2, 33] */
13136module.exports = function hasSymbols() {
13137 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
13138 if (typeof Symbol.iterator === 'symbol') { return true; }
13139
13140 var obj = {};
13141 var sym = Symbol('test');
13142 var symObj = Object(sym);
13143 if (typeof sym === 'string') { return false; }
13144
13145 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
13146 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
13147
13148 // temp disabled per https://github.com/ljharb/object.assign/issues/17
13149 // if (sym instanceof Symbol) { return false; }
13150 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
13151 // if (!(symObj instanceof Symbol)) { return false; }
13152
13153 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
13154 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
13155
13156 var symVal = 42;
13157 obj[sym] = symVal;
13158 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
13159 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
13160
13161 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
13162
13163 var syms = Object.getOwnPropertySymbols(obj);
13164 if (syms.length !== 1 || syms[0] !== sym) { return false; }
13165
13166 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
13167
13168 if (typeof Object.getOwnPropertyDescriptor === 'function') {
13169 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
13170 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
13171 }
13172
13173 return true;
13174};
13175
13176},{}],54:[function(require,module,exports){
13177(function (global){
13178/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
13179;(function(root) {
13180
13181 // Detect free variables `exports`.
13182 var freeExports = typeof exports == 'object' && exports;
13183
13184 // Detect free variable `module`.
13185 var freeModule = typeof module == 'object' && module &&
13186 module.exports == freeExports && module;
13187
13188 // Detect free variable `global`, from Node.js or Browserified code,
13189 // and use it as `root`.
13190 var freeGlobal = typeof global == 'object' && global;
13191 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
13192 root = freeGlobal;
13193 }
13194
13195 /*--------------------------------------------------------------------------*/
13196
13197 // All astral symbols.
13198 var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
13199 // All ASCII symbols (not just printable ASCII) except those listed in the
13200 // first column of the overrides table.
13201 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
13202 var regexAsciiWhitelist = /[\x01-\x7F]/g;
13203 // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
13204 // code points listed in the first column of the overrides table on
13205 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
13206 var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
13207
13208 var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g;
13209 var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'};
13210
13211 var regexEscape = /["&'<>`]/g;
13212 var escapeMap = {
13213 '"': '&quot;',
13214 '&': '&amp;',
13215 '\'': '&#x27;',
13216 '<': '&lt;',
13217 // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
13218 // following is not strictly necessary unless it’s part of a tag or an
13219 // unquoted attribute value. We’re only escaping it to support those
13220 // situations, and for XML support.
13221 '>': '&gt;',
13222 // In Internet Explorer ≤ 8, the backtick character can be used
13223 // to break out of (un)quoted attribute values or HTML comments.
13224 // See http://html5sec.org/#102, http://html5sec.org/#108, and
13225 // http://html5sec.org/#133.
13226 '`': '&#x60;'
13227 };
13228
13229 var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
13230 var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
13231 var regexDecode = /&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g;
13232 var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'};
13233 var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'};
13234 var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'};
13235 var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111];
13236
13237 /*--------------------------------------------------------------------------*/
13238
13239 var stringFromCharCode = String.fromCharCode;
13240
13241 var object = {};
13242 var hasOwnProperty = object.hasOwnProperty;
13243 var has = function(object, propertyName) {
13244 return hasOwnProperty.call(object, propertyName);
13245 };
13246
13247 var contains = function(array, value) {
13248 var index = -1;
13249 var length = array.length;
13250 while (++index < length) {
13251 if (array[index] == value) {
13252 return true;
13253 }
13254 }
13255 return false;
13256 };
13257
13258 var merge = function(options, defaults) {
13259 if (!options) {
13260 return defaults;
13261 }
13262 var result = {};
13263 var key;
13264 for (key in defaults) {
13265 // A `hasOwnProperty` check is not needed here, since only recognized
13266 // option names are used anyway. Any others are ignored.
13267 result[key] = has(options, key) ? options[key] : defaults[key];
13268 }
13269 return result;
13270 };
13271
13272 // Modified version of `ucs2encode`; see https://mths.be/punycode.
13273 var codePointToSymbol = function(codePoint, strict) {
13274 var output = '';
13275 if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
13276 // See issue #4:
13277 // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
13278 // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
13279 // REPLACEMENT CHARACTER.”
13280 if (strict) {
13281 parseError('character reference outside the permissible Unicode range');
13282 }
13283 return '\uFFFD';
13284 }
13285 if (has(decodeMapNumeric, codePoint)) {
13286 if (strict) {
13287 parseError('disallowed character reference');
13288 }
13289 return decodeMapNumeric[codePoint];
13290 }
13291 if (strict && contains(invalidReferenceCodePoints, codePoint)) {
13292 parseError('disallowed character reference');
13293 }
13294 if (codePoint > 0xFFFF) {
13295 codePoint -= 0x10000;
13296 output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
13297 codePoint = 0xDC00 | codePoint & 0x3FF;
13298 }
13299 output += stringFromCharCode(codePoint);
13300 return output;
13301 };
13302
13303 var hexEscape = function(codePoint) {
13304 return '&#x' + codePoint.toString(16).toUpperCase() + ';';
13305 };
13306
13307 var decEscape = function(codePoint) {
13308 return '&#' + codePoint + ';';
13309 };
13310
13311 var parseError = function(message) {
13312 throw Error('Parse error: ' + message);
13313 };
13314
13315 /*--------------------------------------------------------------------------*/
13316
13317 var encode = function(string, options) {
13318 options = merge(options, encode.options);
13319 var strict = options.strict;
13320 if (strict && regexInvalidRawCodePoint.test(string)) {
13321 parseError('forbidden code point');
13322 }
13323 var encodeEverything = options.encodeEverything;
13324 var useNamedReferences = options.useNamedReferences;
13325 var allowUnsafeSymbols = options.allowUnsafeSymbols;
13326 var escapeCodePoint = options.decimal ? decEscape : hexEscape;
13327
13328 var escapeBmpSymbol = function(symbol) {
13329 return escapeCodePoint(symbol.charCodeAt(0));
13330 };
13331
13332 if (encodeEverything) {
13333 // Encode ASCII symbols.
13334 string = string.replace(regexAsciiWhitelist, function(symbol) {
13335 // Use named references if requested & possible.
13336 if (useNamedReferences && has(encodeMap, symbol)) {
13337 return '&' + encodeMap[symbol] + ';';
13338 }
13339 return escapeBmpSymbol(symbol);
13340 });
13341 // Shorten a few escapes that represent two symbols, of which at least one
13342 // is within the ASCII range.
13343 if (useNamedReferences) {
13344 string = string
13345 .replace(/&gt;\u20D2/g, '&nvgt;')
13346 .replace(/&lt;\u20D2/g, '&nvlt;')
13347 .replace(/&#x66;&#x6A;/g, '&fjlig;');
13348 }
13349 // Encode non-ASCII symbols.
13350 if (useNamedReferences) {
13351 // Encode non-ASCII symbols that can be replaced with a named reference.
13352 string = string.replace(regexEncodeNonAscii, function(string) {
13353 // Note: there is no need to check `has(encodeMap, string)` here.
13354 return '&' + encodeMap[string] + ';';
13355 });
13356 }
13357 // Note: any remaining non-ASCII symbols are handled outside of the `if`.
13358 } else if (useNamedReferences) {
13359 // Apply named character references.
13360 // Encode `<>"'&` using named character references.
13361 if (!allowUnsafeSymbols) {
13362 string = string.replace(regexEscape, function(string) {
13363 return '&' + encodeMap[string] + ';'; // no need to check `has()` here
13364 });
13365 }
13366 // Shorten escapes that represent two symbols, of which at least one is
13367 // `<>"'&`.
13368 string = string
13369 .replace(/&gt;\u20D2/g, '&nvgt;')
13370 .replace(/&lt;\u20D2/g, '&nvlt;');
13371 // Encode non-ASCII symbols that can be replaced with a named reference.
13372 string = string.replace(regexEncodeNonAscii, function(string) {
13373 // Note: there is no need to check `has(encodeMap, string)` here.
13374 return '&' + encodeMap[string] + ';';
13375 });
13376 } else if (!allowUnsafeSymbols) {
13377 // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
13378 // using named character references.
13379 string = string.replace(regexEscape, escapeBmpSymbol);
13380 }
13381 return string
13382 // Encode astral symbols.
13383 .replace(regexAstralSymbols, function($0) {
13384 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
13385 var high = $0.charCodeAt(0);
13386 var low = $0.charCodeAt(1);
13387 var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
13388 return escapeCodePoint(codePoint);
13389 })
13390 // Encode any remaining BMP symbols that are not printable ASCII symbols
13391 // using a hexadecimal escape.
13392 .replace(regexBmpWhitelist, escapeBmpSymbol);
13393 };
13394 // Expose default options (so they can be overridden globally).
13395 encode.options = {
13396 'allowUnsafeSymbols': false,
13397 'encodeEverything': false,
13398 'strict': false,
13399 'useNamedReferences': false,
13400 'decimal' : false
13401 };
13402
13403 var decode = function(html, options) {
13404 options = merge(options, decode.options);
13405 var strict = options.strict;
13406 if (strict && regexInvalidEntity.test(html)) {
13407 parseError('malformed character reference');
13408 }
13409 return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
13410 var codePoint;
13411 var semicolon;
13412 var decDigits;
13413 var hexDigits;
13414 var reference;
13415 var next;
13416
13417 if ($1) {
13418 reference = $1;
13419 // Note: there is no need to check `has(decodeMap, reference)`.
13420 return decodeMap[reference];
13421 }
13422
13423 if ($2) {
13424 // Decode named character references without trailing `;`, e.g. `&amp`.
13425 // This is only a parse error if it gets converted to `&`, or if it is
13426 // followed by `=` in an attribute context.
13427 reference = $2;
13428 next = $3;
13429 if (next && options.isAttributeValue) {
13430 if (strict && next == '=') {
13431 parseError('`&` did not start a character reference');
13432 }
13433 return $0;
13434 } else {
13435 if (strict) {
13436 parseError(
13437 'named character reference was not terminated by a semicolon'
13438 );
13439 }
13440 // Note: there is no need to check `has(decodeMapLegacy, reference)`.
13441 return decodeMapLegacy[reference] + (next || '');
13442 }
13443 }
13444
13445 if ($4) {
13446 // Decode decimal escapes, e.g. `&#119558;`.
13447 decDigits = $4;
13448 semicolon = $5;
13449 if (strict && !semicolon) {
13450 parseError('character reference was not terminated by a semicolon');
13451 }
13452 codePoint = parseInt(decDigits, 10);
13453 return codePointToSymbol(codePoint, strict);
13454 }
13455
13456 if ($6) {
13457 // Decode hexadecimal escapes, e.g. `&#x1D306;`.
13458 hexDigits = $6;
13459 semicolon = $7;
13460 if (strict && !semicolon) {
13461 parseError('character reference was not terminated by a semicolon');
13462 }
13463 codePoint = parseInt(hexDigits, 16);
13464 return codePointToSymbol(codePoint, strict);
13465 }
13466
13467 // If we’re still here, `if ($7)` is implied; it’s an ambiguous
13468 // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
13469 if (strict) {
13470 parseError(
13471 'named character reference was not terminated by a semicolon'
13472 );
13473 }
13474 return $0;
13475 });
13476 };
13477 // Expose default options (so they can be overridden globally).
13478 decode.options = {
13479 'isAttributeValue': false,
13480 'strict': false
13481 };
13482
13483 var escape = function(string) {
13484 return string.replace(regexEscape, function($0) {
13485 // Note: there is no need to check `has(escapeMap, $0)` here.
13486 return escapeMap[$0];
13487 });
13488 };
13489
13490 /*--------------------------------------------------------------------------*/
13491
13492 var he = {
13493 'version': '1.2.0',
13494 'encode': encode,
13495 'decode': decode,
13496 'escape': escape,
13497 'unescape': decode
13498 };
13499
13500 // Some AMD build optimizers, like r.js, check for specific condition patterns
13501 // like the following:
13502 if (
13503 false
13504 ) {
13505 define(function() {
13506 return he;
13507 });
13508 } else if (freeExports && !freeExports.nodeType) {
13509 if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
13510 freeModule.exports = he;
13511 } else { // in Narwhal or RingoJS v0.7.0-
13512 for (var key in he) {
13513 has(he, key) && (freeExports[key] = he[key]);
13514 }
13515 }
13516 } else { // in Rhino or a web browser
13517 root.he = he;
13518 }
13519
13520}(this));
13521
13522}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
13523},{}],55:[function(require,module,exports){
13524exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13525 var e, m
13526 var eLen = (nBytes * 8) - mLen - 1
13527 var eMax = (1 << eLen) - 1
13528 var eBias = eMax >> 1
13529 var nBits = -7
13530 var i = isLE ? (nBytes - 1) : 0
13531 var d = isLE ? -1 : 1
13532 var s = buffer[offset + i]
13533
13534 i += d
13535
13536 e = s & ((1 << (-nBits)) - 1)
13537 s >>= (-nBits)
13538 nBits += eLen
13539 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13540
13541 m = e & ((1 << (-nBits)) - 1)
13542 e >>= (-nBits)
13543 nBits += mLen
13544 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13545
13546 if (e === 0) {
13547 e = 1 - eBias
13548 } else if (e === eMax) {
13549 return m ? NaN : ((s ? -1 : 1) * Infinity)
13550 } else {
13551 m = m + Math.pow(2, mLen)
13552 e = e - eBias
13553 }
13554 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13555}
13556
13557exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13558 var e, m, c
13559 var eLen = (nBytes * 8) - mLen - 1
13560 var eMax = (1 << eLen) - 1
13561 var eBias = eMax >> 1
13562 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
13563 var i = isLE ? 0 : (nBytes - 1)
13564 var d = isLE ? 1 : -1
13565 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
13566
13567 value = Math.abs(value)
13568
13569 if (isNaN(value) || value === Infinity) {
13570 m = isNaN(value) ? 1 : 0
13571 e = eMax
13572 } else {
13573 e = Math.floor(Math.log(value) / Math.LN2)
13574 if (value * (c = Math.pow(2, -e)) < 1) {
13575 e--
13576 c *= 2
13577 }
13578 if (e + eBias >= 1) {
13579 value += rt / c
13580 } else {
13581 value += rt * Math.pow(2, 1 - eBias)
13582 }
13583 if (value * c >= 2) {
13584 e++
13585 c /= 2
13586 }
13587
13588 if (e + eBias >= eMax) {
13589 m = 0
13590 e = eMax
13591 } else if (e + eBias >= 1) {
13592 m = ((value * c) - 1) * Math.pow(2, mLen)
13593 e = e + eBias
13594 } else {
13595 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
13596 e = 0
13597 }
13598 }
13599
13600 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13601
13602 e = (e << mLen) | m
13603 eLen += mLen
13604 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13605
13606 buffer[offset + i - d] |= s * 128
13607}
13608
13609},{}],56:[function(require,module,exports){
13610if (typeof Object.create === 'function') {
13611 // implementation from standard node.js 'util' module
13612 module.exports = function inherits(ctor, superCtor) {
13613 ctor.super_ = superCtor
13614 ctor.prototype = Object.create(superCtor.prototype, {
13615 constructor: {
13616 value: ctor,
13617 enumerable: false,
13618 writable: true,
13619 configurable: true
13620 }
13621 });
13622 };
13623} else {
13624 // old school shim for old browsers
13625 module.exports = function inherits(ctor, superCtor) {
13626 ctor.super_ = superCtor
13627 var TempCtor = function () {}
13628 TempCtor.prototype = superCtor.prototype
13629 ctor.prototype = new TempCtor()
13630 ctor.prototype.constructor = ctor
13631 }
13632}
13633
13634},{}],57:[function(require,module,exports){
13635/*!
13636 * Determine if an object is a Buffer
13637 *
13638 * @author Feross Aboukhadijeh <https://feross.org>
13639 * @license MIT
13640 */
13641
13642// The _isBuffer check is for Safari 5-7 support, because it's missing
13643// Object.prototype.constructor. Remove this eventually
13644module.exports = function (obj) {
13645 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
13646}
13647
13648function isBuffer (obj) {
13649 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
13650}
13651
13652// For Node v0.10 support. Remove this eventually.
13653function isSlowBuffer (obj) {
13654 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
13655}
13656
13657},{}],58:[function(require,module,exports){
13658var toString = {}.toString;
13659
13660module.exports = Array.isArray || function (arr) {
13661 return toString.call(arr) == '[object Array]';
13662};
13663
13664},{}],59:[function(require,module,exports){
13665(function (process){
13666var path = require('path');
13667var fs = require('fs');
13668var _0777 = parseInt('0777', 8);
13669
13670module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
13671
13672function mkdirP (p, opts, f, made) {
13673 if (typeof opts === 'function') {
13674 f = opts;
13675 opts = {};
13676 }
13677 else if (!opts || typeof opts !== 'object') {
13678 opts = { mode: opts };
13679 }
13680
13681 var mode = opts.mode;
13682 var xfs = opts.fs || fs;
13683
13684 if (mode === undefined) {
13685 mode = _0777 & (~process.umask());
13686 }
13687 if (!made) made = null;
13688
13689 var cb = f || function () {};
13690 p = path.resolve(p);
13691
13692 xfs.mkdir(p, mode, function (er) {
13693 if (!er) {
13694 made = made || p;
13695 return cb(null, made);
13696 }
13697 switch (er.code) {
13698 case 'ENOENT':
13699 mkdirP(path.dirname(p), opts, function (er, made) {
13700 if (er) cb(er, made);
13701 else mkdirP(p, opts, cb, made);
13702 });
13703 break;
13704
13705 // In the case of any other error, just see if there's a dir
13706 // there already. If so, then hooray! If not, then something
13707 // is borked.
13708 default:
13709 xfs.stat(p, function (er2, stat) {
13710 // if the stat fails, then that's super weird.
13711 // let the original error be the failure reason.
13712 if (er2 || !stat.isDirectory()) cb(er, made)
13713 else cb(null, made);
13714 });
13715 break;
13716 }
13717 });
13718}
13719
13720mkdirP.sync = function sync (p, opts, made) {
13721 if (!opts || typeof opts !== 'object') {
13722 opts = { mode: opts };
13723 }
13724
13725 var mode = opts.mode;
13726 var xfs = opts.fs || fs;
13727
13728 if (mode === undefined) {
13729 mode = _0777 & (~process.umask());
13730 }
13731 if (!made) made = null;
13732
13733 p = path.resolve(p);
13734
13735 try {
13736 xfs.mkdirSync(p, mode);
13737 made = made || p;
13738 }
13739 catch (err0) {
13740 switch (err0.code) {
13741 case 'ENOENT' :
13742 made = sync(path.dirname(p), opts, made);
13743 sync(p, opts, made);
13744 break;
13745
13746 // In the case of any other error, just see if there's a dir
13747 // there already. If so, then hooray! If not, then something
13748 // is borked.
13749 default:
13750 var stat;
13751 try {
13752 stat = xfs.statSync(p);
13753 }
13754 catch (err1) {
13755 throw err0;
13756 }
13757 if (!stat.isDirectory()) throw err0;
13758 break;
13759 }
13760 }
13761
13762 return made;
13763};
13764
13765}).call(this,require('_process'))
13766},{"_process":68,"fs":42,"path":42}],60:[function(require,module,exports){
13767/**
13768 * Helpers.
13769 */
13770
13771var s = 1000;
13772var m = s * 60;
13773var h = m * 60;
13774var d = h * 24;
13775var w = d * 7;
13776var y = d * 365.25;
13777
13778/**
13779 * Parse or format the given `val`.
13780 *
13781 * Options:
13782 *
13783 * - `long` verbose formatting [false]
13784 *
13785 * @param {String|Number} val
13786 * @param {Object} [options]
13787 * @throws {Error} throw an error if val is not a non-empty string or a number
13788 * @return {String|Number}
13789 * @api public
13790 */
13791
13792module.exports = function(val, options) {
13793 options = options || {};
13794 var type = typeof val;
13795 if (type === 'string' && val.length > 0) {
13796 return parse(val);
13797 } else if (type === 'number' && isNaN(val) === false) {
13798 return options.long ? fmtLong(val) : fmtShort(val);
13799 }
13800 throw new Error(
13801 'val is not a non-empty string or a valid number. val=' +
13802 JSON.stringify(val)
13803 );
13804};
13805
13806/**
13807 * Parse the given `str` and return milliseconds.
13808 *
13809 * @param {String} str
13810 * @return {Number}
13811 * @api private
13812 */
13813
13814function parse(str) {
13815 str = String(str);
13816 if (str.length > 100) {
13817 return;
13818 }
13819 var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
13820 str
13821 );
13822 if (!match) {
13823 return;
13824 }
13825 var n = parseFloat(match[1]);
13826 var type = (match[2] || 'ms').toLowerCase();
13827 switch (type) {
13828 case 'years':
13829 case 'year':
13830 case 'yrs':
13831 case 'yr':
13832 case 'y':
13833 return n * y;
13834 case 'weeks':
13835 case 'week':
13836 case 'w':
13837 return n * w;
13838 case 'days':
13839 case 'day':
13840 case 'd':
13841 return n * d;
13842 case 'hours':
13843 case 'hour':
13844 case 'hrs':
13845 case 'hr':
13846 case 'h':
13847 return n * h;
13848 case 'minutes':
13849 case 'minute':
13850 case 'mins':
13851 case 'min':
13852 case 'm':
13853 return n * m;
13854 case 'seconds':
13855 case 'second':
13856 case 'secs':
13857 case 'sec':
13858 case 's':
13859 return n * s;
13860 case 'milliseconds':
13861 case 'millisecond':
13862 case 'msecs':
13863 case 'msec':
13864 case 'ms':
13865 return n;
13866 default:
13867 return undefined;
13868 }
13869}
13870
13871/**
13872 * Short format for `ms`.
13873 *
13874 * @param {Number} ms
13875 * @return {String}
13876 * @api private
13877 */
13878
13879function fmtShort(ms) {
13880 var msAbs = Math.abs(ms);
13881 if (msAbs >= d) {
13882 return Math.round(ms / d) + 'd';
13883 }
13884 if (msAbs >= h) {
13885 return Math.round(ms / h) + 'h';
13886 }
13887 if (msAbs >= m) {
13888 return Math.round(ms / m) + 'm';
13889 }
13890 if (msAbs >= s) {
13891 return Math.round(ms / s) + 's';
13892 }
13893 return ms + 'ms';
13894}
13895
13896/**
13897 * Long format for `ms`.
13898 *
13899 * @param {Number} ms
13900 * @return {String}
13901 * @api private
13902 */
13903
13904function fmtLong(ms) {
13905 var msAbs = Math.abs(ms);
13906 if (msAbs >= d) {
13907 return plural(ms, msAbs, d, 'day');
13908 }
13909 if (msAbs >= h) {
13910 return plural(ms, msAbs, h, 'hour');
13911 }
13912 if (msAbs >= m) {
13913 return plural(ms, msAbs, m, 'minute');
13914 }
13915 if (msAbs >= s) {
13916 return plural(ms, msAbs, s, 'second');
13917 }
13918 return ms + ' ms';
13919}
13920
13921/**
13922 * Pluralization helper.
13923 */
13924
13925function plural(ms, msAbs, n, name) {
13926 var isPlural = msAbs >= n * 1.5;
13927 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
13928}
13929
13930},{}],61:[function(require,module,exports){
13931'use strict';
13932
13933// modified from https://github.com/es-shims/es5-shim
13934var has = Object.prototype.hasOwnProperty;
13935var toStr = Object.prototype.toString;
13936var slice = Array.prototype.slice;
13937var isArgs = require('./isArguments');
13938var isEnumerable = Object.prototype.propertyIsEnumerable;
13939var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
13940var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
13941var dontEnums = [
13942 'toString',
13943 'toLocaleString',
13944 'valueOf',
13945 'hasOwnProperty',
13946 'isPrototypeOf',
13947 'propertyIsEnumerable',
13948 'constructor'
13949];
13950var equalsConstructorPrototype = function (o) {
13951 var ctor = o.constructor;
13952 return ctor && ctor.prototype === o;
13953};
13954var excludedKeys = {
13955 $applicationCache: true,
13956 $console: true,
13957 $external: true,
13958 $frame: true,
13959 $frameElement: true,
13960 $frames: true,
13961 $innerHeight: true,
13962 $innerWidth: true,
13963 $outerHeight: true,
13964 $outerWidth: true,
13965 $pageXOffset: true,
13966 $pageYOffset: true,
13967 $parent: true,
13968 $scrollLeft: true,
13969 $scrollTop: true,
13970 $scrollX: true,
13971 $scrollY: true,
13972 $self: true,
13973 $webkitIndexedDB: true,
13974 $webkitStorageInfo: true,
13975 $window: true
13976};
13977var hasAutomationEqualityBug = (function () {
13978 /* global window */
13979 if (typeof window === 'undefined') { return false; }
13980 for (var k in window) {
13981 try {
13982 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
13983 try {
13984 equalsConstructorPrototype(window[k]);
13985 } catch (e) {
13986 return true;
13987 }
13988 }
13989 } catch (e) {
13990 return true;
13991 }
13992 }
13993 return false;
13994}());
13995var equalsConstructorPrototypeIfNotBuggy = function (o) {
13996 /* global window */
13997 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
13998 return equalsConstructorPrototype(o);
13999 }
14000 try {
14001 return equalsConstructorPrototype(o);
14002 } catch (e) {
14003 return false;
14004 }
14005};
14006
14007var keysShim = function keys(object) {
14008 var isObject = object !== null && typeof object === 'object';
14009 var isFunction = toStr.call(object) === '[object Function]';
14010 var isArguments = isArgs(object);
14011 var isString = isObject && toStr.call(object) === '[object String]';
14012 var theKeys = [];
14013
14014 if (!isObject && !isFunction && !isArguments) {
14015 throw new TypeError('Object.keys called on a non-object');
14016 }
14017
14018 var skipProto = hasProtoEnumBug && isFunction;
14019 if (isString && object.length > 0 && !has.call(object, 0)) {
14020 for (var i = 0; i < object.length; ++i) {
14021 theKeys.push(String(i));
14022 }
14023 }
14024
14025 if (isArguments && object.length > 0) {
14026 for (var j = 0; j < object.length; ++j) {
14027 theKeys.push(String(j));
14028 }
14029 } else {
14030 for (var name in object) {
14031 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
14032 theKeys.push(String(name));
14033 }
14034 }
14035 }
14036
14037 if (hasDontEnumBug) {
14038 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
14039
14040 for (var k = 0; k < dontEnums.length; ++k) {
14041 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
14042 theKeys.push(dontEnums[k]);
14043 }
14044 }
14045 }
14046 return theKeys;
14047};
14048
14049keysShim.shim = function shimObjectKeys() {
14050 if (Object.keys) {
14051 var keysWorksWithArguments = (function () {
14052 // Safari 5.0 bug
14053 return (Object.keys(arguments) || '').length === 2;
14054 }(1, 2));
14055 if (!keysWorksWithArguments) {
14056 var originalKeys = Object.keys;
14057 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
14058 if (isArgs(object)) {
14059 return originalKeys(slice.call(object));
14060 } else {
14061 return originalKeys(object);
14062 }
14063 };
14064 }
14065 } else {
14066 Object.keys = keysShim;
14067 }
14068 return Object.keys || keysShim;
14069};
14070
14071module.exports = keysShim;
14072
14073},{"./isArguments":62}],62:[function(require,module,exports){
14074'use strict';
14075
14076var toStr = Object.prototype.toString;
14077
14078module.exports = function isArguments(value) {
14079 var str = toStr.call(value);
14080 var isArgs = str === '[object Arguments]';
14081 if (!isArgs) {
14082 isArgs = str !== '[object Array]' &&
14083 value !== null &&
14084 typeof value === 'object' &&
14085 typeof value.length === 'number' &&
14086 value.length >= 0 &&
14087 toStr.call(value.callee) === '[object Function]';
14088 }
14089 return isArgs;
14090};
14091
14092},{}],63:[function(require,module,exports){
14093'use strict';
14094
14095// modified from https://github.com/es-shims/es6-shim
14096var keys = require('object-keys');
14097var bind = require('function-bind');
14098var canBeObject = function (obj) {
14099 return typeof obj !== 'undefined' && obj !== null;
14100};
14101var hasSymbols = require('has-symbols/shams')();
14102var toObject = Object;
14103var push = bind.call(Function.call, Array.prototype.push);
14104var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
14105var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
14106
14107module.exports = function assign(target, source1) {
14108 if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
14109 var objTarget = toObject(target);
14110 var s, source, i, props, syms, value, key;
14111 for (s = 1; s < arguments.length; ++s) {
14112 source = toObject(arguments[s]);
14113 props = keys(source);
14114 var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
14115 if (getSymbols) {
14116 syms = getSymbols(source);
14117 for (i = 0; i < syms.length; ++i) {
14118 key = syms[i];
14119 if (propIsEnumerable(source, key)) {
14120 push(props, key);
14121 }
14122 }
14123 }
14124 for (i = 0; i < props.length; ++i) {
14125 key = props[i];
14126 value = source[key];
14127 if (propIsEnumerable(source, key)) {
14128 objTarget[key] = value;
14129 }
14130 }
14131 }
14132 return objTarget;
14133};
14134
14135},{"function-bind":52,"has-symbols/shams":53,"object-keys":61}],64:[function(require,module,exports){
14136'use strict';
14137
14138var defineProperties = require('define-properties');
14139
14140var implementation = require('./implementation');
14141var getPolyfill = require('./polyfill');
14142var shim = require('./shim');
14143
14144var polyfill = getPolyfill();
14145
14146defineProperties(polyfill, {
14147 getPolyfill: getPolyfill,
14148 implementation: implementation,
14149 shim: shim
14150});
14151
14152module.exports = polyfill;
14153
14154},{"./implementation":63,"./polyfill":65,"./shim":66,"define-properties":47}],65:[function(require,module,exports){
14155'use strict';
14156
14157var implementation = require('./implementation');
14158
14159var lacksProperEnumerationOrder = function () {
14160 if (!Object.assign) {
14161 return false;
14162 }
14163 // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
14164 // note: this does not detect the bug unless there's 20 characters
14165 var str = 'abcdefghijklmnopqrst';
14166 var letters = str.split('');
14167 var map = {};
14168 for (var i = 0; i < letters.length; ++i) {
14169 map[letters[i]] = letters[i];
14170 }
14171 var obj = Object.assign({}, map);
14172 var actual = '';
14173 for (var k in obj) {
14174 actual += k;
14175 }
14176 return str !== actual;
14177};
14178
14179var assignHasPendingExceptions = function () {
14180 if (!Object.assign || !Object.preventExtensions) {
14181 return false;
14182 }
14183 // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
14184 // which is 72% slower than our shim, and Firefox 40's native implementation.
14185 var thrower = Object.preventExtensions({ 1: 2 });
14186 try {
14187 Object.assign(thrower, 'xy');
14188 } catch (e) {
14189 return thrower[1] === 'y';
14190 }
14191 return false;
14192};
14193
14194module.exports = function getPolyfill() {
14195 if (!Object.assign) {
14196 return implementation;
14197 }
14198 if (lacksProperEnumerationOrder()) {
14199 return implementation;
14200 }
14201 if (assignHasPendingExceptions()) {
14202 return implementation;
14203 }
14204 return Object.assign;
14205};
14206
14207},{"./implementation":63}],66:[function(require,module,exports){
14208'use strict';
14209
14210var define = require('define-properties');
14211var getPolyfill = require('./polyfill');
14212
14213module.exports = function shimAssign() {
14214 var polyfill = getPolyfill();
14215 define(
14216 Object,
14217 { assign: polyfill },
14218 { assign: function () { return Object.assign !== polyfill; } }
14219 );
14220 return polyfill;
14221};
14222
14223},{"./polyfill":65,"define-properties":47}],67:[function(require,module,exports){
14224(function (process){
14225'use strict';
14226
14227if (!process.version ||
14228 process.version.indexOf('v0.') === 0 ||
14229 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
14230 module.exports = { nextTick: nextTick };
14231} else {
14232 module.exports = process
14233}
14234
14235function nextTick(fn, arg1, arg2, arg3) {
14236 if (typeof fn !== 'function') {
14237 throw new TypeError('"callback" argument must be a function');
14238 }
14239 var len = arguments.length;
14240 var args, i;
14241 switch (len) {
14242 case 0:
14243 case 1:
14244 return process.nextTick(fn);
14245 case 2:
14246 return process.nextTick(function afterTickOne() {
14247 fn.call(null, arg1);
14248 });
14249 case 3:
14250 return process.nextTick(function afterTickTwo() {
14251 fn.call(null, arg1, arg2);
14252 });
14253 case 4:
14254 return process.nextTick(function afterTickThree() {
14255 fn.call(null, arg1, arg2, arg3);
14256 });
14257 default:
14258 args = new Array(len - 1);
14259 i = 0;
14260 while (i < args.length) {
14261 args[i++] = arguments[i];
14262 }
14263 return process.nextTick(function afterTick() {
14264 fn.apply(null, args);
14265 });
14266 }
14267}
14268
14269
14270}).call(this,require('_process'))
14271},{"_process":68}],68:[function(require,module,exports){
14272// shim for using process in browser
14273var process = module.exports = {};
14274
14275// cached from whatever global is present so that test runners that stub it
14276// don't break things. But we need to wrap it in a try catch in case it is
14277// wrapped in strict mode code which doesn't define any globals. It's inside a
14278// function because try/catches deoptimize in certain engines.
14279
14280var cachedSetTimeout;
14281var cachedClearTimeout;
14282
14283function defaultSetTimout() {
14284 throw new Error('setTimeout has not been defined');
14285}
14286function defaultClearTimeout () {
14287 throw new Error('clearTimeout has not been defined');
14288}
14289(function () {
14290 try {
14291 if (typeof setTimeout === 'function') {
14292 cachedSetTimeout = setTimeout;
14293 } else {
14294 cachedSetTimeout = defaultSetTimout;
14295 }
14296 } catch (e) {
14297 cachedSetTimeout = defaultSetTimout;
14298 }
14299 try {
14300 if (typeof clearTimeout === 'function') {
14301 cachedClearTimeout = clearTimeout;
14302 } else {
14303 cachedClearTimeout = defaultClearTimeout;
14304 }
14305 } catch (e) {
14306 cachedClearTimeout = defaultClearTimeout;
14307 }
14308} ())
14309function runTimeout(fun) {
14310 if (cachedSetTimeout === setTimeout) {
14311 //normal enviroments in sane situations
14312 return setTimeout(fun, 0);
14313 }
14314 // if setTimeout wasn't available but was latter defined
14315 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
14316 cachedSetTimeout = setTimeout;
14317 return setTimeout(fun, 0);
14318 }
14319 try {
14320 // when when somebody has screwed with setTimeout but no I.E. maddness
14321 return cachedSetTimeout(fun, 0);
14322 } catch(e){
14323 try {
14324 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14325 return cachedSetTimeout.call(null, fun, 0);
14326 } catch(e){
14327 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
14328 return cachedSetTimeout.call(this, fun, 0);
14329 }
14330 }
14331
14332
14333}
14334function runClearTimeout(marker) {
14335 if (cachedClearTimeout === clearTimeout) {
14336 //normal enviroments in sane situations
14337 return clearTimeout(marker);
14338 }
14339 // if clearTimeout wasn't available but was latter defined
14340 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
14341 cachedClearTimeout = clearTimeout;
14342 return clearTimeout(marker);
14343 }
14344 try {
14345 // when when somebody has screwed with setTimeout but no I.E. maddness
14346 return cachedClearTimeout(marker);
14347 } catch (e){
14348 try {
14349 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14350 return cachedClearTimeout.call(null, marker);
14351 } catch (e){
14352 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
14353 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
14354 return cachedClearTimeout.call(this, marker);
14355 }
14356 }
14357
14358
14359
14360}
14361var queue = [];
14362var draining = false;
14363var currentQueue;
14364var queueIndex = -1;
14365
14366function cleanUpNextTick() {
14367 if (!draining || !currentQueue) {
14368 return;
14369 }
14370 draining = false;
14371 if (currentQueue.length) {
14372 queue = currentQueue.concat(queue);
14373 } else {
14374 queueIndex = -1;
14375 }
14376 if (queue.length) {
14377 drainQueue();
14378 }
14379}
14380
14381function drainQueue() {
14382 if (draining) {
14383 return;
14384 }
14385 var timeout = runTimeout(cleanUpNextTick);
14386 draining = true;
14387
14388 var len = queue.length;
14389 while(len) {
14390 currentQueue = queue;
14391 queue = [];
14392 while (++queueIndex < len) {
14393 if (currentQueue) {
14394 currentQueue[queueIndex].run();
14395 }
14396 }
14397 queueIndex = -1;
14398 len = queue.length;
14399 }
14400 currentQueue = null;
14401 draining = false;
14402 runClearTimeout(timeout);
14403}
14404
14405process.nextTick = function (fun) {
14406 var args = new Array(arguments.length - 1);
14407 if (arguments.length > 1) {
14408 for (var i = 1; i < arguments.length; i++) {
14409 args[i - 1] = arguments[i];
14410 }
14411 }
14412 queue.push(new Item(fun, args));
14413 if (queue.length === 1 && !draining) {
14414 runTimeout(drainQueue);
14415 }
14416};
14417
14418// v8 likes predictible objects
14419function Item(fun, array) {
14420 this.fun = fun;
14421 this.array = array;
14422}
14423Item.prototype.run = function () {
14424 this.fun.apply(null, this.array);
14425};
14426process.title = 'browser';
14427process.browser = true;
14428process.env = {};
14429process.argv = [];
14430process.version = ''; // empty string to avoid regexp issues
14431process.versions = {};
14432
14433function noop() {}
14434
14435process.on = noop;
14436process.addListener = noop;
14437process.once = noop;
14438process.off = noop;
14439process.removeListener = noop;
14440process.removeAllListeners = noop;
14441process.emit = noop;
14442process.prependListener = noop;
14443process.prependOnceListener = noop;
14444
14445process.listeners = function (name) { return [] }
14446
14447process.binding = function (name) {
14448 throw new Error('process.binding is not supported');
14449};
14450
14451process.cwd = function () { return '/' };
14452process.chdir = function (dir) {
14453 throw new Error('process.chdir is not supported');
14454};
14455process.umask = function() { return 0; };
14456
14457},{}],69:[function(require,module,exports){
14458module.exports = require('./lib/_stream_duplex.js');
14459
14460},{"./lib/_stream_duplex.js":70}],70:[function(require,module,exports){
14461// Copyright Joyent, Inc. and other Node contributors.
14462//
14463// Permission is hereby granted, free of charge, to any person obtaining a
14464// copy of this software and associated documentation files (the
14465// "Software"), to deal in the Software without restriction, including
14466// without limitation the rights to use, copy, modify, merge, publish,
14467// distribute, sublicense, and/or sell copies of the Software, and to permit
14468// persons to whom the Software is furnished to do so, subject to the
14469// following conditions:
14470//
14471// The above copyright notice and this permission notice shall be included
14472// in all copies or substantial portions of the Software.
14473//
14474// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14475// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14476// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14477// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14478// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14479// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14480// USE OR OTHER DEALINGS IN THE SOFTWARE.
14481
14482// a duplex stream is just a stream that is both readable and writable.
14483// Since JS doesn't have multiple prototypal inheritance, this class
14484// prototypally inherits from Readable, and then parasitically from
14485// Writable.
14486
14487'use strict';
14488
14489/*<replacement>*/
14490
14491var pna = require('process-nextick-args');
14492/*</replacement>*/
14493
14494/*<replacement>*/
14495var objectKeys = Object.keys || function (obj) {
14496 var keys = [];
14497 for (var key in obj) {
14498 keys.push(key);
14499 }return keys;
14500};
14501/*</replacement>*/
14502
14503module.exports = Duplex;
14504
14505/*<replacement>*/
14506var util = require('core-util-is');
14507util.inherits = require('inherits');
14508/*</replacement>*/
14509
14510var Readable = require('./_stream_readable');
14511var Writable = require('./_stream_writable');
14512
14513util.inherits(Duplex, Readable);
14514
14515{
14516 // avoid scope creep, the keys array can then be collected
14517 var keys = objectKeys(Writable.prototype);
14518 for (var v = 0; v < keys.length; v++) {
14519 var method = keys[v];
14520 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
14521 }
14522}
14523
14524function Duplex(options) {
14525 if (!(this instanceof Duplex)) return new Duplex(options);
14526
14527 Readable.call(this, options);
14528 Writable.call(this, options);
14529
14530 if (options && options.readable === false) this.readable = false;
14531
14532 if (options && options.writable === false) this.writable = false;
14533
14534 this.allowHalfOpen = true;
14535 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
14536
14537 this.once('end', onend);
14538}
14539
14540Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
14541 // making it explicit this property is not enumerable
14542 // because otherwise some prototype manipulation in
14543 // userland will fail
14544 enumerable: false,
14545 get: function () {
14546 return this._writableState.highWaterMark;
14547 }
14548});
14549
14550// the no-half-open enforcer
14551function onend() {
14552 // if we allow half-open state, or if the writable side ended,
14553 // then we're ok.
14554 if (this.allowHalfOpen || this._writableState.ended) return;
14555
14556 // no more data can be written.
14557 // But allow more writes to happen in this tick.
14558 pna.nextTick(onEndNT, this);
14559}
14560
14561function onEndNT(self) {
14562 self.end();
14563}
14564
14565Object.defineProperty(Duplex.prototype, 'destroyed', {
14566 get: function () {
14567 if (this._readableState === undefined || this._writableState === undefined) {
14568 return false;
14569 }
14570 return this._readableState.destroyed && this._writableState.destroyed;
14571 },
14572 set: function (value) {
14573 // we ignore the value if the stream
14574 // has not been initialized yet
14575 if (this._readableState === undefined || this._writableState === undefined) {
14576 return;
14577 }
14578
14579 // backward compatibility, the user is explicitly
14580 // managing destroyed
14581 this._readableState.destroyed = value;
14582 this._writableState.destroyed = value;
14583 }
14584});
14585
14586Duplex.prototype._destroy = function (err, cb) {
14587 this.push(null);
14588 this.end();
14589
14590 pna.nextTick(cb, err);
14591};
14592},{"./_stream_readable":72,"./_stream_writable":74,"core-util-is":44,"inherits":56,"process-nextick-args":67}],71:[function(require,module,exports){
14593// Copyright Joyent, Inc. and other Node contributors.
14594//
14595// Permission is hereby granted, free of charge, to any person obtaining a
14596// copy of this software and associated documentation files (the
14597// "Software"), to deal in the Software without restriction, including
14598// without limitation the rights to use, copy, modify, merge, publish,
14599// distribute, sublicense, and/or sell copies of the Software, and to permit
14600// persons to whom the Software is furnished to do so, subject to the
14601// following conditions:
14602//
14603// The above copyright notice and this permission notice shall be included
14604// in all copies or substantial portions of the Software.
14605//
14606// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14607// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14608// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14609// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14610// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14611// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14612// USE OR OTHER DEALINGS IN THE SOFTWARE.
14613
14614// a passthrough stream.
14615// basically just the most minimal sort of Transform stream.
14616// Every written chunk gets output as-is.
14617
14618'use strict';
14619
14620module.exports = PassThrough;
14621
14622var Transform = require('./_stream_transform');
14623
14624/*<replacement>*/
14625var util = require('core-util-is');
14626util.inherits = require('inherits');
14627/*</replacement>*/
14628
14629util.inherits(PassThrough, Transform);
14630
14631function PassThrough(options) {
14632 if (!(this instanceof PassThrough)) return new PassThrough(options);
14633
14634 Transform.call(this, options);
14635}
14636
14637PassThrough.prototype._transform = function (chunk, encoding, cb) {
14638 cb(null, chunk);
14639};
14640},{"./_stream_transform":73,"core-util-is":44,"inherits":56}],72:[function(require,module,exports){
14641(function (process,global){
14642// Copyright Joyent, Inc. and other Node contributors.
14643//
14644// Permission is hereby granted, free of charge, to any person obtaining a
14645// copy of this software and associated documentation files (the
14646// "Software"), to deal in the Software without restriction, including
14647// without limitation the rights to use, copy, modify, merge, publish,
14648// distribute, sublicense, and/or sell copies of the Software, and to permit
14649// persons to whom the Software is furnished to do so, subject to the
14650// following conditions:
14651//
14652// The above copyright notice and this permission notice shall be included
14653// in all copies or substantial portions of the Software.
14654//
14655// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14656// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14657// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14658// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14659// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14660// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14661// USE OR OTHER DEALINGS IN THE SOFTWARE.
14662
14663'use strict';
14664
14665/*<replacement>*/
14666
14667var pna = require('process-nextick-args');
14668/*</replacement>*/
14669
14670module.exports = Readable;
14671
14672/*<replacement>*/
14673var isArray = require('isarray');
14674/*</replacement>*/
14675
14676/*<replacement>*/
14677var Duplex;
14678/*</replacement>*/
14679
14680Readable.ReadableState = ReadableState;
14681
14682/*<replacement>*/
14683var EE = require('events').EventEmitter;
14684
14685var EElistenerCount = function (emitter, type) {
14686 return emitter.listeners(type).length;
14687};
14688/*</replacement>*/
14689
14690/*<replacement>*/
14691var Stream = require('./internal/streams/stream');
14692/*</replacement>*/
14693
14694/*<replacement>*/
14695
14696var Buffer = require('safe-buffer').Buffer;
14697var OurUint8Array = global.Uint8Array || function () {};
14698function _uint8ArrayToBuffer(chunk) {
14699 return Buffer.from(chunk);
14700}
14701function _isUint8Array(obj) {
14702 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
14703}
14704
14705/*</replacement>*/
14706
14707/*<replacement>*/
14708var util = require('core-util-is');
14709util.inherits = require('inherits');
14710/*</replacement>*/
14711
14712/*<replacement>*/
14713var debugUtil = require('util');
14714var debug = void 0;
14715if (debugUtil && debugUtil.debuglog) {
14716 debug = debugUtil.debuglog('stream');
14717} else {
14718 debug = function () {};
14719}
14720/*</replacement>*/
14721
14722var BufferList = require('./internal/streams/BufferList');
14723var destroyImpl = require('./internal/streams/destroy');
14724var StringDecoder;
14725
14726util.inherits(Readable, Stream);
14727
14728var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
14729
14730function prependListener(emitter, event, fn) {
14731 // Sadly this is not cacheable as some libraries bundle their own
14732 // event emitter implementation with them.
14733 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
14734
14735 // This is a hack to make sure that our error handler is attached before any
14736 // userland ones. NEVER DO THIS. This is here only because this code needs
14737 // to continue to work with older versions of Node.js that do not include
14738 // the prependListener() method. The goal is to eventually remove this hack.
14739 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
14740}
14741
14742function ReadableState(options, stream) {
14743 Duplex = Duplex || require('./_stream_duplex');
14744
14745 options = options || {};
14746
14747 // Duplex streams are both readable and writable, but share
14748 // the same options object.
14749 // However, some cases require setting options to different
14750 // values for the readable and the writable sides of the duplex stream.
14751 // These options can be provided separately as readableXXX and writableXXX.
14752 var isDuplex = stream instanceof Duplex;
14753
14754 // object stream flag. Used to make read(n) ignore n and to
14755 // make all the buffer merging and length checks go away
14756 this.objectMode = !!options.objectMode;
14757
14758 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
14759
14760 // the point at which it stops calling _read() to fill the buffer
14761 // Note: 0 is a valid value, means "don't call _read preemptively ever"
14762 var hwm = options.highWaterMark;
14763 var readableHwm = options.readableHighWaterMark;
14764 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
14765
14766 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
14767
14768 // cast to ints.
14769 this.highWaterMark = Math.floor(this.highWaterMark);
14770
14771 // A linked list is used to store data chunks instead of an array because the
14772 // linked list can remove elements from the beginning faster than
14773 // array.shift()
14774 this.buffer = new BufferList();
14775 this.length = 0;
14776 this.pipes = null;
14777 this.pipesCount = 0;
14778 this.flowing = null;
14779 this.ended = false;
14780 this.endEmitted = false;
14781 this.reading = false;
14782
14783 // a flag to be able to tell if the event 'readable'/'data' is emitted
14784 // immediately, or on a later tick. We set this to true at first, because
14785 // any actions that shouldn't happen until "later" should generally also
14786 // not happen before the first read call.
14787 this.sync = true;
14788
14789 // whenever we return null, then we set a flag to say
14790 // that we're awaiting a 'readable' event emission.
14791 this.needReadable = false;
14792 this.emittedReadable = false;
14793 this.readableListening = false;
14794 this.resumeScheduled = false;
14795
14796 // has it been destroyed
14797 this.destroyed = false;
14798
14799 // Crypto is kind of old and crusty. Historically, its default string
14800 // encoding is 'binary' so we have to make this configurable.
14801 // Everything else in the universe uses 'utf8', though.
14802 this.defaultEncoding = options.defaultEncoding || 'utf8';
14803
14804 // the number of writers that are awaiting a drain event in .pipe()s
14805 this.awaitDrain = 0;
14806
14807 // if true, a maybeReadMore has been scheduled
14808 this.readingMore = false;
14809
14810 this.decoder = null;
14811 this.encoding = null;
14812 if (options.encoding) {
14813 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
14814 this.decoder = new StringDecoder(options.encoding);
14815 this.encoding = options.encoding;
14816 }
14817}
14818
14819function Readable(options) {
14820 Duplex = Duplex || require('./_stream_duplex');
14821
14822 if (!(this instanceof Readable)) return new Readable(options);
14823
14824 this._readableState = new ReadableState(options, this);
14825
14826 // legacy
14827 this.readable = true;
14828
14829 if (options) {
14830 if (typeof options.read === 'function') this._read = options.read;
14831
14832 if (typeof options.destroy === 'function') this._destroy = options.destroy;
14833 }
14834
14835 Stream.call(this);
14836}
14837
14838Object.defineProperty(Readable.prototype, 'destroyed', {
14839 get: function () {
14840 if (this._readableState === undefined) {
14841 return false;
14842 }
14843 return this._readableState.destroyed;
14844 },
14845 set: function (value) {
14846 // we ignore the value if the stream
14847 // has not been initialized yet
14848 if (!this._readableState) {
14849 return;
14850 }
14851
14852 // backward compatibility, the user is explicitly
14853 // managing destroyed
14854 this._readableState.destroyed = value;
14855 }
14856});
14857
14858Readable.prototype.destroy = destroyImpl.destroy;
14859Readable.prototype._undestroy = destroyImpl.undestroy;
14860Readable.prototype._destroy = function (err, cb) {
14861 this.push(null);
14862 cb(err);
14863};
14864
14865// Manually shove something into the read() buffer.
14866// This returns true if the highWaterMark has not been hit yet,
14867// similar to how Writable.write() returns true if you should
14868// write() some more.
14869Readable.prototype.push = function (chunk, encoding) {
14870 var state = this._readableState;
14871 var skipChunkCheck;
14872
14873 if (!state.objectMode) {
14874 if (typeof chunk === 'string') {
14875 encoding = encoding || state.defaultEncoding;
14876 if (encoding !== state.encoding) {
14877 chunk = Buffer.from(chunk, encoding);
14878 encoding = '';
14879 }
14880 skipChunkCheck = true;
14881 }
14882 } else {
14883 skipChunkCheck = true;
14884 }
14885
14886 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
14887};
14888
14889// Unshift should *always* be something directly out of read()
14890Readable.prototype.unshift = function (chunk) {
14891 return readableAddChunk(this, chunk, null, true, false);
14892};
14893
14894function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
14895 var state = stream._readableState;
14896 if (chunk === null) {
14897 state.reading = false;
14898 onEofChunk(stream, state);
14899 } else {
14900 var er;
14901 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
14902 if (er) {
14903 stream.emit('error', er);
14904 } else if (state.objectMode || chunk && chunk.length > 0) {
14905 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
14906 chunk = _uint8ArrayToBuffer(chunk);
14907 }
14908
14909 if (addToFront) {
14910 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
14911 } else if (state.ended) {
14912 stream.emit('error', new Error('stream.push() after EOF'));
14913 } else {
14914 state.reading = false;
14915 if (state.decoder && !encoding) {
14916 chunk = state.decoder.write(chunk);
14917 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
14918 } else {
14919 addChunk(stream, state, chunk, false);
14920 }
14921 }
14922 } else if (!addToFront) {
14923 state.reading = false;
14924 }
14925 }
14926
14927 return needMoreData(state);
14928}
14929
14930function addChunk(stream, state, chunk, addToFront) {
14931 if (state.flowing && state.length === 0 && !state.sync) {
14932 stream.emit('data', chunk);
14933 stream.read(0);
14934 } else {
14935 // update the buffer info.
14936 state.length += state.objectMode ? 1 : chunk.length;
14937 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
14938
14939 if (state.needReadable) emitReadable(stream);
14940 }
14941 maybeReadMore(stream, state);
14942}
14943
14944function chunkInvalid(state, chunk) {
14945 var er;
14946 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
14947 er = new TypeError('Invalid non-string/buffer chunk');
14948 }
14949 return er;
14950}
14951
14952// if it's past the high water mark, we can push in some more.
14953// Also, if we have no data yet, we can stand some
14954// more bytes. This is to work around cases where hwm=0,
14955// such as the repl. Also, if the push() triggered a
14956// readable event, and the user called read(largeNumber) such that
14957// needReadable was set, then we ought to push more, so that another
14958// 'readable' event will be triggered.
14959function needMoreData(state) {
14960 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
14961}
14962
14963Readable.prototype.isPaused = function () {
14964 return this._readableState.flowing === false;
14965};
14966
14967// backwards compatibility.
14968Readable.prototype.setEncoding = function (enc) {
14969 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
14970 this._readableState.decoder = new StringDecoder(enc);
14971 this._readableState.encoding = enc;
14972 return this;
14973};
14974
14975// Don't raise the hwm > 8MB
14976var MAX_HWM = 0x800000;
14977function computeNewHighWaterMark(n) {
14978 if (n >= MAX_HWM) {
14979 n = MAX_HWM;
14980 } else {
14981 // Get the next highest power of 2 to prevent increasing hwm excessively in
14982 // tiny amounts
14983 n--;
14984 n |= n >>> 1;
14985 n |= n >>> 2;
14986 n |= n >>> 4;
14987 n |= n >>> 8;
14988 n |= n >>> 16;
14989 n++;
14990 }
14991 return n;
14992}
14993
14994// This function is designed to be inlinable, so please take care when making
14995// changes to the function body.
14996function howMuchToRead(n, state) {
14997 if (n <= 0 || state.length === 0 && state.ended) return 0;
14998 if (state.objectMode) return 1;
14999 if (n !== n) {
15000 // Only flow one buffer at a time
15001 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
15002 }
15003 // If we're asking for more than the current hwm, then raise the hwm.
15004 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
15005 if (n <= state.length) return n;
15006 // Don't have enough
15007 if (!state.ended) {
15008 state.needReadable = true;
15009 return 0;
15010 }
15011 return state.length;
15012}
15013
15014// you can override either this method, or the async _read(n) below.
15015Readable.prototype.read = function (n) {
15016 debug('read', n);
15017 n = parseInt(n, 10);
15018 var state = this._readableState;
15019 var nOrig = n;
15020
15021 if (n !== 0) state.emittedReadable = false;
15022
15023 // if we're doing read(0) to trigger a readable event, but we
15024 // already have a bunch of data in the buffer, then just trigger
15025 // the 'readable' event and move on.
15026 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
15027 debug('read: emitReadable', state.length, state.ended);
15028 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
15029 return null;
15030 }
15031
15032 n = howMuchToRead(n, state);
15033
15034 // if we've ended, and we're now clear, then finish it up.
15035 if (n === 0 && state.ended) {
15036 if (state.length === 0) endReadable(this);
15037 return null;
15038 }
15039
15040 // All the actual chunk generation logic needs to be
15041 // *below* the call to _read. The reason is that in certain
15042 // synthetic stream cases, such as passthrough streams, _read
15043 // may be a completely synchronous operation which may change
15044 // the state of the read buffer, providing enough data when
15045 // before there was *not* enough.
15046 //
15047 // So, the steps are:
15048 // 1. Figure out what the state of things will be after we do
15049 // a read from the buffer.
15050 //
15051 // 2. If that resulting state will trigger a _read, then call _read.
15052 // Note that this may be asynchronous, or synchronous. Yes, it is
15053 // deeply ugly to write APIs this way, but that still doesn't mean
15054 // that the Readable class should behave improperly, as streams are
15055 // designed to be sync/async agnostic.
15056 // Take note if the _read call is sync or async (ie, if the read call
15057 // has returned yet), so that we know whether or not it's safe to emit
15058 // 'readable' etc.
15059 //
15060 // 3. Actually pull the requested chunks out of the buffer and return.
15061
15062 // if we need a readable event, then we need to do some reading.
15063 var doRead = state.needReadable;
15064 debug('need readable', doRead);
15065
15066 // if we currently have less than the highWaterMark, then also read some
15067 if (state.length === 0 || state.length - n < state.highWaterMark) {
15068 doRead = true;
15069 debug('length less than watermark', doRead);
15070 }
15071
15072 // however, if we've ended, then there's no point, and if we're already
15073 // reading, then it's unnecessary.
15074 if (state.ended || state.reading) {
15075 doRead = false;
15076 debug('reading or ended', doRead);
15077 } else if (doRead) {
15078 debug('do read');
15079 state.reading = true;
15080 state.sync = true;
15081 // if the length is currently zero, then we *need* a readable event.
15082 if (state.length === 0) state.needReadable = true;
15083 // call internal read method
15084 this._read(state.highWaterMark);
15085 state.sync = false;
15086 // If _read pushed data synchronously, then `reading` will be false,
15087 // and we need to re-evaluate how much data we can return to the user.
15088 if (!state.reading) n = howMuchToRead(nOrig, state);
15089 }
15090
15091 var ret;
15092 if (n > 0) ret = fromList(n, state);else ret = null;
15093
15094 if (ret === null) {
15095 state.needReadable = true;
15096 n = 0;
15097 } else {
15098 state.length -= n;
15099 }
15100
15101 if (state.length === 0) {
15102 // If we have nothing in the buffer, then we want to know
15103 // as soon as we *do* get something into the buffer.
15104 if (!state.ended) state.needReadable = true;
15105
15106 // If we tried to read() past the EOF, then emit end on the next tick.
15107 if (nOrig !== n && state.ended) endReadable(this);
15108 }
15109
15110 if (ret !== null) this.emit('data', ret);
15111
15112 return ret;
15113};
15114
15115function onEofChunk(stream, state) {
15116 if (state.ended) return;
15117 if (state.decoder) {
15118 var chunk = state.decoder.end();
15119 if (chunk && chunk.length) {
15120 state.buffer.push(chunk);
15121 state.length += state.objectMode ? 1 : chunk.length;
15122 }
15123 }
15124 state.ended = true;
15125
15126 // emit 'readable' now to make sure it gets picked up.
15127 emitReadable(stream);
15128}
15129
15130// Don't emit readable right away in sync mode, because this can trigger
15131// another read() call => stack overflow. This way, it might trigger
15132// a nextTick recursion warning, but that's not so bad.
15133function emitReadable(stream) {
15134 var state = stream._readableState;
15135 state.needReadable = false;
15136 if (!state.emittedReadable) {
15137 debug('emitReadable', state.flowing);
15138 state.emittedReadable = true;
15139 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
15140 }
15141}
15142
15143function emitReadable_(stream) {
15144 debug('emit readable');
15145 stream.emit('readable');
15146 flow(stream);
15147}
15148
15149// at this point, the user has presumably seen the 'readable' event,
15150// and called read() to consume some data. that may have triggered
15151// in turn another _read(n) call, in which case reading = true if
15152// it's in progress.
15153// However, if we're not ended, or reading, and the length < hwm,
15154// then go ahead and try to read some more preemptively.
15155function maybeReadMore(stream, state) {
15156 if (!state.readingMore) {
15157 state.readingMore = true;
15158 pna.nextTick(maybeReadMore_, stream, state);
15159 }
15160}
15161
15162function maybeReadMore_(stream, state) {
15163 var len = state.length;
15164 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
15165 debug('maybeReadMore read 0');
15166 stream.read(0);
15167 if (len === state.length)
15168 // didn't get any data, stop spinning.
15169 break;else len = state.length;
15170 }
15171 state.readingMore = false;
15172}
15173
15174// abstract method. to be overridden in specific implementation classes.
15175// call cb(er, data) where data is <= n in length.
15176// for virtual (non-string, non-buffer) streams, "length" is somewhat
15177// arbitrary, and perhaps not very meaningful.
15178Readable.prototype._read = function (n) {
15179 this.emit('error', new Error('_read() is not implemented'));
15180};
15181
15182Readable.prototype.pipe = function (dest, pipeOpts) {
15183 var src = this;
15184 var state = this._readableState;
15185
15186 switch (state.pipesCount) {
15187 case 0:
15188 state.pipes = dest;
15189 break;
15190 case 1:
15191 state.pipes = [state.pipes, dest];
15192 break;
15193 default:
15194 state.pipes.push(dest);
15195 break;
15196 }
15197 state.pipesCount += 1;
15198 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
15199
15200 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
15201
15202 var endFn = doEnd ? onend : unpipe;
15203 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
15204
15205 dest.on('unpipe', onunpipe);
15206 function onunpipe(readable, unpipeInfo) {
15207 debug('onunpipe');
15208 if (readable === src) {
15209 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
15210 unpipeInfo.hasUnpiped = true;
15211 cleanup();
15212 }
15213 }
15214 }
15215
15216 function onend() {
15217 debug('onend');
15218 dest.end();
15219 }
15220
15221 // when the dest drains, it reduces the awaitDrain counter
15222 // on the source. This would be more elegant with a .once()
15223 // handler in flow(), but adding and removing repeatedly is
15224 // too slow.
15225 var ondrain = pipeOnDrain(src);
15226 dest.on('drain', ondrain);
15227
15228 var cleanedUp = false;
15229 function cleanup() {
15230 debug('cleanup');
15231 // cleanup event handlers once the pipe is broken
15232 dest.removeListener('close', onclose);
15233 dest.removeListener('finish', onfinish);
15234 dest.removeListener('drain', ondrain);
15235 dest.removeListener('error', onerror);
15236 dest.removeListener('unpipe', onunpipe);
15237 src.removeListener('end', onend);
15238 src.removeListener('end', unpipe);
15239 src.removeListener('data', ondata);
15240
15241 cleanedUp = true;
15242
15243 // if the reader is waiting for a drain event from this
15244 // specific writer, then it would cause it to never start
15245 // flowing again.
15246 // So, if this is awaiting a drain, then we just call it now.
15247 // If we don't know, then assume that we are waiting for one.
15248 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
15249 }
15250
15251 // If the user pushes more data while we're writing to dest then we'll end up
15252 // in ondata again. However, we only want to increase awaitDrain once because
15253 // dest will only emit one 'drain' event for the multiple writes.
15254 // => Introduce a guard on increasing awaitDrain.
15255 var increasedAwaitDrain = false;
15256 src.on('data', ondata);
15257 function ondata(chunk) {
15258 debug('ondata');
15259 increasedAwaitDrain = false;
15260 var ret = dest.write(chunk);
15261 if (false === ret && !increasedAwaitDrain) {
15262 // If the user unpiped during `dest.write()`, it is possible
15263 // to get stuck in a permanently paused state if that write
15264 // also returned false.
15265 // => Check whether `dest` is still a piping destination.
15266 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
15267 debug('false write response, pause', src._readableState.awaitDrain);
15268 src._readableState.awaitDrain++;
15269 increasedAwaitDrain = true;
15270 }
15271 src.pause();
15272 }
15273 }
15274
15275 // if the dest has an error, then stop piping into it.
15276 // however, don't suppress the throwing behavior for this.
15277 function onerror(er) {
15278 debug('onerror', er);
15279 unpipe();
15280 dest.removeListener('error', onerror);
15281 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
15282 }
15283
15284 // Make sure our error handler is attached before userland ones.
15285 prependListener(dest, 'error', onerror);
15286
15287 // Both close and finish should trigger unpipe, but only once.
15288 function onclose() {
15289 dest.removeListener('finish', onfinish);
15290 unpipe();
15291 }
15292 dest.once('close', onclose);
15293 function onfinish() {
15294 debug('onfinish');
15295 dest.removeListener('close', onclose);
15296 unpipe();
15297 }
15298 dest.once('finish', onfinish);
15299
15300 function unpipe() {
15301 debug('unpipe');
15302 src.unpipe(dest);
15303 }
15304
15305 // tell the dest that it's being piped to
15306 dest.emit('pipe', src);
15307
15308 // start the flow if it hasn't been started already.
15309 if (!state.flowing) {
15310 debug('pipe resume');
15311 src.resume();
15312 }
15313
15314 return dest;
15315};
15316
15317function pipeOnDrain(src) {
15318 return function () {
15319 var state = src._readableState;
15320 debug('pipeOnDrain', state.awaitDrain);
15321 if (state.awaitDrain) state.awaitDrain--;
15322 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
15323 state.flowing = true;
15324 flow(src);
15325 }
15326 };
15327}
15328
15329Readable.prototype.unpipe = function (dest) {
15330 var state = this._readableState;
15331 var unpipeInfo = { hasUnpiped: false };
15332
15333 // if we're not piping anywhere, then do nothing.
15334 if (state.pipesCount === 0) return this;
15335
15336 // just one destination. most common case.
15337 if (state.pipesCount === 1) {
15338 // passed in one, but it's not the right one.
15339 if (dest && dest !== state.pipes) return this;
15340
15341 if (!dest) dest = state.pipes;
15342
15343 // got a match.
15344 state.pipes = null;
15345 state.pipesCount = 0;
15346 state.flowing = false;
15347 if (dest) dest.emit('unpipe', this, unpipeInfo);
15348 return this;
15349 }
15350
15351 // slow case. multiple pipe destinations.
15352
15353 if (!dest) {
15354 // remove all.
15355 var dests = state.pipes;
15356 var len = state.pipesCount;
15357 state.pipes = null;
15358 state.pipesCount = 0;
15359 state.flowing = false;
15360
15361 for (var i = 0; i < len; i++) {
15362 dests[i].emit('unpipe', this, unpipeInfo);
15363 }return this;
15364 }
15365
15366 // try to find the right one.
15367 var index = indexOf(state.pipes, dest);
15368 if (index === -1) return this;
15369
15370 state.pipes.splice(index, 1);
15371 state.pipesCount -= 1;
15372 if (state.pipesCount === 1) state.pipes = state.pipes[0];
15373
15374 dest.emit('unpipe', this, unpipeInfo);
15375
15376 return this;
15377};
15378
15379// set up data events if they are asked for
15380// Ensure readable listeners eventually get something
15381Readable.prototype.on = function (ev, fn) {
15382 var res = Stream.prototype.on.call(this, ev, fn);
15383
15384 if (ev === 'data') {
15385 // Start flowing on next tick if stream isn't explicitly paused
15386 if (this._readableState.flowing !== false) this.resume();
15387 } else if (ev === 'readable') {
15388 var state = this._readableState;
15389 if (!state.endEmitted && !state.readableListening) {
15390 state.readableListening = state.needReadable = true;
15391 state.emittedReadable = false;
15392 if (!state.reading) {
15393 pna.nextTick(nReadingNextTick, this);
15394 } else if (state.length) {
15395 emitReadable(this);
15396 }
15397 }
15398 }
15399
15400 return res;
15401};
15402Readable.prototype.addListener = Readable.prototype.on;
15403
15404function nReadingNextTick(self) {
15405 debug('readable nexttick read 0');
15406 self.read(0);
15407}
15408
15409// pause() and resume() are remnants of the legacy readable stream API
15410// If the user uses them, then switch into old mode.
15411Readable.prototype.resume = function () {
15412 var state = this._readableState;
15413 if (!state.flowing) {
15414 debug('resume');
15415 state.flowing = true;
15416 resume(this, state);
15417 }
15418 return this;
15419};
15420
15421function resume(stream, state) {
15422 if (!state.resumeScheduled) {
15423 state.resumeScheduled = true;
15424 pna.nextTick(resume_, stream, state);
15425 }
15426}
15427
15428function resume_(stream, state) {
15429 if (!state.reading) {
15430 debug('resume read 0');
15431 stream.read(0);
15432 }
15433
15434 state.resumeScheduled = false;
15435 state.awaitDrain = 0;
15436 stream.emit('resume');
15437 flow(stream);
15438 if (state.flowing && !state.reading) stream.read(0);
15439}
15440
15441Readable.prototype.pause = function () {
15442 debug('call pause flowing=%j', this._readableState.flowing);
15443 if (false !== this._readableState.flowing) {
15444 debug('pause');
15445 this._readableState.flowing = false;
15446 this.emit('pause');
15447 }
15448 return this;
15449};
15450
15451function flow(stream) {
15452 var state = stream._readableState;
15453 debug('flow', state.flowing);
15454 while (state.flowing && stream.read() !== null) {}
15455}
15456
15457// wrap an old-style stream as the async data source.
15458// This is *not* part of the readable stream interface.
15459// It is an ugly unfortunate mess of history.
15460Readable.prototype.wrap = function (stream) {
15461 var _this = this;
15462
15463 var state = this._readableState;
15464 var paused = false;
15465
15466 stream.on('end', function () {
15467 debug('wrapped end');
15468 if (state.decoder && !state.ended) {
15469 var chunk = state.decoder.end();
15470 if (chunk && chunk.length) _this.push(chunk);
15471 }
15472
15473 _this.push(null);
15474 });
15475
15476 stream.on('data', function (chunk) {
15477 debug('wrapped data');
15478 if (state.decoder) chunk = state.decoder.write(chunk);
15479
15480 // don't skip over falsy values in objectMode
15481 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
15482
15483 var ret = _this.push(chunk);
15484 if (!ret) {
15485 paused = true;
15486 stream.pause();
15487 }
15488 });
15489
15490 // proxy all the other methods.
15491 // important when wrapping filters and duplexes.
15492 for (var i in stream) {
15493 if (this[i] === undefined && typeof stream[i] === 'function') {
15494 this[i] = function (method) {
15495 return function () {
15496 return stream[method].apply(stream, arguments);
15497 };
15498 }(i);
15499 }
15500 }
15501
15502 // proxy certain important events.
15503 for (var n = 0; n < kProxyEvents.length; n++) {
15504 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
15505 }
15506
15507 // when we try to consume some more bytes, simply unpause the
15508 // underlying stream.
15509 this._read = function (n) {
15510 debug('wrapped _read', n);
15511 if (paused) {
15512 paused = false;
15513 stream.resume();
15514 }
15515 };
15516
15517 return this;
15518};
15519
15520Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
15521 // making it explicit this property is not enumerable
15522 // because otherwise some prototype manipulation in
15523 // userland will fail
15524 enumerable: false,
15525 get: function () {
15526 return this._readableState.highWaterMark;
15527 }
15528});
15529
15530// exposed for testing purposes only.
15531Readable._fromList = fromList;
15532
15533// Pluck off n bytes from an array of buffers.
15534// Length is the combined lengths of all the buffers in the list.
15535// This function is designed to be inlinable, so please take care when making
15536// changes to the function body.
15537function fromList(n, state) {
15538 // nothing buffered
15539 if (state.length === 0) return null;
15540
15541 var ret;
15542 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
15543 // read it all, truncate the list
15544 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
15545 state.buffer.clear();
15546 } else {
15547 // read part of list
15548 ret = fromListPartial(n, state.buffer, state.decoder);
15549 }
15550
15551 return ret;
15552}
15553
15554// Extracts only enough buffered data to satisfy the amount requested.
15555// This function is designed to be inlinable, so please take care when making
15556// changes to the function body.
15557function fromListPartial(n, list, hasStrings) {
15558 var ret;
15559 if (n < list.head.data.length) {
15560 // slice is the same for buffers and strings
15561 ret = list.head.data.slice(0, n);
15562 list.head.data = list.head.data.slice(n);
15563 } else if (n === list.head.data.length) {
15564 // first chunk is a perfect match
15565 ret = list.shift();
15566 } else {
15567 // result spans more than one buffer
15568 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
15569 }
15570 return ret;
15571}
15572
15573// Copies a specified amount of characters from the list of buffered data
15574// chunks.
15575// This function is designed to be inlinable, so please take care when making
15576// changes to the function body.
15577function copyFromBufferString(n, list) {
15578 var p = list.head;
15579 var c = 1;
15580 var ret = p.data;
15581 n -= ret.length;
15582 while (p = p.next) {
15583 var str = p.data;
15584 var nb = n > str.length ? str.length : n;
15585 if (nb === str.length) ret += str;else ret += str.slice(0, n);
15586 n -= nb;
15587 if (n === 0) {
15588 if (nb === str.length) {
15589 ++c;
15590 if (p.next) list.head = p.next;else list.head = list.tail = null;
15591 } else {
15592 list.head = p;
15593 p.data = str.slice(nb);
15594 }
15595 break;
15596 }
15597 ++c;
15598 }
15599 list.length -= c;
15600 return ret;
15601}
15602
15603// Copies a specified amount of bytes from the list of buffered data chunks.
15604// This function is designed to be inlinable, so please take care when making
15605// changes to the function body.
15606function copyFromBuffer(n, list) {
15607 var ret = Buffer.allocUnsafe(n);
15608 var p = list.head;
15609 var c = 1;
15610 p.data.copy(ret);
15611 n -= p.data.length;
15612 while (p = p.next) {
15613 var buf = p.data;
15614 var nb = n > buf.length ? buf.length : n;
15615 buf.copy(ret, ret.length - n, 0, nb);
15616 n -= nb;
15617 if (n === 0) {
15618 if (nb === buf.length) {
15619 ++c;
15620 if (p.next) list.head = p.next;else list.head = list.tail = null;
15621 } else {
15622 list.head = p;
15623 p.data = buf.slice(nb);
15624 }
15625 break;
15626 }
15627 ++c;
15628 }
15629 list.length -= c;
15630 return ret;
15631}
15632
15633function endReadable(stream) {
15634 var state = stream._readableState;
15635
15636 // If we get here before consuming all the bytes, then that is a
15637 // bug in node. Should never happen.
15638 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
15639
15640 if (!state.endEmitted) {
15641 state.ended = true;
15642 pna.nextTick(endReadableNT, state, stream);
15643 }
15644}
15645
15646function endReadableNT(state, stream) {
15647 // Check that we didn't get one last unshift.
15648 if (!state.endEmitted && state.length === 0) {
15649 state.endEmitted = true;
15650 stream.readable = false;
15651 stream.emit('end');
15652 }
15653}
15654
15655function indexOf(xs, x) {
15656 for (var i = 0, l = xs.length; i < l; i++) {
15657 if (xs[i] === x) return i;
15658 }
15659 return -1;
15660}
15661}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
15662},{"./_stream_duplex":70,"./internal/streams/BufferList":75,"./internal/streams/destroy":76,"./internal/streams/stream":77,"_process":68,"core-util-is":44,"events":50,"inherits":56,"isarray":58,"process-nextick-args":67,"safe-buffer":82,"string_decoder/":84,"util":40}],73:[function(require,module,exports){
15663// Copyright Joyent, Inc. and other Node contributors.
15664//
15665// Permission is hereby granted, free of charge, to any person obtaining a
15666// copy of this software and associated documentation files (the
15667// "Software"), to deal in the Software without restriction, including
15668// without limitation the rights to use, copy, modify, merge, publish,
15669// distribute, sublicense, and/or sell copies of the Software, and to permit
15670// persons to whom the Software is furnished to do so, subject to the
15671// following conditions:
15672//
15673// The above copyright notice and this permission notice shall be included
15674// in all copies or substantial portions of the Software.
15675//
15676// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15677// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15678// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15679// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15680// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15681// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15682// USE OR OTHER DEALINGS IN THE SOFTWARE.
15683
15684// a transform stream is a readable/writable stream where you do
15685// something with the data. Sometimes it's called a "filter",
15686// but that's not a great name for it, since that implies a thing where
15687// some bits pass through, and others are simply ignored. (That would
15688// be a valid example of a transform, of course.)
15689//
15690// While the output is causally related to the input, it's not a
15691// necessarily symmetric or synchronous transformation. For example,
15692// a zlib stream might take multiple plain-text writes(), and then
15693// emit a single compressed chunk some time in the future.
15694//
15695// Here's how this works:
15696//
15697// The Transform stream has all the aspects of the readable and writable
15698// stream classes. When you write(chunk), that calls _write(chunk,cb)
15699// internally, and returns false if there's a lot of pending writes
15700// buffered up. When you call read(), that calls _read(n) until
15701// there's enough pending readable data buffered up.
15702//
15703// In a transform stream, the written data is placed in a buffer. When
15704// _read(n) is called, it transforms the queued up data, calling the
15705// buffered _write cb's as it consumes chunks. If consuming a single
15706// written chunk would result in multiple output chunks, then the first
15707// outputted bit calls the readcb, and subsequent chunks just go into
15708// the read buffer, and will cause it to emit 'readable' if necessary.
15709//
15710// This way, back-pressure is actually determined by the reading side,
15711// since _read has to be called to start processing a new chunk. However,
15712// a pathological inflate type of transform can cause excessive buffering
15713// here. For example, imagine a stream where every byte of input is
15714// interpreted as an integer from 0-255, and then results in that many
15715// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
15716// 1kb of data being output. In this case, you could write a very small
15717// amount of input, and end up with a very large amount of output. In
15718// such a pathological inflating mechanism, there'd be no way to tell
15719// the system to stop doing the transform. A single 4MB write could
15720// cause the system to run out of memory.
15721//
15722// However, even in such a pathological case, only a single written chunk
15723// would be consumed, and then the rest would wait (un-transformed) until
15724// the results of the previous transformed chunk were consumed.
15725
15726'use strict';
15727
15728module.exports = Transform;
15729
15730var Duplex = require('./_stream_duplex');
15731
15732/*<replacement>*/
15733var util = require('core-util-is');
15734util.inherits = require('inherits');
15735/*</replacement>*/
15736
15737util.inherits(Transform, Duplex);
15738
15739function afterTransform(er, data) {
15740 var ts = this._transformState;
15741 ts.transforming = false;
15742
15743 var cb = ts.writecb;
15744
15745 if (!cb) {
15746 return this.emit('error', new Error('write callback called multiple times'));
15747 }
15748
15749 ts.writechunk = null;
15750 ts.writecb = null;
15751
15752 if (data != null) // single equals check for both `null` and `undefined`
15753 this.push(data);
15754
15755 cb(er);
15756
15757 var rs = this._readableState;
15758 rs.reading = false;
15759 if (rs.needReadable || rs.length < rs.highWaterMark) {
15760 this._read(rs.highWaterMark);
15761 }
15762}
15763
15764function Transform(options) {
15765 if (!(this instanceof Transform)) return new Transform(options);
15766
15767 Duplex.call(this, options);
15768
15769 this._transformState = {
15770 afterTransform: afterTransform.bind(this),
15771 needTransform: false,
15772 transforming: false,
15773 writecb: null,
15774 writechunk: null,
15775 writeencoding: null
15776 };
15777
15778 // start out asking for a readable event once data is transformed.
15779 this._readableState.needReadable = true;
15780
15781 // we have implemented the _read method, and done the other things
15782 // that Readable wants before the first _read call, so unset the
15783 // sync guard flag.
15784 this._readableState.sync = false;
15785
15786 if (options) {
15787 if (typeof options.transform === 'function') this._transform = options.transform;
15788
15789 if (typeof options.flush === 'function') this._flush = options.flush;
15790 }
15791
15792 // When the writable side finishes, then flush out anything remaining.
15793 this.on('prefinish', prefinish);
15794}
15795
15796function prefinish() {
15797 var _this = this;
15798
15799 if (typeof this._flush === 'function') {
15800 this._flush(function (er, data) {
15801 done(_this, er, data);
15802 });
15803 } else {
15804 done(this, null, null);
15805 }
15806}
15807
15808Transform.prototype.push = function (chunk, encoding) {
15809 this._transformState.needTransform = false;
15810 return Duplex.prototype.push.call(this, chunk, encoding);
15811};
15812
15813// This is the part where you do stuff!
15814// override this function in implementation classes.
15815// 'chunk' is an input chunk.
15816//
15817// Call `push(newChunk)` to pass along transformed output
15818// to the readable side. You may call 'push' zero or more times.
15819//
15820// Call `cb(err)` when you are done with this chunk. If you pass
15821// an error, then that'll put the hurt on the whole operation. If you
15822// never call cb(), then you'll never get another chunk.
15823Transform.prototype._transform = function (chunk, encoding, cb) {
15824 throw new Error('_transform() is not implemented');
15825};
15826
15827Transform.prototype._write = function (chunk, encoding, cb) {
15828 var ts = this._transformState;
15829 ts.writecb = cb;
15830 ts.writechunk = chunk;
15831 ts.writeencoding = encoding;
15832 if (!ts.transforming) {
15833 var rs = this._readableState;
15834 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
15835 }
15836};
15837
15838// Doesn't matter what the args are here.
15839// _transform does all the work.
15840// That we got here means that the readable side wants more data.
15841Transform.prototype._read = function (n) {
15842 var ts = this._transformState;
15843
15844 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
15845 ts.transforming = true;
15846 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
15847 } else {
15848 // mark that we need a transform, so that any data that comes in
15849 // will get processed, now that we've asked for it.
15850 ts.needTransform = true;
15851 }
15852};
15853
15854Transform.prototype._destroy = function (err, cb) {
15855 var _this2 = this;
15856
15857 Duplex.prototype._destroy.call(this, err, function (err2) {
15858 cb(err2);
15859 _this2.emit('close');
15860 });
15861};
15862
15863function done(stream, er, data) {
15864 if (er) return stream.emit('error', er);
15865
15866 if (data != null) // single equals check for both `null` and `undefined`
15867 stream.push(data);
15868
15869 // if there's nothing in the write buffer, then that means
15870 // that nothing more will ever be provided
15871 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
15872
15873 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
15874
15875 return stream.push(null);
15876}
15877},{"./_stream_duplex":70,"core-util-is":44,"inherits":56}],74:[function(require,module,exports){
15878(function (process,global){
15879// Copyright Joyent, Inc. and other Node contributors.
15880//
15881// Permission is hereby granted, free of charge, to any person obtaining a
15882// copy of this software and associated documentation files (the
15883// "Software"), to deal in the Software without restriction, including
15884// without limitation the rights to use, copy, modify, merge, publish,
15885// distribute, sublicense, and/or sell copies of the Software, and to permit
15886// persons to whom the Software is furnished to do so, subject to the
15887// following conditions:
15888//
15889// The above copyright notice and this permission notice shall be included
15890// in all copies or substantial portions of the Software.
15891//
15892// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15893// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15894// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15895// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15896// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15897// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15898// USE OR OTHER DEALINGS IN THE SOFTWARE.
15899
15900// A bit simpler than readable streams.
15901// Implement an async ._write(chunk, encoding, cb), and it'll handle all
15902// the drain event emission and buffering.
15903
15904'use strict';
15905
15906/*<replacement>*/
15907
15908var pna = require('process-nextick-args');
15909/*</replacement>*/
15910
15911module.exports = Writable;
15912
15913/* <replacement> */
15914function WriteReq(chunk, encoding, cb) {
15915 this.chunk = chunk;
15916 this.encoding = encoding;
15917 this.callback = cb;
15918 this.next = null;
15919}
15920
15921// It seems a linked list but it is not
15922// there will be only 2 of these for each stream
15923function CorkedRequest(state) {
15924 var _this = this;
15925
15926 this.next = null;
15927 this.entry = null;
15928 this.finish = function () {
15929 onCorkedFinish(_this, state);
15930 };
15931}
15932/* </replacement> */
15933
15934/*<replacement>*/
15935var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
15936/*</replacement>*/
15937
15938/*<replacement>*/
15939var Duplex;
15940/*</replacement>*/
15941
15942Writable.WritableState = WritableState;
15943
15944/*<replacement>*/
15945var util = require('core-util-is');
15946util.inherits = require('inherits');
15947/*</replacement>*/
15948
15949/*<replacement>*/
15950var internalUtil = {
15951 deprecate: require('util-deprecate')
15952};
15953/*</replacement>*/
15954
15955/*<replacement>*/
15956var Stream = require('./internal/streams/stream');
15957/*</replacement>*/
15958
15959/*<replacement>*/
15960
15961var Buffer = require('safe-buffer').Buffer;
15962var OurUint8Array = global.Uint8Array || function () {};
15963function _uint8ArrayToBuffer(chunk) {
15964 return Buffer.from(chunk);
15965}
15966function _isUint8Array(obj) {
15967 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
15968}
15969
15970/*</replacement>*/
15971
15972var destroyImpl = require('./internal/streams/destroy');
15973
15974util.inherits(Writable, Stream);
15975
15976function nop() {}
15977
15978function WritableState(options, stream) {
15979 Duplex = Duplex || require('./_stream_duplex');
15980
15981 options = options || {};
15982
15983 // Duplex streams are both readable and writable, but share
15984 // the same options object.
15985 // However, some cases require setting options to different
15986 // values for the readable and the writable sides of the duplex stream.
15987 // These options can be provided separately as readableXXX and writableXXX.
15988 var isDuplex = stream instanceof Duplex;
15989
15990 // object stream flag to indicate whether or not this stream
15991 // contains buffers or objects.
15992 this.objectMode = !!options.objectMode;
15993
15994 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
15995
15996 // the point at which write() starts returning false
15997 // Note: 0 is a valid value, means that we always return false if
15998 // the entire buffer is not flushed immediately on write()
15999 var hwm = options.highWaterMark;
16000 var writableHwm = options.writableHighWaterMark;
16001 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
16002
16003 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
16004
16005 // cast to ints.
16006 this.highWaterMark = Math.floor(this.highWaterMark);
16007
16008 // if _final has been called
16009 this.finalCalled = false;
16010
16011 // drain event flag.
16012 this.needDrain = false;
16013 // at the start of calling end()
16014 this.ending = false;
16015 // when end() has been called, and returned
16016 this.ended = false;
16017 // when 'finish' is emitted
16018 this.finished = false;
16019
16020 // has it been destroyed
16021 this.destroyed = false;
16022
16023 // should we decode strings into buffers before passing to _write?
16024 // this is here so that some node-core streams can optimize string
16025 // handling at a lower level.
16026 var noDecode = options.decodeStrings === false;
16027 this.decodeStrings = !noDecode;
16028
16029 // Crypto is kind of old and crusty. Historically, its default string
16030 // encoding is 'binary' so we have to make this configurable.
16031 // Everything else in the universe uses 'utf8', though.
16032 this.defaultEncoding = options.defaultEncoding || 'utf8';
16033
16034 // not an actual buffer we keep track of, but a measurement
16035 // of how much we're waiting to get pushed to some underlying
16036 // socket or file.
16037 this.length = 0;
16038
16039 // a flag to see when we're in the middle of a write.
16040 this.writing = false;
16041
16042 // when true all writes will be buffered until .uncork() call
16043 this.corked = 0;
16044
16045 // a flag to be able to tell if the onwrite cb is called immediately,
16046 // or on a later tick. We set this to true at first, because any
16047 // actions that shouldn't happen until "later" should generally also
16048 // not happen before the first write call.
16049 this.sync = true;
16050
16051 // a flag to know if we're processing previously buffered items, which
16052 // may call the _write() callback in the same tick, so that we don't
16053 // end up in an overlapped onwrite situation.
16054 this.bufferProcessing = false;
16055
16056 // the callback that's passed to _write(chunk,cb)
16057 this.onwrite = function (er) {
16058 onwrite(stream, er);
16059 };
16060
16061 // the callback that the user supplies to write(chunk,encoding,cb)
16062 this.writecb = null;
16063
16064 // the amount that is being written when _write is called.
16065 this.writelen = 0;
16066
16067 this.bufferedRequest = null;
16068 this.lastBufferedRequest = null;
16069
16070 // number of pending user-supplied write callbacks
16071 // this must be 0 before 'finish' can be emitted
16072 this.pendingcb = 0;
16073
16074 // emit prefinish if the only thing we're waiting for is _write cbs
16075 // This is relevant for synchronous Transform streams
16076 this.prefinished = false;
16077
16078 // True if the error was already emitted and should not be thrown again
16079 this.errorEmitted = false;
16080
16081 // count buffered requests
16082 this.bufferedRequestCount = 0;
16083
16084 // allocate the first CorkedRequest, there is always
16085 // one allocated and free to use, and we maintain at most two
16086 this.corkedRequestsFree = new CorkedRequest(this);
16087}
16088
16089WritableState.prototype.getBuffer = function getBuffer() {
16090 var current = this.bufferedRequest;
16091 var out = [];
16092 while (current) {
16093 out.push(current);
16094 current = current.next;
16095 }
16096 return out;
16097};
16098
16099(function () {
16100 try {
16101 Object.defineProperty(WritableState.prototype, 'buffer', {
16102 get: internalUtil.deprecate(function () {
16103 return this.getBuffer();
16104 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
16105 });
16106 } catch (_) {}
16107})();
16108
16109// Test _writableState for inheritance to account for Duplex streams,
16110// whose prototype chain only points to Readable.
16111var realHasInstance;
16112if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
16113 realHasInstance = Function.prototype[Symbol.hasInstance];
16114 Object.defineProperty(Writable, Symbol.hasInstance, {
16115 value: function (object) {
16116 if (realHasInstance.call(this, object)) return true;
16117 if (this !== Writable) return false;
16118
16119 return object && object._writableState instanceof WritableState;
16120 }
16121 });
16122} else {
16123 realHasInstance = function (object) {
16124 return object instanceof this;
16125 };
16126}
16127
16128function Writable(options) {
16129 Duplex = Duplex || require('./_stream_duplex');
16130
16131 // Writable ctor is applied to Duplexes, too.
16132 // `realHasInstance` is necessary because using plain `instanceof`
16133 // would return false, as no `_writableState` property is attached.
16134
16135 // Trying to use the custom `instanceof` for Writable here will also break the
16136 // Node.js LazyTransform implementation, which has a non-trivial getter for
16137 // `_writableState` that would lead to infinite recursion.
16138 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
16139 return new Writable(options);
16140 }
16141
16142 this._writableState = new WritableState(options, this);
16143
16144 // legacy.
16145 this.writable = true;
16146
16147 if (options) {
16148 if (typeof options.write === 'function') this._write = options.write;
16149
16150 if (typeof options.writev === 'function') this._writev = options.writev;
16151
16152 if (typeof options.destroy === 'function') this._destroy = options.destroy;
16153
16154 if (typeof options.final === 'function') this._final = options.final;
16155 }
16156
16157 Stream.call(this);
16158}
16159
16160// Otherwise people can pipe Writable streams, which is just wrong.
16161Writable.prototype.pipe = function () {
16162 this.emit('error', new Error('Cannot pipe, not readable'));
16163};
16164
16165function writeAfterEnd(stream, cb) {
16166 var er = new Error('write after end');
16167 // TODO: defer error events consistently everywhere, not just the cb
16168 stream.emit('error', er);
16169 pna.nextTick(cb, er);
16170}
16171
16172// Checks that a user-supplied chunk is valid, especially for the particular
16173// mode the stream is in. Currently this means that `null` is never accepted
16174// and undefined/non-string values are only allowed in object mode.
16175function validChunk(stream, state, chunk, cb) {
16176 var valid = true;
16177 var er = false;
16178
16179 if (chunk === null) {
16180 er = new TypeError('May not write null values to stream');
16181 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
16182 er = new TypeError('Invalid non-string/buffer chunk');
16183 }
16184 if (er) {
16185 stream.emit('error', er);
16186 pna.nextTick(cb, er);
16187 valid = false;
16188 }
16189 return valid;
16190}
16191
16192Writable.prototype.write = function (chunk, encoding, cb) {
16193 var state = this._writableState;
16194 var ret = false;
16195 var isBuf = !state.objectMode && _isUint8Array(chunk);
16196
16197 if (isBuf && !Buffer.isBuffer(chunk)) {
16198 chunk = _uint8ArrayToBuffer(chunk);
16199 }
16200
16201 if (typeof encoding === 'function') {
16202 cb = encoding;
16203 encoding = null;
16204 }
16205
16206 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
16207
16208 if (typeof cb !== 'function') cb = nop;
16209
16210 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
16211 state.pendingcb++;
16212 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
16213 }
16214
16215 return ret;
16216};
16217
16218Writable.prototype.cork = function () {
16219 var state = this._writableState;
16220
16221 state.corked++;
16222};
16223
16224Writable.prototype.uncork = function () {
16225 var state = this._writableState;
16226
16227 if (state.corked) {
16228 state.corked--;
16229
16230 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
16231 }
16232};
16233
16234Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
16235 // node::ParseEncoding() requires lower case.
16236 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
16237 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
16238 this._writableState.defaultEncoding = encoding;
16239 return this;
16240};
16241
16242function decodeChunk(state, chunk, encoding) {
16243 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
16244 chunk = Buffer.from(chunk, encoding);
16245 }
16246 return chunk;
16247}
16248
16249Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
16250 // making it explicit this property is not enumerable
16251 // because otherwise some prototype manipulation in
16252 // userland will fail
16253 enumerable: false,
16254 get: function () {
16255 return this._writableState.highWaterMark;
16256 }
16257});
16258
16259// if we're already writing something, then just put this
16260// in the queue, and wait our turn. Otherwise, call _write
16261// If we return false, then we need a drain event, so set that flag.
16262function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
16263 if (!isBuf) {
16264 var newChunk = decodeChunk(state, chunk, encoding);
16265 if (chunk !== newChunk) {
16266 isBuf = true;
16267 encoding = 'buffer';
16268 chunk = newChunk;
16269 }
16270 }
16271 var len = state.objectMode ? 1 : chunk.length;
16272
16273 state.length += len;
16274
16275 var ret = state.length < state.highWaterMark;
16276 // we must ensure that previous needDrain will not be reset to false.
16277 if (!ret) state.needDrain = true;
16278
16279 if (state.writing || state.corked) {
16280 var last = state.lastBufferedRequest;
16281 state.lastBufferedRequest = {
16282 chunk: chunk,
16283 encoding: encoding,
16284 isBuf: isBuf,
16285 callback: cb,
16286 next: null
16287 };
16288 if (last) {
16289 last.next = state.lastBufferedRequest;
16290 } else {
16291 state.bufferedRequest = state.lastBufferedRequest;
16292 }
16293 state.bufferedRequestCount += 1;
16294 } else {
16295 doWrite(stream, state, false, len, chunk, encoding, cb);
16296 }
16297
16298 return ret;
16299}
16300
16301function doWrite(stream, state, writev, len, chunk, encoding, cb) {
16302 state.writelen = len;
16303 state.writecb = cb;
16304 state.writing = true;
16305 state.sync = true;
16306 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
16307 state.sync = false;
16308}
16309
16310function onwriteError(stream, state, sync, er, cb) {
16311 --state.pendingcb;
16312
16313 if (sync) {
16314 // defer the callback if we are being called synchronously
16315 // to avoid piling up things on the stack
16316 pna.nextTick(cb, er);
16317 // this can emit finish, and it will always happen
16318 // after error
16319 pna.nextTick(finishMaybe, stream, state);
16320 stream._writableState.errorEmitted = true;
16321 stream.emit('error', er);
16322 } else {
16323 // the caller expect this to happen before if
16324 // it is async
16325 cb(er);
16326 stream._writableState.errorEmitted = true;
16327 stream.emit('error', er);
16328 // this can emit finish, but finish must
16329 // always follow error
16330 finishMaybe(stream, state);
16331 }
16332}
16333
16334function onwriteStateUpdate(state) {
16335 state.writing = false;
16336 state.writecb = null;
16337 state.length -= state.writelen;
16338 state.writelen = 0;
16339}
16340
16341function onwrite(stream, er) {
16342 var state = stream._writableState;
16343 var sync = state.sync;
16344 var cb = state.writecb;
16345
16346 onwriteStateUpdate(state);
16347
16348 if (er) onwriteError(stream, state, sync, er, cb);else {
16349 // Check if we're actually ready to finish, but don't emit yet
16350 var finished = needFinish(state);
16351
16352 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
16353 clearBuffer(stream, state);
16354 }
16355
16356 if (sync) {
16357 /*<replacement>*/
16358 asyncWrite(afterWrite, stream, state, finished, cb);
16359 /*</replacement>*/
16360 } else {
16361 afterWrite(stream, state, finished, cb);
16362 }
16363 }
16364}
16365
16366function afterWrite(stream, state, finished, cb) {
16367 if (!finished) onwriteDrain(stream, state);
16368 state.pendingcb--;
16369 cb();
16370 finishMaybe(stream, state);
16371}
16372
16373// Must force callback to be called on nextTick, so that we don't
16374// emit 'drain' before the write() consumer gets the 'false' return
16375// value, and has a chance to attach a 'drain' listener.
16376function onwriteDrain(stream, state) {
16377 if (state.length === 0 && state.needDrain) {
16378 state.needDrain = false;
16379 stream.emit('drain');
16380 }
16381}
16382
16383// if there's something in the buffer waiting, then process it
16384function clearBuffer(stream, state) {
16385 state.bufferProcessing = true;
16386 var entry = state.bufferedRequest;
16387
16388 if (stream._writev && entry && entry.next) {
16389 // Fast case, write everything using _writev()
16390 var l = state.bufferedRequestCount;
16391 var buffer = new Array(l);
16392 var holder = state.corkedRequestsFree;
16393 holder.entry = entry;
16394
16395 var count = 0;
16396 var allBuffers = true;
16397 while (entry) {
16398 buffer[count] = entry;
16399 if (!entry.isBuf) allBuffers = false;
16400 entry = entry.next;
16401 count += 1;
16402 }
16403 buffer.allBuffers = allBuffers;
16404
16405 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
16406
16407 // doWrite is almost always async, defer these to save a bit of time
16408 // as the hot path ends with doWrite
16409 state.pendingcb++;
16410 state.lastBufferedRequest = null;
16411 if (holder.next) {
16412 state.corkedRequestsFree = holder.next;
16413 holder.next = null;
16414 } else {
16415 state.corkedRequestsFree = new CorkedRequest(state);
16416 }
16417 state.bufferedRequestCount = 0;
16418 } else {
16419 // Slow case, write chunks one-by-one
16420 while (entry) {
16421 var chunk = entry.chunk;
16422 var encoding = entry.encoding;
16423 var cb = entry.callback;
16424 var len = state.objectMode ? 1 : chunk.length;
16425
16426 doWrite(stream, state, false, len, chunk, encoding, cb);
16427 entry = entry.next;
16428 state.bufferedRequestCount--;
16429 // if we didn't call the onwrite immediately, then
16430 // it means that we need to wait until it does.
16431 // also, that means that the chunk and cb are currently
16432 // being processed, so move the buffer counter past them.
16433 if (state.writing) {
16434 break;
16435 }
16436 }
16437
16438 if (entry === null) state.lastBufferedRequest = null;
16439 }
16440
16441 state.bufferedRequest = entry;
16442 state.bufferProcessing = false;
16443}
16444
16445Writable.prototype._write = function (chunk, encoding, cb) {
16446 cb(new Error('_write() is not implemented'));
16447};
16448
16449Writable.prototype._writev = null;
16450
16451Writable.prototype.end = function (chunk, encoding, cb) {
16452 var state = this._writableState;
16453
16454 if (typeof chunk === 'function') {
16455 cb = chunk;
16456 chunk = null;
16457 encoding = null;
16458 } else if (typeof encoding === 'function') {
16459 cb = encoding;
16460 encoding = null;
16461 }
16462
16463 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
16464
16465 // .end() fully uncorks
16466 if (state.corked) {
16467 state.corked = 1;
16468 this.uncork();
16469 }
16470
16471 // ignore unnecessary end() calls.
16472 if (!state.ending && !state.finished) endWritable(this, state, cb);
16473};
16474
16475function needFinish(state) {
16476 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
16477}
16478function callFinal(stream, state) {
16479 stream._final(function (err) {
16480 state.pendingcb--;
16481 if (err) {
16482 stream.emit('error', err);
16483 }
16484 state.prefinished = true;
16485 stream.emit('prefinish');
16486 finishMaybe(stream, state);
16487 });
16488}
16489function prefinish(stream, state) {
16490 if (!state.prefinished && !state.finalCalled) {
16491 if (typeof stream._final === 'function') {
16492 state.pendingcb++;
16493 state.finalCalled = true;
16494 pna.nextTick(callFinal, stream, state);
16495 } else {
16496 state.prefinished = true;
16497 stream.emit('prefinish');
16498 }
16499 }
16500}
16501
16502function finishMaybe(stream, state) {
16503 var need = needFinish(state);
16504 if (need) {
16505 prefinish(stream, state);
16506 if (state.pendingcb === 0) {
16507 state.finished = true;
16508 stream.emit('finish');
16509 }
16510 }
16511 return need;
16512}
16513
16514function endWritable(stream, state, cb) {
16515 state.ending = true;
16516 finishMaybe(stream, state);
16517 if (cb) {
16518 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
16519 }
16520 state.ended = true;
16521 stream.writable = false;
16522}
16523
16524function onCorkedFinish(corkReq, state, err) {
16525 var entry = corkReq.entry;
16526 corkReq.entry = null;
16527 while (entry) {
16528 var cb = entry.callback;
16529 state.pendingcb--;
16530 cb(err);
16531 entry = entry.next;
16532 }
16533 if (state.corkedRequestsFree) {
16534 state.corkedRequestsFree.next = corkReq;
16535 } else {
16536 state.corkedRequestsFree = corkReq;
16537 }
16538}
16539
16540Object.defineProperty(Writable.prototype, 'destroyed', {
16541 get: function () {
16542 if (this._writableState === undefined) {
16543 return false;
16544 }
16545 return this._writableState.destroyed;
16546 },
16547 set: function (value) {
16548 // we ignore the value if the stream
16549 // has not been initialized yet
16550 if (!this._writableState) {
16551 return;
16552 }
16553
16554 // backward compatibility, the user is explicitly
16555 // managing destroyed
16556 this._writableState.destroyed = value;
16557 }
16558});
16559
16560Writable.prototype.destroy = destroyImpl.destroy;
16561Writable.prototype._undestroy = destroyImpl.undestroy;
16562Writable.prototype._destroy = function (err, cb) {
16563 this.end();
16564 cb(err);
16565};
16566}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
16567},{"./_stream_duplex":70,"./internal/streams/destroy":76,"./internal/streams/stream":77,"_process":68,"core-util-is":44,"inherits":56,"process-nextick-args":67,"safe-buffer":82,"util-deprecate":85}],75:[function(require,module,exports){
16568'use strict';
16569
16570function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16571
16572var Buffer = require('safe-buffer').Buffer;
16573var util = require('util');
16574
16575function copyBuffer(src, target, offset) {
16576 src.copy(target, offset);
16577}
16578
16579module.exports = function () {
16580 function BufferList() {
16581 _classCallCheck(this, BufferList);
16582
16583 this.head = null;
16584 this.tail = null;
16585 this.length = 0;
16586 }
16587
16588 BufferList.prototype.push = function push(v) {
16589 var entry = { data: v, next: null };
16590 if (this.length > 0) this.tail.next = entry;else this.head = entry;
16591 this.tail = entry;
16592 ++this.length;
16593 };
16594
16595 BufferList.prototype.unshift = function unshift(v) {
16596 var entry = { data: v, next: this.head };
16597 if (this.length === 0) this.tail = entry;
16598 this.head = entry;
16599 ++this.length;
16600 };
16601
16602 BufferList.prototype.shift = function shift() {
16603 if (this.length === 0) return;
16604 var ret = this.head.data;
16605 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
16606 --this.length;
16607 return ret;
16608 };
16609
16610 BufferList.prototype.clear = function clear() {
16611 this.head = this.tail = null;
16612 this.length = 0;
16613 };
16614
16615 BufferList.prototype.join = function join(s) {
16616 if (this.length === 0) return '';
16617 var p = this.head;
16618 var ret = '' + p.data;
16619 while (p = p.next) {
16620 ret += s + p.data;
16621 }return ret;
16622 };
16623
16624 BufferList.prototype.concat = function concat(n) {
16625 if (this.length === 0) return Buffer.alloc(0);
16626 if (this.length === 1) return this.head.data;
16627 var ret = Buffer.allocUnsafe(n >>> 0);
16628 var p = this.head;
16629 var i = 0;
16630 while (p) {
16631 copyBuffer(p.data, ret, i);
16632 i += p.data.length;
16633 p = p.next;
16634 }
16635 return ret;
16636 };
16637
16638 return BufferList;
16639}();
16640
16641if (util && util.inspect && util.inspect.custom) {
16642 module.exports.prototype[util.inspect.custom] = function () {
16643 var obj = util.inspect({ length: this.length });
16644 return this.constructor.name + ' ' + obj;
16645 };
16646}
16647},{"safe-buffer":82,"util":40}],76:[function(require,module,exports){
16648'use strict';
16649
16650/*<replacement>*/
16651
16652var pna = require('process-nextick-args');
16653/*</replacement>*/
16654
16655// undocumented cb() API, needed for core, not for public API
16656function destroy(err, cb) {
16657 var _this = this;
16658
16659 var readableDestroyed = this._readableState && this._readableState.destroyed;
16660 var writableDestroyed = this._writableState && this._writableState.destroyed;
16661
16662 if (readableDestroyed || writableDestroyed) {
16663 if (cb) {
16664 cb(err);
16665 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
16666 pna.nextTick(emitErrorNT, this, err);
16667 }
16668 return this;
16669 }
16670
16671 // we set destroyed to true before firing error callbacks in order
16672 // to make it re-entrance safe in case destroy() is called within callbacks
16673
16674 if (this._readableState) {
16675 this._readableState.destroyed = true;
16676 }
16677
16678 // if this is a duplex stream mark the writable part as destroyed as well
16679 if (this._writableState) {
16680 this._writableState.destroyed = true;
16681 }
16682
16683 this._destroy(err || null, function (err) {
16684 if (!cb && err) {
16685 pna.nextTick(emitErrorNT, _this, err);
16686 if (_this._writableState) {
16687 _this._writableState.errorEmitted = true;
16688 }
16689 } else if (cb) {
16690 cb(err);
16691 }
16692 });
16693
16694 return this;
16695}
16696
16697function undestroy() {
16698 if (this._readableState) {
16699 this._readableState.destroyed = false;
16700 this._readableState.reading = false;
16701 this._readableState.ended = false;
16702 this._readableState.endEmitted = false;
16703 }
16704
16705 if (this._writableState) {
16706 this._writableState.destroyed = false;
16707 this._writableState.ended = false;
16708 this._writableState.ending = false;
16709 this._writableState.finished = false;
16710 this._writableState.errorEmitted = false;
16711 }
16712}
16713
16714function emitErrorNT(self, err) {
16715 self.emit('error', err);
16716}
16717
16718module.exports = {
16719 destroy: destroy,
16720 undestroy: undestroy
16721};
16722},{"process-nextick-args":67}],77:[function(require,module,exports){
16723module.exports = require('events').EventEmitter;
16724
16725},{"events":50}],78:[function(require,module,exports){
16726module.exports = require('./readable').PassThrough
16727
16728},{"./readable":79}],79:[function(require,module,exports){
16729exports = module.exports = require('./lib/_stream_readable.js');
16730exports.Stream = exports;
16731exports.Readable = exports;
16732exports.Writable = require('./lib/_stream_writable.js');
16733exports.Duplex = require('./lib/_stream_duplex.js');
16734exports.Transform = require('./lib/_stream_transform.js');
16735exports.PassThrough = require('./lib/_stream_passthrough.js');
16736
16737},{"./lib/_stream_duplex.js":70,"./lib/_stream_passthrough.js":71,"./lib/_stream_readable.js":72,"./lib/_stream_transform.js":73,"./lib/_stream_writable.js":74}],80:[function(require,module,exports){
16738module.exports = require('./readable').Transform
16739
16740},{"./readable":79}],81:[function(require,module,exports){
16741module.exports = require('./lib/_stream_writable.js');
16742
16743},{"./lib/_stream_writable.js":74}],82:[function(require,module,exports){
16744/* eslint-disable node/no-deprecated-api */
16745var buffer = require('buffer')
16746var Buffer = buffer.Buffer
16747
16748// alternative to using Object.keys for old browsers
16749function copyProps (src, dst) {
16750 for (var key in src) {
16751 dst[key] = src[key]
16752 }
16753}
16754if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
16755 module.exports = buffer
16756} else {
16757 // Copy properties from require('buffer')
16758 copyProps(buffer, exports)
16759 exports.Buffer = SafeBuffer
16760}
16761
16762function SafeBuffer (arg, encodingOrOffset, length) {
16763 return Buffer(arg, encodingOrOffset, length)
16764}
16765
16766// Copy static methods from Buffer
16767copyProps(Buffer, SafeBuffer)
16768
16769SafeBuffer.from = function (arg, encodingOrOffset, length) {
16770 if (typeof arg === 'number') {
16771 throw new TypeError('Argument must not be a number')
16772 }
16773 return Buffer(arg, encodingOrOffset, length)
16774}
16775
16776SafeBuffer.alloc = function (size, fill, encoding) {
16777 if (typeof size !== 'number') {
16778 throw new TypeError('Argument must be a number')
16779 }
16780 var buf = Buffer(size)
16781 if (fill !== undefined) {
16782 if (typeof encoding === 'string') {
16783 buf.fill(fill, encoding)
16784 } else {
16785 buf.fill(fill)
16786 }
16787 } else {
16788 buf.fill(0)
16789 }
16790 return buf
16791}
16792
16793SafeBuffer.allocUnsafe = function (size) {
16794 if (typeof size !== 'number') {
16795 throw new TypeError('Argument must be a number')
16796 }
16797 return Buffer(size)
16798}
16799
16800SafeBuffer.allocUnsafeSlow = function (size) {
16801 if (typeof size !== 'number') {
16802 throw new TypeError('Argument must be a number')
16803 }
16804 return buffer.SlowBuffer(size)
16805}
16806
16807},{"buffer":43}],83:[function(require,module,exports){
16808// Copyright Joyent, Inc. and other Node contributors.
16809//
16810// Permission is hereby granted, free of charge, to any person obtaining a
16811// copy of this software and associated documentation files (the
16812// "Software"), to deal in the Software without restriction, including
16813// without limitation the rights to use, copy, modify, merge, publish,
16814// distribute, sublicense, and/or sell copies of the Software, and to permit
16815// persons to whom the Software is furnished to do so, subject to the
16816// following conditions:
16817//
16818// The above copyright notice and this permission notice shall be included
16819// in all copies or substantial portions of the Software.
16820//
16821// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16822// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16823// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16824// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16825// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16826// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16827// USE OR OTHER DEALINGS IN THE SOFTWARE.
16828
16829module.exports = Stream;
16830
16831var EE = require('events').EventEmitter;
16832var inherits = require('inherits');
16833
16834inherits(Stream, EE);
16835Stream.Readable = require('readable-stream/readable.js');
16836Stream.Writable = require('readable-stream/writable.js');
16837Stream.Duplex = require('readable-stream/duplex.js');
16838Stream.Transform = require('readable-stream/transform.js');
16839Stream.PassThrough = require('readable-stream/passthrough.js');
16840
16841// Backwards-compat with node 0.4.x
16842Stream.Stream = Stream;
16843
16844
16845
16846// old-style streams. Note that the pipe method (the only relevant
16847// part of this class) is overridden in the Readable class.
16848
16849function Stream() {
16850 EE.call(this);
16851}
16852
16853Stream.prototype.pipe = function(dest, options) {
16854 var source = this;
16855
16856 function ondata(chunk) {
16857 if (dest.writable) {
16858 if (false === dest.write(chunk) && source.pause) {
16859 source.pause();
16860 }
16861 }
16862 }
16863
16864 source.on('data', ondata);
16865
16866 function ondrain() {
16867 if (source.readable && source.resume) {
16868 source.resume();
16869 }
16870 }
16871
16872 dest.on('drain', ondrain);
16873
16874 // If the 'end' option is not supplied, dest.end() will be called when
16875 // source gets the 'end' or 'close' events. Only dest.end() once.
16876 if (!dest._isStdio && (!options || options.end !== false)) {
16877 source.on('end', onend);
16878 source.on('close', onclose);
16879 }
16880
16881 var didOnEnd = false;
16882 function onend() {
16883 if (didOnEnd) return;
16884 didOnEnd = true;
16885
16886 dest.end();
16887 }
16888
16889
16890 function onclose() {
16891 if (didOnEnd) return;
16892 didOnEnd = true;
16893
16894 if (typeof dest.destroy === 'function') dest.destroy();
16895 }
16896
16897 // don't leave dangling pipes when there are errors.
16898 function onerror(er) {
16899 cleanup();
16900 if (EE.listenerCount(this, 'error') === 0) {
16901 throw er; // Unhandled stream error in pipe.
16902 }
16903 }
16904
16905 source.on('error', onerror);
16906 dest.on('error', onerror);
16907
16908 // remove all the event listeners that were added.
16909 function cleanup() {
16910 source.removeListener('data', ondata);
16911 dest.removeListener('drain', ondrain);
16912
16913 source.removeListener('end', onend);
16914 source.removeListener('close', onclose);
16915
16916 source.removeListener('error', onerror);
16917 dest.removeListener('error', onerror);
16918
16919 source.removeListener('end', cleanup);
16920 source.removeListener('close', cleanup);
16921
16922 dest.removeListener('close', cleanup);
16923 }
16924
16925 source.on('end', cleanup);
16926 source.on('close', cleanup);
16927
16928 dest.on('close', cleanup);
16929
16930 dest.emit('pipe', source);
16931
16932 // Allow for unix-like usage: A.pipe(B).pipe(C)
16933 return dest;
16934};
16935
16936},{"events":50,"inherits":56,"readable-stream/duplex.js":69,"readable-stream/passthrough.js":78,"readable-stream/readable.js":79,"readable-stream/transform.js":80,"readable-stream/writable.js":81}],84:[function(require,module,exports){
16937// Copyright Joyent, Inc. and other Node contributors.
16938//
16939// Permission is hereby granted, free of charge, to any person obtaining a
16940// copy of this software and associated documentation files (the
16941// "Software"), to deal in the Software without restriction, including
16942// without limitation the rights to use, copy, modify, merge, publish,
16943// distribute, sublicense, and/or sell copies of the Software, and to permit
16944// persons to whom the Software is furnished to do so, subject to the
16945// following conditions:
16946//
16947// The above copyright notice and this permission notice shall be included
16948// in all copies or substantial portions of the Software.
16949//
16950// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16951// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16952// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16953// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16954// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16955// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16956// USE OR OTHER DEALINGS IN THE SOFTWARE.
16957
16958'use strict';
16959
16960/*<replacement>*/
16961
16962var Buffer = require('safe-buffer').Buffer;
16963/*</replacement>*/
16964
16965var isEncoding = Buffer.isEncoding || function (encoding) {
16966 encoding = '' + encoding;
16967 switch (encoding && encoding.toLowerCase()) {
16968 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
16969 return true;
16970 default:
16971 return false;
16972 }
16973};
16974
16975function _normalizeEncoding(enc) {
16976 if (!enc) return 'utf8';
16977 var retried;
16978 while (true) {
16979 switch (enc) {
16980 case 'utf8':
16981 case 'utf-8':
16982 return 'utf8';
16983 case 'ucs2':
16984 case 'ucs-2':
16985 case 'utf16le':
16986 case 'utf-16le':
16987 return 'utf16le';
16988 case 'latin1':
16989 case 'binary':
16990 return 'latin1';
16991 case 'base64':
16992 case 'ascii':
16993 case 'hex':
16994 return enc;
16995 default:
16996 if (retried) return; // undefined
16997 enc = ('' + enc).toLowerCase();
16998 retried = true;
16999 }
17000 }
17001};
17002
17003// Do not cache `Buffer.isEncoding` when checking encoding names as some
17004// modules monkey-patch it to support additional encodings
17005function normalizeEncoding(enc) {
17006 var nenc = _normalizeEncoding(enc);
17007 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
17008 return nenc || enc;
17009}
17010
17011// StringDecoder provides an interface for efficiently splitting a series of
17012// buffers into a series of JS strings without breaking apart multi-byte
17013// characters.
17014exports.StringDecoder = StringDecoder;
17015function StringDecoder(encoding) {
17016 this.encoding = normalizeEncoding(encoding);
17017 var nb;
17018 switch (this.encoding) {
17019 case 'utf16le':
17020 this.text = utf16Text;
17021 this.end = utf16End;
17022 nb = 4;
17023 break;
17024 case 'utf8':
17025 this.fillLast = utf8FillLast;
17026 nb = 4;
17027 break;
17028 case 'base64':
17029 this.text = base64Text;
17030 this.end = base64End;
17031 nb = 3;
17032 break;
17033 default:
17034 this.write = simpleWrite;
17035 this.end = simpleEnd;
17036 return;
17037 }
17038 this.lastNeed = 0;
17039 this.lastTotal = 0;
17040 this.lastChar = Buffer.allocUnsafe(nb);
17041}
17042
17043StringDecoder.prototype.write = function (buf) {
17044 if (buf.length === 0) return '';
17045 var r;
17046 var i;
17047 if (this.lastNeed) {
17048 r = this.fillLast(buf);
17049 if (r === undefined) return '';
17050 i = this.lastNeed;
17051 this.lastNeed = 0;
17052 } else {
17053 i = 0;
17054 }
17055 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
17056 return r || '';
17057};
17058
17059StringDecoder.prototype.end = utf8End;
17060
17061// Returns only complete characters in a Buffer
17062StringDecoder.prototype.text = utf8Text;
17063
17064// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
17065StringDecoder.prototype.fillLast = function (buf) {
17066 if (this.lastNeed <= buf.length) {
17067 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
17068 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17069 }
17070 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
17071 this.lastNeed -= buf.length;
17072};
17073
17074// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
17075// continuation byte. If an invalid byte is detected, -2 is returned.
17076function utf8CheckByte(byte) {
17077 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
17078 return byte >> 6 === 0x02 ? -1 : -2;
17079}
17080
17081// Checks at most 3 bytes at the end of a Buffer in order to detect an
17082// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
17083// needed to complete the UTF-8 character (if applicable) are returned.
17084function utf8CheckIncomplete(self, buf, i) {
17085 var j = buf.length - 1;
17086 if (j < i) return 0;
17087 var nb = utf8CheckByte(buf[j]);
17088 if (nb >= 0) {
17089 if (nb > 0) self.lastNeed = nb - 1;
17090 return nb;
17091 }
17092 if (--j < i || nb === -2) return 0;
17093 nb = utf8CheckByte(buf[j]);
17094 if (nb >= 0) {
17095 if (nb > 0) self.lastNeed = nb - 2;
17096 return nb;
17097 }
17098 if (--j < i || nb === -2) return 0;
17099 nb = utf8CheckByte(buf[j]);
17100 if (nb >= 0) {
17101 if (nb > 0) {
17102 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
17103 }
17104 return nb;
17105 }
17106 return 0;
17107}
17108
17109// Validates as many continuation bytes for a multi-byte UTF-8 character as
17110// needed or are available. If we see a non-continuation byte where we expect
17111// one, we "replace" the validated continuation bytes we've seen so far with
17112// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
17113// behavior. The continuation byte check is included three times in the case
17114// where all of the continuation bytes for a character exist in the same buffer.
17115// It is also done this way as a slight performance increase instead of using a
17116// loop.
17117function utf8CheckExtraBytes(self, buf, p) {
17118 if ((buf[0] & 0xC0) !== 0x80) {
17119 self.lastNeed = 0;
17120 return '\ufffd';
17121 }
17122 if (self.lastNeed > 1 && buf.length > 1) {
17123 if ((buf[1] & 0xC0) !== 0x80) {
17124 self.lastNeed = 1;
17125 return '\ufffd';
17126 }
17127 if (self.lastNeed > 2 && buf.length > 2) {
17128 if ((buf[2] & 0xC0) !== 0x80) {
17129 self.lastNeed = 2;
17130 return '\ufffd';
17131 }
17132 }
17133 }
17134}
17135
17136// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
17137function utf8FillLast(buf) {
17138 var p = this.lastTotal - this.lastNeed;
17139 var r = utf8CheckExtraBytes(this, buf, p);
17140 if (r !== undefined) return r;
17141 if (this.lastNeed <= buf.length) {
17142 buf.copy(this.lastChar, p, 0, this.lastNeed);
17143 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17144 }
17145 buf.copy(this.lastChar, p, 0, buf.length);
17146 this.lastNeed -= buf.length;
17147}
17148
17149// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
17150// partial character, the character's bytes are buffered until the required
17151// number of bytes are available.
17152function utf8Text(buf, i) {
17153 var total = utf8CheckIncomplete(this, buf, i);
17154 if (!this.lastNeed) return buf.toString('utf8', i);
17155 this.lastTotal = total;
17156 var end = buf.length - (total - this.lastNeed);
17157 buf.copy(this.lastChar, 0, end);
17158 return buf.toString('utf8', i, end);
17159}
17160
17161// For UTF-8, a replacement character is added when ending on a partial
17162// character.
17163function utf8End(buf) {
17164 var r = buf && buf.length ? this.write(buf) : '';
17165 if (this.lastNeed) return r + '\ufffd';
17166 return r;
17167}
17168
17169// UTF-16LE typically needs two bytes per character, but even if we have an even
17170// number of bytes available, we need to check if we end on a leading/high
17171// surrogate. In that case, we need to wait for the next two bytes in order to
17172// decode the last character properly.
17173function utf16Text(buf, i) {
17174 if ((buf.length - i) % 2 === 0) {
17175 var r = buf.toString('utf16le', i);
17176 if (r) {
17177 var c = r.charCodeAt(r.length - 1);
17178 if (c >= 0xD800 && c <= 0xDBFF) {
17179 this.lastNeed = 2;
17180 this.lastTotal = 4;
17181 this.lastChar[0] = buf[buf.length - 2];
17182 this.lastChar[1] = buf[buf.length - 1];
17183 return r.slice(0, -1);
17184 }
17185 }
17186 return r;
17187 }
17188 this.lastNeed = 1;
17189 this.lastTotal = 2;
17190 this.lastChar[0] = buf[buf.length - 1];
17191 return buf.toString('utf16le', i, buf.length - 1);
17192}
17193
17194// For UTF-16LE we do not explicitly append special replacement characters if we
17195// end on a partial character, we simply let v8 handle that.
17196function utf16End(buf) {
17197 var r = buf && buf.length ? this.write(buf) : '';
17198 if (this.lastNeed) {
17199 var end = this.lastTotal - this.lastNeed;
17200 return r + this.lastChar.toString('utf16le', 0, end);
17201 }
17202 return r;
17203}
17204
17205function base64Text(buf, i) {
17206 var n = (buf.length - i) % 3;
17207 if (n === 0) return buf.toString('base64', i);
17208 this.lastNeed = 3 - n;
17209 this.lastTotal = 3;
17210 if (n === 1) {
17211 this.lastChar[0] = buf[buf.length - 1];
17212 } else {
17213 this.lastChar[0] = buf[buf.length - 2];
17214 this.lastChar[1] = buf[buf.length - 1];
17215 }
17216 return buf.toString('base64', i, buf.length - n);
17217}
17218
17219function base64End(buf) {
17220 var r = buf && buf.length ? this.write(buf) : '';
17221 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
17222 return r;
17223}
17224
17225// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
17226function simpleWrite(buf) {
17227 return buf.toString(this.encoding);
17228}
17229
17230function simpleEnd(buf) {
17231 return buf && buf.length ? this.write(buf) : '';
17232}
17233},{"safe-buffer":82}],85:[function(require,module,exports){
17234(function (global){
17235
17236/**
17237 * Module exports.
17238 */
17239
17240module.exports = deprecate;
17241
17242/**
17243 * Mark that a method should not be used.
17244 * Returns a modified function which warns once by default.
17245 *
17246 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
17247 *
17248 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
17249 * will throw an Error when invoked.
17250 *
17251 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
17252 * will invoke `console.trace()` instead of `console.error()`.
17253 *
17254 * @param {Function} fn - the function to deprecate
17255 * @param {String} msg - the string to print to the console when `fn` is invoked
17256 * @returns {Function} a new "deprecated" version of `fn`
17257 * @api public
17258 */
17259
17260function deprecate (fn, msg) {
17261 if (config('noDeprecation')) {
17262 return fn;
17263 }
17264
17265 var warned = false;
17266 function deprecated() {
17267 if (!warned) {
17268 if (config('throwDeprecation')) {
17269 throw new Error(msg);
17270 } else if (config('traceDeprecation')) {
17271 console.trace(msg);
17272 } else {
17273 console.warn(msg);
17274 }
17275 warned = true;
17276 }
17277 return fn.apply(this, arguments);
17278 }
17279
17280 return deprecated;
17281}
17282
17283/**
17284 * Checks `localStorage` for boolean values for the given `name`.
17285 *
17286 * @param {String} name
17287 * @returns {Boolean}
17288 * @api private
17289 */
17290
17291function config (name) {
17292 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
17293 try {
17294 if (!global.localStorage) return false;
17295 } catch (_) {
17296 return false;
17297 }
17298 var val = global.localStorage[name];
17299 if (null == val) return false;
17300 return String(val).toLowerCase() === 'true';
17301}
17302
17303}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17304},{}],86:[function(require,module,exports){
17305arguments[4][56][0].apply(exports,arguments)
17306},{"dup":56}],87:[function(require,module,exports){
17307module.exports = function isBuffer(arg) {
17308 return arg && typeof arg === 'object'
17309 && typeof arg.copy === 'function'
17310 && typeof arg.fill === 'function'
17311 && typeof arg.readUInt8 === 'function';
17312}
17313},{}],88:[function(require,module,exports){
17314(function (process,global){
17315// Copyright Joyent, Inc. and other Node contributors.
17316//
17317// Permission is hereby granted, free of charge, to any person obtaining a
17318// copy of this software and associated documentation files (the
17319// "Software"), to deal in the Software without restriction, including
17320// without limitation the rights to use, copy, modify, merge, publish,
17321// distribute, sublicense, and/or sell copies of the Software, and to permit
17322// persons to whom the Software is furnished to do so, subject to the
17323// following conditions:
17324//
17325// The above copyright notice and this permission notice shall be included
17326// in all copies or substantial portions of the Software.
17327//
17328// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17329// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17330// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17331// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17332// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17333// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17334// USE OR OTHER DEALINGS IN THE SOFTWARE.
17335
17336var formatRegExp = /%[sdj%]/g;
17337exports.format = function(f) {
17338 if (!isString(f)) {
17339 var objects = [];
17340 for (var i = 0; i < arguments.length; i++) {
17341 objects.push(inspect(arguments[i]));
17342 }
17343 return objects.join(' ');
17344 }
17345
17346 var i = 1;
17347 var args = arguments;
17348 var len = args.length;
17349 var str = String(f).replace(formatRegExp, function(x) {
17350 if (x === '%%') return '%';
17351 if (i >= len) return x;
17352 switch (x) {
17353 case '%s': return String(args[i++]);
17354 case '%d': return Number(args[i++]);
17355 case '%j':
17356 try {
17357 return JSON.stringify(args[i++]);
17358 } catch (_) {
17359 return '[Circular]';
17360 }
17361 default:
17362 return x;
17363 }
17364 });
17365 for (var x = args[i]; i < len; x = args[++i]) {
17366 if (isNull(x) || !isObject(x)) {
17367 str += ' ' + x;
17368 } else {
17369 str += ' ' + inspect(x);
17370 }
17371 }
17372 return str;
17373};
17374
17375
17376// Mark that a method should not be used.
17377// Returns a modified function which warns once by default.
17378// If --no-deprecation is set, then it is a no-op.
17379exports.deprecate = function(fn, msg) {
17380 // Allow for deprecating things in the process of starting up.
17381 if (isUndefined(global.process)) {
17382 return function() {
17383 return exports.deprecate(fn, msg).apply(this, arguments);
17384 };
17385 }
17386
17387 if (process.noDeprecation === true) {
17388 return fn;
17389 }
17390
17391 var warned = false;
17392 function deprecated() {
17393 if (!warned) {
17394 if (process.throwDeprecation) {
17395 throw new Error(msg);
17396 } else if (process.traceDeprecation) {
17397 console.trace(msg);
17398 } else {
17399 console.error(msg);
17400 }
17401 warned = true;
17402 }
17403 return fn.apply(this, arguments);
17404 }
17405
17406 return deprecated;
17407};
17408
17409
17410var debugs = {};
17411var debugEnviron;
17412exports.debuglog = function(set) {
17413 if (isUndefined(debugEnviron))
17414 debugEnviron = process.env.NODE_DEBUG || '';
17415 set = set.toUpperCase();
17416 if (!debugs[set]) {
17417 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
17418 var pid = process.pid;
17419 debugs[set] = function() {
17420 var msg = exports.format.apply(exports, arguments);
17421 console.error('%s %d: %s', set, pid, msg);
17422 };
17423 } else {
17424 debugs[set] = function() {};
17425 }
17426 }
17427 return debugs[set];
17428};
17429
17430
17431/**
17432 * Echos the value of a value. Trys to print the value out
17433 * in the best way possible given the different types.
17434 *
17435 * @param {Object} obj The object to print out.
17436 * @param {Object} opts Optional options object that alters the output.
17437 */
17438/* legacy: obj, showHidden, depth, colors*/
17439function inspect(obj, opts) {
17440 // default options
17441 var ctx = {
17442 seen: [],
17443 stylize: stylizeNoColor
17444 };
17445 // legacy...
17446 if (arguments.length >= 3) ctx.depth = arguments[2];
17447 if (arguments.length >= 4) ctx.colors = arguments[3];
17448 if (isBoolean(opts)) {
17449 // legacy...
17450 ctx.showHidden = opts;
17451 } else if (opts) {
17452 // got an "options" object
17453 exports._extend(ctx, opts);
17454 }
17455 // set default options
17456 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
17457 if (isUndefined(ctx.depth)) ctx.depth = 2;
17458 if (isUndefined(ctx.colors)) ctx.colors = false;
17459 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
17460 if (ctx.colors) ctx.stylize = stylizeWithColor;
17461 return formatValue(ctx, obj, ctx.depth);
17462}
17463exports.inspect = inspect;
17464
17465
17466// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
17467inspect.colors = {
17468 'bold' : [1, 22],
17469 'italic' : [3, 23],
17470 'underline' : [4, 24],
17471 'inverse' : [7, 27],
17472 'white' : [37, 39],
17473 'grey' : [90, 39],
17474 'black' : [30, 39],
17475 'blue' : [34, 39],
17476 'cyan' : [36, 39],
17477 'green' : [32, 39],
17478 'magenta' : [35, 39],
17479 'red' : [31, 39],
17480 'yellow' : [33, 39]
17481};
17482
17483// Don't use 'blue' not visible on cmd.exe
17484inspect.styles = {
17485 'special': 'cyan',
17486 'number': 'yellow',
17487 'boolean': 'yellow',
17488 'undefined': 'grey',
17489 'null': 'bold',
17490 'string': 'green',
17491 'date': 'magenta',
17492 // "name": intentionally not styling
17493 'regexp': 'red'
17494};
17495
17496
17497function stylizeWithColor(str, styleType) {
17498 var style = inspect.styles[styleType];
17499
17500 if (style) {
17501 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
17502 '\u001b[' + inspect.colors[style][1] + 'm';
17503 } else {
17504 return str;
17505 }
17506}
17507
17508
17509function stylizeNoColor(str, styleType) {
17510 return str;
17511}
17512
17513
17514function arrayToHash(array) {
17515 var hash = {};
17516
17517 array.forEach(function(val, idx) {
17518 hash[val] = true;
17519 });
17520
17521 return hash;
17522}
17523
17524
17525function formatValue(ctx, value, recurseTimes) {
17526 // Provide a hook for user-specified inspect functions.
17527 // Check that value is an object with an inspect function on it
17528 if (ctx.customInspect &&
17529 value &&
17530 isFunction(value.inspect) &&
17531 // Filter out the util module, it's inspect function is special
17532 value.inspect !== exports.inspect &&
17533 // Also filter out any prototype objects using the circular check.
17534 !(value.constructor && value.constructor.prototype === value)) {
17535 var ret = value.inspect(recurseTimes, ctx);
17536 if (!isString(ret)) {
17537 ret = formatValue(ctx, ret, recurseTimes);
17538 }
17539 return ret;
17540 }
17541
17542 // Primitive types cannot have properties
17543 var primitive = formatPrimitive(ctx, value);
17544 if (primitive) {
17545 return primitive;
17546 }
17547
17548 // Look up the keys of the object.
17549 var keys = Object.keys(value);
17550 var visibleKeys = arrayToHash(keys);
17551
17552 if (ctx.showHidden) {
17553 keys = Object.getOwnPropertyNames(value);
17554 }
17555
17556 // IE doesn't make error fields non-enumerable
17557 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
17558 if (isError(value)
17559 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
17560 return formatError(value);
17561 }
17562
17563 // Some type of object without properties can be shortcutted.
17564 if (keys.length === 0) {
17565 if (isFunction(value)) {
17566 var name = value.name ? ': ' + value.name : '';
17567 return ctx.stylize('[Function' + name + ']', 'special');
17568 }
17569 if (isRegExp(value)) {
17570 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
17571 }
17572 if (isDate(value)) {
17573 return ctx.stylize(Date.prototype.toString.call(value), 'date');
17574 }
17575 if (isError(value)) {
17576 return formatError(value);
17577 }
17578 }
17579
17580 var base = '', array = false, braces = ['{', '}'];
17581
17582 // Make Array say that they are Array
17583 if (isArray(value)) {
17584 array = true;
17585 braces = ['[', ']'];
17586 }
17587
17588 // Make functions say that they are functions
17589 if (isFunction(value)) {
17590 var n = value.name ? ': ' + value.name : '';
17591 base = ' [Function' + n + ']';
17592 }
17593
17594 // Make RegExps say that they are RegExps
17595 if (isRegExp(value)) {
17596 base = ' ' + RegExp.prototype.toString.call(value);
17597 }
17598
17599 // Make dates with properties first say the date
17600 if (isDate(value)) {
17601 base = ' ' + Date.prototype.toUTCString.call(value);
17602 }
17603
17604 // Make error with message first say the error
17605 if (isError(value)) {
17606 base = ' ' + formatError(value);
17607 }
17608
17609 if (keys.length === 0 && (!array || value.length == 0)) {
17610 return braces[0] + base + braces[1];
17611 }
17612
17613 if (recurseTimes < 0) {
17614 if (isRegExp(value)) {
17615 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
17616 } else {
17617 return ctx.stylize('[Object]', 'special');
17618 }
17619 }
17620
17621 ctx.seen.push(value);
17622
17623 var output;
17624 if (array) {
17625 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
17626 } else {
17627 output = keys.map(function(key) {
17628 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
17629 });
17630 }
17631
17632 ctx.seen.pop();
17633
17634 return reduceToSingleString(output, base, braces);
17635}
17636
17637
17638function formatPrimitive(ctx, value) {
17639 if (isUndefined(value))
17640 return ctx.stylize('undefined', 'undefined');
17641 if (isString(value)) {
17642 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
17643 .replace(/'/g, "\\'")
17644 .replace(/\\"/g, '"') + '\'';
17645 return ctx.stylize(simple, 'string');
17646 }
17647 if (isNumber(value))
17648 return ctx.stylize('' + value, 'number');
17649 if (isBoolean(value))
17650 return ctx.stylize('' + value, 'boolean');
17651 // For some reason typeof null is "object", so special case here.
17652 if (isNull(value))
17653 return ctx.stylize('null', 'null');
17654}
17655
17656
17657function formatError(value) {
17658 return '[' + Error.prototype.toString.call(value) + ']';
17659}
17660
17661
17662function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
17663 var output = [];
17664 for (var i = 0, l = value.length; i < l; ++i) {
17665 if (hasOwnProperty(value, String(i))) {
17666 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
17667 String(i), true));
17668 } else {
17669 output.push('');
17670 }
17671 }
17672 keys.forEach(function(key) {
17673 if (!key.match(/^\d+$/)) {
17674 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
17675 key, true));
17676 }
17677 });
17678 return output;
17679}
17680
17681
17682function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
17683 var name, str, desc;
17684 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
17685 if (desc.get) {
17686 if (desc.set) {
17687 str = ctx.stylize('[Getter/Setter]', 'special');
17688 } else {
17689 str = ctx.stylize('[Getter]', 'special');
17690 }
17691 } else {
17692 if (desc.set) {
17693 str = ctx.stylize('[Setter]', 'special');
17694 }
17695 }
17696 if (!hasOwnProperty(visibleKeys, key)) {
17697 name = '[' + key + ']';
17698 }
17699 if (!str) {
17700 if (ctx.seen.indexOf(desc.value) < 0) {
17701 if (isNull(recurseTimes)) {
17702 str = formatValue(ctx, desc.value, null);
17703 } else {
17704 str = formatValue(ctx, desc.value, recurseTimes - 1);
17705 }
17706 if (str.indexOf('\n') > -1) {
17707 if (array) {
17708 str = str.split('\n').map(function(line) {
17709 return ' ' + line;
17710 }).join('\n').substr(2);
17711 } else {
17712 str = '\n' + str.split('\n').map(function(line) {
17713 return ' ' + line;
17714 }).join('\n');
17715 }
17716 }
17717 } else {
17718 str = ctx.stylize('[Circular]', 'special');
17719 }
17720 }
17721 if (isUndefined(name)) {
17722 if (array && key.match(/^\d+$/)) {
17723 return str;
17724 }
17725 name = JSON.stringify('' + key);
17726 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
17727 name = name.substr(1, name.length - 2);
17728 name = ctx.stylize(name, 'name');
17729 } else {
17730 name = name.replace(/'/g, "\\'")
17731 .replace(/\\"/g, '"')
17732 .replace(/(^"|"$)/g, "'");
17733 name = ctx.stylize(name, 'string');
17734 }
17735 }
17736
17737 return name + ': ' + str;
17738}
17739
17740
17741function reduceToSingleString(output, base, braces) {
17742 var numLinesEst = 0;
17743 var length = output.reduce(function(prev, cur) {
17744 numLinesEst++;
17745 if (cur.indexOf('\n') >= 0) numLinesEst++;
17746 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
17747 }, 0);
17748
17749 if (length > 60) {
17750 return braces[0] +
17751 (base === '' ? '' : base + '\n ') +
17752 ' ' +
17753 output.join(',\n ') +
17754 ' ' +
17755 braces[1];
17756 }
17757
17758 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
17759}
17760
17761
17762// NOTE: These type checking functions intentionally don't use `instanceof`
17763// because it is fragile and can be easily faked with `Object.create()`.
17764function isArray(ar) {
17765 return Array.isArray(ar);
17766}
17767exports.isArray = isArray;
17768
17769function isBoolean(arg) {
17770 return typeof arg === 'boolean';
17771}
17772exports.isBoolean = isBoolean;
17773
17774function isNull(arg) {
17775 return arg === null;
17776}
17777exports.isNull = isNull;
17778
17779function isNullOrUndefined(arg) {
17780 return arg == null;
17781}
17782exports.isNullOrUndefined = isNullOrUndefined;
17783
17784function isNumber(arg) {
17785 return typeof arg === 'number';
17786}
17787exports.isNumber = isNumber;
17788
17789function isString(arg) {
17790 return typeof arg === 'string';
17791}
17792exports.isString = isString;
17793
17794function isSymbol(arg) {
17795 return typeof arg === 'symbol';
17796}
17797exports.isSymbol = isSymbol;
17798
17799function isUndefined(arg) {
17800 return arg === void 0;
17801}
17802exports.isUndefined = isUndefined;
17803
17804function isRegExp(re) {
17805 return isObject(re) && objectToString(re) === '[object RegExp]';
17806}
17807exports.isRegExp = isRegExp;
17808
17809function isObject(arg) {
17810 return typeof arg === 'object' && arg !== null;
17811}
17812exports.isObject = isObject;
17813
17814function isDate(d) {
17815 return isObject(d) && objectToString(d) === '[object Date]';
17816}
17817exports.isDate = isDate;
17818
17819function isError(e) {
17820 return isObject(e) &&
17821 (objectToString(e) === '[object Error]' || e instanceof Error);
17822}
17823exports.isError = isError;
17824
17825function isFunction(arg) {
17826 return typeof arg === 'function';
17827}
17828exports.isFunction = isFunction;
17829
17830function isPrimitive(arg) {
17831 return arg === null ||
17832 typeof arg === 'boolean' ||
17833 typeof arg === 'number' ||
17834 typeof arg === 'string' ||
17835 typeof arg === 'symbol' || // ES6 symbol
17836 typeof arg === 'undefined';
17837}
17838exports.isPrimitive = isPrimitive;
17839
17840exports.isBuffer = require('./support/isBuffer');
17841
17842function objectToString(o) {
17843 return Object.prototype.toString.call(o);
17844}
17845
17846
17847function pad(n) {
17848 return n < 10 ? '0' + n.toString(10) : n.toString(10);
17849}
17850
17851
17852var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
17853 'Oct', 'Nov', 'Dec'];
17854
17855// 26 Feb 16:19:34
17856function timestamp() {
17857 var d = new Date();
17858 var time = [pad(d.getHours()),
17859 pad(d.getMinutes()),
17860 pad(d.getSeconds())].join(':');
17861 return [d.getDate(), months[d.getMonth()], time].join(' ');
17862}
17863
17864
17865// log is just a thin wrapper to console.log that prepends a timestamp
17866exports.log = function() {
17867 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
17868};
17869
17870
17871/**
17872 * Inherit the prototype methods from one constructor into another.
17873 *
17874 * The Function.prototype.inherits from lang.js rewritten as a standalone
17875 * function (not on Function.prototype). NOTE: If this file is to be loaded
17876 * during bootstrapping this function needs to be rewritten using some native
17877 * functions as prototype setup using normal JavaScript does not work as
17878 * expected during bootstrapping (see mirror.js in r114903).
17879 *
17880 * @param {function} ctor Constructor function which needs to inherit the
17881 * prototype.
17882 * @param {function} superCtor Constructor function to inherit prototype from.
17883 */
17884exports.inherits = require('inherits');
17885
17886exports._extend = function(origin, add) {
17887 // Don't do anything if add isn't an object
17888 if (!add || !isObject(add)) return origin;
17889
17890 var keys = Object.keys(add);
17891 var i = keys.length;
17892 while (i--) {
17893 origin[keys[i]] = add[keys[i]];
17894 }
17895 return origin;
17896};
17897
17898function hasOwnProperty(obj, prop) {
17899 return Object.prototype.hasOwnProperty.call(obj, prop);
17900}
17901
17902}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17903},{"./support/isBuffer":87,"_process":68,"inherits":86}],89:[function(require,module,exports){
17904module.exports={
17905 "name": "mocha",
17906 "version": "6.0.2",
17907 "homepage": "https://mochajs.org/",
17908 "notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
17909}
17910},{}]},{},[1]);