UNPKG

587 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":69,"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":90,"../runner":34,"_process":69}],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|constructor} [options.reporter] - Reporter name or constructor.
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 // Globals are passed in as options.global, with options.globals for backward compatibility.
1504 options.globals = options.global || options.globals || [];
1505 delete options.global;
1506
1507 this.grep(options.grep)
1508 .fgrep(options.fgrep)
1509 .ui(options.ui)
1510 .bail(options.bail)
1511 .reporter(options.reporter, options.reporterOptions)
1512 .useColors(options.color)
1513 .slow(options.slow)
1514 .useInlineDiffs(options.inlineDiffs)
1515 .globals(options.globals);
1516
1517 if ('enableTimeouts' in options) {
1518 utils.deprecate(
1519 'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
1520 );
1521 if (options.enableTimeouts === false) {
1522 this.timeout(0);
1523 }
1524 }
1525
1526 // this guard exists because Suite#timeout does not consider `undefined` to be valid input
1527 if (typeof options.timeout !== 'undefined') {
1528 this.timeout(options.timeout === false ? 0 : options.timeout);
1529 }
1530
1531 if ('retries' in options) {
1532 this.retries(options.retries);
1533 }
1534
1535 if ('diff' in options) {
1536 this.hideDiff(!options.diff);
1537 }
1538
1539 [
1540 'allowUncaught',
1541 'asyncOnly',
1542 'checkLeaks',
1543 'delay',
1544 'forbidOnly',
1545 'forbidPending',
1546 'fullTrace',
1547 'growl',
1548 'invert'
1549 ].forEach(function(opt) {
1550 if (options[opt]) {
1551 this[opt]();
1552 }
1553 }, this);
1554}
1555
1556/**
1557 * Enables or disables bailing on the first failure.
1558 *
1559 * @public
1560 * @see {@link /#-bail-b|CLI option}
1561 * @param {boolean} [bail=true] - Whether to bail on first error.
1562 * @returns {Mocha} this
1563 * @chainable
1564 */
1565Mocha.prototype.bail = function(bail) {
1566 if (!arguments.length) {
1567 bail = true;
1568 }
1569 this.suite.bail(bail);
1570 return this;
1571};
1572
1573/**
1574 * @summary
1575 * Adds `file` to be loaded for execution.
1576 *
1577 * @description
1578 * Useful for generic setup code that must be included within test suite.
1579 *
1580 * @public
1581 * @see {@link /#-file-filedirectoryglob|CLI option}
1582 * @param {string} file - Pathname of file to be loaded.
1583 * @returns {Mocha} this
1584 * @chainable
1585 */
1586Mocha.prototype.addFile = function(file) {
1587 this.files.push(file);
1588 return this;
1589};
1590
1591/**
1592 * Sets reporter to `reporter`, defaults to "spec".
1593 *
1594 * @public
1595 * @see {@link /#-reporter-name-r-name|CLI option}
1596 * @see {@link /#reporters|Reporters}
1597 * @param {String|Function} reporter - Reporter name or constructor.
1598 * @param {Object} [reporterOptions] - Options used to configure the reporter.
1599 * @returns {Mocha} this
1600 * @chainable
1601 * @throws {Error} if requested reporter cannot be loaded
1602 * @example
1603 *
1604 * // Use XUnit reporter and direct its output to file
1605 * mocha.reporter('xunit', { output: '/path/to/testspec.xunit.xml' });
1606 */
1607Mocha.prototype.reporter = function(reporter, reporterOptions) {
1608 if (typeof reporter === 'function') {
1609 this._reporter = reporter;
1610 } else {
1611 reporter = reporter || 'spec';
1612 var _reporter;
1613 // Try to load a built-in reporter.
1614 if (builtinReporters[reporter]) {
1615 _reporter = builtinReporters[reporter];
1616 }
1617 // Try to load reporters from process.cwd() and node_modules
1618 if (!_reporter) {
1619 try {
1620 _reporter = require(reporter);
1621 } catch (err) {
1622 if (
1623 err.code !== 'MODULE_NOT_FOUND' ||
1624 err.message.indexOf('Cannot find module') !== -1
1625 ) {
1626 // Try to load reporters from a path (absolute or relative)
1627 try {
1628 _reporter = require(path.resolve(process.cwd(), reporter));
1629 } catch (_err) {
1630 _err.code !== 'MODULE_NOT_FOUND' ||
1631 _err.message.indexOf('Cannot find module') !== -1
1632 ? console.warn(sQuote(reporter) + ' reporter not found')
1633 : console.warn(
1634 sQuote(reporter) +
1635 ' reporter blew up with error:\n' +
1636 err.stack
1637 );
1638 }
1639 } else {
1640 console.warn(
1641 sQuote(reporter) + ' reporter blew up with error:\n' + err.stack
1642 );
1643 }
1644 }
1645 }
1646 if (!_reporter) {
1647 throw createInvalidReporterError(
1648 'invalid reporter ' + sQuote(reporter),
1649 reporter
1650 );
1651 }
1652 this._reporter = _reporter;
1653 }
1654 this.options.reporterOptions = reporterOptions;
1655 return this;
1656};
1657
1658/**
1659 * Sets test UI `name`, defaults to "bdd".
1660 *
1661 * @public
1662 * @see {@link /#-ui-name-u-name|CLI option}
1663 * @see {@link /#interfaces|Interface DSLs}
1664 * @param {string|Function} [ui=bdd] - Interface name or class.
1665 * @returns {Mocha} this
1666 * @chainable
1667 * @throws {Error} if requested interface cannot be loaded
1668 */
1669Mocha.prototype.ui = function(ui) {
1670 var bindInterface;
1671 if (typeof ui === 'function') {
1672 bindInterface = ui;
1673 } else {
1674 ui = ui || 'bdd';
1675 bindInterface = exports.interfaces[ui];
1676 if (!bindInterface) {
1677 try {
1678 bindInterface = require(ui);
1679 } catch (err) {
1680 throw createInvalidInterfaceError(
1681 'invalid interface ' + sQuote(ui),
1682 ui
1683 );
1684 }
1685 }
1686 }
1687 bindInterface(this.suite);
1688
1689 this.suite.on(EVENT_FILE_PRE_REQUIRE, function(context) {
1690 exports.afterEach = context.afterEach || context.teardown;
1691 exports.after = context.after || context.suiteTeardown;
1692 exports.beforeEach = context.beforeEach || context.setup;
1693 exports.before = context.before || context.suiteSetup;
1694 exports.describe = context.describe || context.suite;
1695 exports.it = context.it || context.test;
1696 exports.xit = context.xit || (context.test && context.test.skip);
1697 exports.setup = context.setup || context.beforeEach;
1698 exports.suiteSetup = context.suiteSetup || context.before;
1699 exports.suiteTeardown = context.suiteTeardown || context.after;
1700 exports.suite = context.suite || context.describe;
1701 exports.teardown = context.teardown || context.afterEach;
1702 exports.test = context.test || context.it;
1703 exports.run = context.run;
1704 });
1705
1706 return this;
1707};
1708
1709/**
1710 * Loads `files` prior to execution.
1711 *
1712 * @description
1713 * The implementation relies on Node's `require` to execute
1714 * the test interface functions and will be subject to its cache.
1715 *
1716 * @private
1717 * @see {@link Mocha#addFile}
1718 * @see {@link Mocha#run}
1719 * @see {@link Mocha#unloadFiles}
1720 * @param {Function} [fn] - Callback invoked upon completion.
1721 */
1722Mocha.prototype.loadFiles = function(fn) {
1723 var self = this;
1724 var suite = this.suite;
1725 this.files.forEach(function(file) {
1726 file = path.resolve(file);
1727 suite.emit(EVENT_FILE_PRE_REQUIRE, global, file, self);
1728 suite.emit(EVENT_FILE_REQUIRE, require(file), file, self);
1729 suite.emit(EVENT_FILE_POST_REQUIRE, global, file, self);
1730 });
1731 fn && fn();
1732};
1733
1734/**
1735 * Removes a previously loaded file from Node's `require` cache.
1736 *
1737 * @private
1738 * @static
1739 * @see {@link Mocha#unloadFiles}
1740 * @param {string} file - Pathname of file to be unloaded.
1741 */
1742Mocha.unloadFile = function(file) {
1743 delete require.cache[require.resolve(file)];
1744};
1745
1746/**
1747 * Unloads `files` from Node's `require` cache.
1748 *
1749 * @description
1750 * This allows files to be "freshly" reloaded, providing the ability
1751 * to reuse a Mocha instance programmatically.
1752 *
1753 * <strong>Intended for consumers &mdash; not used internally</strong>
1754 *
1755 * @public
1756 * @see {@link Mocha.unloadFile}
1757 * @see {@link Mocha#loadFiles}
1758 * @see {@link Mocha#run}
1759 * @returns {Mocha} this
1760 * @chainable
1761 */
1762Mocha.prototype.unloadFiles = function() {
1763 this.files.forEach(Mocha.unloadFile);
1764 return this;
1765};
1766
1767/**
1768 * Sets `grep` filter after escaping RegExp special characters.
1769 *
1770 * @public
1771 * @see {@link Mocha#grep}
1772 * @param {string} str - Value to be converted to a regexp.
1773 * @returns {Mocha} this
1774 * @chainable
1775 * @example
1776 *
1777 * // Select tests whose full title begins with `"foo"` followed by a period
1778 * mocha.fgrep('foo.');
1779 */
1780Mocha.prototype.fgrep = function(str) {
1781 if (!str) {
1782 return this;
1783 }
1784 return this.grep(new RegExp(escapeRe(str)));
1785};
1786
1787/**
1788 * @summary
1789 * Sets `grep` filter used to select specific tests for execution.
1790 *
1791 * @description
1792 * If `re` is a regexp-like string, it will be converted to regexp.
1793 * The regexp is tested against the full title of each test (i.e., the
1794 * name of the test preceded by titles of each its ancestral suites).
1795 * As such, using an <em>exact-match</em> fixed pattern against the
1796 * test name itself will not yield any matches.
1797 * <br>
1798 * <strong>Previous filter value will be overwritten on each call!</strong>
1799 *
1800 * @public
1801 * @see {@link /#grep-regexp-g-regexp|CLI option}
1802 * @see {@link Mocha#fgrep}
1803 * @see {@link Mocha#invert}
1804 * @param {RegExp|String} re - Regular expression used to select tests.
1805 * @return {Mocha} this
1806 * @chainable
1807 * @example
1808 *
1809 * // Select tests whose full title contains `"match"`, ignoring case
1810 * mocha.grep(/match/i);
1811 * @example
1812 *
1813 * // Same as above but with regexp-like string argument
1814 * mocha.grep('/match/i');
1815 * @example
1816 *
1817 * // ## Anti-example
1818 * // Given embedded test `it('only-this-test')`...
1819 * mocha.grep('/^only-this-test$/'); // NO! Use `.only()` to do this!
1820 */
1821Mocha.prototype.grep = function(re) {
1822 if (utils.isString(re)) {
1823 // extract args if it's regex-like, i.e: [string, pattern, flag]
1824 var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
1825 this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
1826 } else {
1827 this.options.grep = re;
1828 }
1829 return this;
1830};
1831
1832/**
1833 * Inverts `grep` matches.
1834 *
1835 * @public
1836 * @see {@link Mocha#grep}
1837 * @return {Mocha} this
1838 * @chainable
1839 * @example
1840 *
1841 * // Select tests whose full title does *not* contain `"match"`, ignoring case
1842 * mocha.grep(/match/i).invert();
1843 */
1844Mocha.prototype.invert = function() {
1845 this.options.invert = true;
1846 return this;
1847};
1848
1849/**
1850 * Enables or disables ignoring global leaks.
1851 *
1852 * @public
1853 * @see {@link Mocha#checkLeaks}
1854 * @param {boolean} ignoreLeaks - Whether to ignore global leaks.
1855 * @return {Mocha} this
1856 * @chainable
1857 * @example
1858 *
1859 * // Ignore global leaks
1860 * mocha.ignoreLeaks(true);
1861 */
1862Mocha.prototype.ignoreLeaks = function(ignoreLeaks) {
1863 this.options.ignoreLeaks = Boolean(ignoreLeaks);
1864 return this;
1865};
1866
1867/**
1868 * Enables checking for global variables leaked while running tests.
1869 *
1870 * @public
1871 * @see {@link /#-check-leaks|CLI option}
1872 * @see {@link Mocha#ignoreLeaks}
1873 * @return {Mocha} this
1874 * @chainable
1875 */
1876Mocha.prototype.checkLeaks = function() {
1877 this.options.ignoreLeaks = false;
1878 return this;
1879};
1880
1881/**
1882 * Displays full stack trace upon test failure.
1883 *
1884 * @public
1885 * @return {Mocha} this
1886 * @chainable
1887 */
1888Mocha.prototype.fullTrace = function() {
1889 this.options.fullStackTrace = true;
1890 return this;
1891};
1892
1893/**
1894 * Enables desktop notification support if prerequisite software installed.
1895 *
1896 * @public
1897 * @see {@link Mocha#isGrowlCapable}
1898 * @see {@link Mocha#_growl}
1899 * @return {Mocha} this
1900 * @chainable
1901 */
1902Mocha.prototype.growl = function() {
1903 this.options.growl = this.isGrowlCapable();
1904 if (!this.options.growl) {
1905 var detail = process.browser
1906 ? 'notification support not available in this browser...'
1907 : 'notification support prerequisites not installed...';
1908 console.error(detail + ' cannot enable!');
1909 }
1910 return this;
1911};
1912
1913/**
1914 * @summary
1915 * Determines if Growl support seems likely.
1916 *
1917 * @description
1918 * <strong>Not available when run in browser.</strong>
1919 *
1920 * @private
1921 * @see {@link Growl#isCapable}
1922 * @see {@link Mocha#growl}
1923 * @return {boolean} whether Growl support can be expected
1924 */
1925Mocha.prototype.isGrowlCapable = growl.isCapable;
1926
1927/**
1928 * Implements desktop notifications using a pseudo-reporter.
1929 *
1930 * @private
1931 * @see {@link Mocha#growl}
1932 * @see {@link Growl#notify}
1933 * @param {Runner} runner - Runner instance.
1934 */
1935Mocha.prototype._growl = growl.notify;
1936
1937/**
1938 * Specifies whitelist of variable names to be expected in global scope.
1939 *
1940 * @public
1941 * @see {@link /#-global-variable-name|CLI option}
1942 * @see {@link Mocha#checkLeaks}
1943 * @param {String[]|String} globals - Accepted global variable name(s).
1944 * @return {Mocha} this
1945 * @chainable
1946 * @example
1947 *
1948 * // Specify variables to be expected in global scope
1949 * mocha.globals(['jQuery', 'MyLib']);
1950 */
1951Mocha.prototype.globals = function(globals) {
1952 this.options.globals = this.options.globals
1953 .concat(globals)
1954 .filter(Boolean)
1955 .filter(function(elt, idx, arr) {
1956 return arr.indexOf(elt) === idx;
1957 });
1958 return this;
1959};
1960
1961/**
1962 * Enables or disables TTY color output by screen-oriented reporters.
1963 *
1964 * @public
1965 * @param {boolean} colors - Whether to enable color output.
1966 * @return {Mocha} this
1967 * @chainable
1968 */
1969Mocha.prototype.useColors = function(colors) {
1970 if (colors !== undefined) {
1971 this.options.useColors = colors;
1972 }
1973 return this;
1974};
1975
1976/**
1977 * Determines if reporter should use inline diffs (rather than +/-)
1978 * in test failure output.
1979 *
1980 * @public
1981 * @param {boolean} inlineDiffs - Whether to use inline diffs.
1982 * @return {Mocha} this
1983 * @chainable
1984 */
1985Mocha.prototype.useInlineDiffs = function(inlineDiffs) {
1986 this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
1987 return this;
1988};
1989
1990/**
1991 * Determines if reporter should include diffs in test failure output.
1992 *
1993 * @public
1994 * @param {boolean} hideDiff - Whether to hide diffs.
1995 * @return {Mocha} this
1996 * @chainable
1997 */
1998Mocha.prototype.hideDiff = function(hideDiff) {
1999 this.options.hideDiff = hideDiff !== undefined && hideDiff;
2000 return this;
2001};
2002
2003/**
2004 * @summary
2005 * Sets timeout threshold value.
2006 *
2007 * @description
2008 * A string argument can use shorthand (such as "2s") and will be converted.
2009 * If the value is `0`, timeouts will be disabled.
2010 *
2011 * @public
2012 * @see {@link /#-timeout-ms-t-ms|CLI option}
2013 * @see {@link /#timeouts|Timeouts}
2014 * @see {@link Mocha#enableTimeouts}
2015 * @param {number|string} msecs - Timeout threshold value.
2016 * @return {Mocha} this
2017 * @chainable
2018 * @example
2019 *
2020 * // Sets timeout to one second
2021 * mocha.timeout(1000);
2022 * @example
2023 *
2024 * // Same as above but using string argument
2025 * mocha.timeout('1s');
2026 */
2027Mocha.prototype.timeout = function(msecs) {
2028 this.suite.timeout(msecs);
2029 return this;
2030};
2031
2032/**
2033 * Sets the number of times to retry failed tests.
2034 *
2035 * @public
2036 * @see {@link /#retry-tests|Retry Tests}
2037 * @param {number} retry - Number of times to retry failed tests.
2038 * @return {Mocha} this
2039 * @chainable
2040 * @example
2041 *
2042 * // Allow any failed test to retry one more time
2043 * mocha.retries(1);
2044 */
2045Mocha.prototype.retries = function(n) {
2046 this.suite.retries(n);
2047 return this;
2048};
2049
2050/**
2051 * Sets slowness threshold value.
2052 *
2053 * @public
2054 * @see {@link /#-slow-ms-s-ms|CLI option}
2055 * @param {number} msecs - Slowness threshold value.
2056 * @return {Mocha} this
2057 * @chainable
2058 * @example
2059 *
2060 * // Sets "slow" threshold to half a second
2061 * mocha.slow(500);
2062 * @example
2063 *
2064 * // Same as above but using string argument
2065 * mocha.slow('0.5s');
2066 */
2067Mocha.prototype.slow = function(msecs) {
2068 this.suite.slow(msecs);
2069 return this;
2070};
2071
2072/**
2073 * Enables or disables timeouts.
2074 *
2075 * @public
2076 * @see {@link /#-timeout-ms-t-ms|CLI option}
2077 * @param {boolean} enableTimeouts - Whether to enable timeouts.
2078 * @return {Mocha} this
2079 * @chainable
2080 */
2081Mocha.prototype.enableTimeouts = function(enableTimeouts) {
2082 this.suite.enableTimeouts(
2083 arguments.length && enableTimeouts !== undefined ? enableTimeouts : true
2084 );
2085 return this;
2086};
2087
2088/**
2089 * Forces all tests to either accept a `done` callback or return a promise.
2090 *
2091 * @public
2092 * @return {Mocha} this
2093 * @chainable
2094 */
2095Mocha.prototype.asyncOnly = function() {
2096 this.options.asyncOnly = true;
2097 return this;
2098};
2099
2100/**
2101 * Disables syntax highlighting (in browser).
2102 *
2103 * @public
2104 * @return {Mocha} this
2105 * @chainable
2106 */
2107Mocha.prototype.noHighlighting = function() {
2108 this.options.noHighlighting = true;
2109 return this;
2110};
2111
2112/**
2113 * Enables uncaught errors to propagate (in browser).
2114 *
2115 * @public
2116 * @return {Mocha} this
2117 * @chainable
2118 */
2119Mocha.prototype.allowUncaught = function() {
2120 this.options.allowUncaught = true;
2121 return this;
2122};
2123
2124/**
2125 * @summary
2126 * Delays root suite execution.
2127 *
2128 * @description
2129 * Used to perform asynch operations before any suites are run.
2130 *
2131 * @public
2132 * @see {@link /#delayed-root-suite|delayed root suite}
2133 * @returns {Mocha} this
2134 * @chainable
2135 */
2136Mocha.prototype.delay = function delay() {
2137 this.options.delay = true;
2138 return this;
2139};
2140
2141/**
2142 * Causes tests marked `only` to fail the suite.
2143 *
2144 * @public
2145 * @returns {Mocha} this
2146 * @chainable
2147 */
2148Mocha.prototype.forbidOnly = function() {
2149 this.options.forbidOnly = true;
2150 return this;
2151};
2152
2153/**
2154 * Causes pending tests and tests marked `skip` to fail the suite.
2155 *
2156 * @public
2157 * @returns {Mocha} this
2158 * @chainable
2159 */
2160Mocha.prototype.forbidPending = function() {
2161 this.options.forbidPending = true;
2162 return this;
2163};
2164
2165/**
2166 * Mocha version as specified by "package.json".
2167 *
2168 * @name Mocha#version
2169 * @type string
2170 * @readonly
2171 */
2172Object.defineProperty(Mocha.prototype, 'version', {
2173 value: require('../package.json').version,
2174 configurable: false,
2175 enumerable: true,
2176 writable: false
2177});
2178
2179/**
2180 * Callback to be invoked when test execution is complete.
2181 *
2182 * @callback DoneCB
2183 * @param {number} failures - Number of failures that occurred.
2184 */
2185
2186/**
2187 * Runs root suite and invokes `fn()` when complete.
2188 *
2189 * @description
2190 * To run tests multiple times (or to run tests in files that are
2191 * already in the `require` cache), make sure to clear them from
2192 * the cache first!
2193 *
2194 * @public
2195 * @see {@link Mocha#loadFiles}
2196 * @see {@link Mocha#unloadFiles}
2197 * @see {@link Runner#run}
2198 * @param {DoneCB} [fn] - Callback invoked when test execution completed.
2199 * @return {Runner} runner instance
2200 */
2201Mocha.prototype.run = function(fn) {
2202 if (this.files.length) {
2203 this.loadFiles();
2204 }
2205 var suite = this.suite;
2206 var options = this.options;
2207 options.files = this.files;
2208 var runner = new exports.Runner(suite, options.delay);
2209 createStatsCollector(runner);
2210 var reporter = new this._reporter(runner, options);
2211 runner.ignoreLeaks = options.ignoreLeaks !== false;
2212 runner.fullStackTrace = options.fullStackTrace;
2213 runner.asyncOnly = options.asyncOnly;
2214 runner.allowUncaught = options.allowUncaught;
2215 runner.forbidOnly = options.forbidOnly;
2216 runner.forbidPending = options.forbidPending;
2217 if (options.grep) {
2218 runner.grep(options.grep, options.invert);
2219 }
2220 if (options.globals) {
2221 runner.globals(options.globals);
2222 }
2223 if (options.growl) {
2224 this._growl(runner);
2225 }
2226 if (options.useColors !== undefined) {
2227 exports.reporters.Base.useColors = options.useColors;
2228 }
2229 exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
2230 exports.reporters.Base.hideDiff = options.hideDiff;
2231
2232 function done(failures) {
2233 fn = fn || utils.noop;
2234 if (reporter.done) {
2235 reporter.done(failures, fn);
2236 } else {
2237 fn(failures);
2238 }
2239 }
2240
2241 return runner.run(done);
2242};
2243
2244}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2245},{"../package.json":90,"./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":69,"escape-string-regexp":49,"path":42}],15:[function(require,module,exports){
2246module.exports={
2247 "diff": true,
2248 "extension": ["js"],
2249 "opts": "./test/mocha.opts",
2250 "package": "./package.json",
2251 "reporter": "spec",
2252 "slow": 75,
2253 "timeout": 2000,
2254 "ui": "bdd"
2255}
2256
2257},{}],16:[function(require,module,exports){
2258'use strict';
2259
2260module.exports = Pending;
2261
2262/**
2263 * Initialize a new `Pending` error with the given message.
2264 *
2265 * @param {string} message
2266 */
2267function Pending(message) {
2268 this.message = message;
2269}
2270
2271},{}],17:[function(require,module,exports){
2272(function (process){
2273'use strict';
2274/**
2275 * @module Base
2276 */
2277/**
2278 * Module dependencies.
2279 */
2280
2281var tty = require('tty');
2282var diff = require('diff');
2283var milliseconds = require('ms');
2284var utils = require('../utils');
2285var supportsColor = process.browser ? null : require('supports-color');
2286var constants = require('../runner').constants;
2287var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2288var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2289
2290/**
2291 * Expose `Base`.
2292 */
2293
2294exports = module.exports = Base;
2295
2296/**
2297 * Check if both stdio streams are associated with a tty.
2298 */
2299
2300var isatty = process.stdout.isTTY && process.stderr.isTTY;
2301
2302/**
2303 * Save log references to avoid tests interfering (see GH-3604).
2304 */
2305var consoleLog = console.log;
2306
2307/**
2308 * Enable coloring by default, except in the browser interface.
2309 */
2310
2311exports.useColors =
2312 !process.browser &&
2313 (supportsColor.stdout || process.env.MOCHA_COLORS !== undefined);
2314
2315/**
2316 * Inline diffs instead of +/-
2317 */
2318
2319exports.inlineDiffs = false;
2320
2321/**
2322 * Default color map.
2323 */
2324
2325exports.colors = {
2326 pass: 90,
2327 fail: 31,
2328 'bright pass': 92,
2329 'bright fail': 91,
2330 'bright yellow': 93,
2331 pending: 36,
2332 suite: 0,
2333 'error title': 0,
2334 'error message': 31,
2335 'error stack': 90,
2336 checkmark: 32,
2337 fast: 90,
2338 medium: 33,
2339 slow: 31,
2340 green: 32,
2341 light: 90,
2342 'diff gutter': 90,
2343 'diff added': 32,
2344 'diff removed': 31
2345};
2346
2347/**
2348 * Default symbol map.
2349 */
2350
2351exports.symbols = {
2352 ok: '✓',
2353 err: '✖',
2354 dot: '․',
2355 comma: ',',
2356 bang: '!'
2357};
2358
2359// With node.js on Windows: use symbols available in terminal default fonts
2360if (process.platform === 'win32') {
2361 exports.symbols.ok = '\u221A';
2362 exports.symbols.err = '\u00D7';
2363 exports.symbols.dot = '.';
2364}
2365
2366/**
2367 * Color `str` with the given `type`,
2368 * allowing colors to be disabled,
2369 * as well as user-defined color
2370 * schemes.
2371 *
2372 * @private
2373 * @param {string} type
2374 * @param {string} str
2375 * @return {string}
2376 */
2377var color = (exports.color = function(type, str) {
2378 if (!exports.useColors) {
2379 return String(str);
2380 }
2381 return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
2382});
2383
2384/**
2385 * Expose term window size, with some defaults for when stderr is not a tty.
2386 */
2387
2388exports.window = {
2389 width: 75
2390};
2391
2392if (isatty) {
2393 exports.window.width = process.stdout.getWindowSize
2394 ? process.stdout.getWindowSize(1)[0]
2395 : tty.getWindowSize()[1];
2396}
2397
2398/**
2399 * Expose some basic cursor interactions that are common among reporters.
2400 */
2401
2402exports.cursor = {
2403 hide: function() {
2404 isatty && process.stdout.write('\u001b[?25l');
2405 },
2406
2407 show: function() {
2408 isatty && process.stdout.write('\u001b[?25h');
2409 },
2410
2411 deleteLine: function() {
2412 isatty && process.stdout.write('\u001b[2K');
2413 },
2414
2415 beginningOfLine: function() {
2416 isatty && process.stdout.write('\u001b[0G');
2417 },
2418
2419 CR: function() {
2420 if (isatty) {
2421 exports.cursor.deleteLine();
2422 exports.cursor.beginningOfLine();
2423 } else {
2424 process.stdout.write('\r');
2425 }
2426 }
2427};
2428
2429function showDiff(err) {
2430 return (
2431 err &&
2432 err.showDiff !== false &&
2433 sameType(err.actual, err.expected) &&
2434 err.expected !== undefined
2435 );
2436}
2437
2438function stringifyDiffObjs(err) {
2439 if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
2440 err.actual = utils.stringify(err.actual);
2441 err.expected = utils.stringify(err.expected);
2442 }
2443}
2444
2445/**
2446 * Returns a diff between 2 strings with coloured ANSI output.
2447 *
2448 * @description
2449 * The diff will be either inline or unified dependent on the value
2450 * of `Base.inlineDiff`.
2451 *
2452 * @param {string} actual
2453 * @param {string} expected
2454 * @return {string} Diff
2455 */
2456var generateDiff = (exports.generateDiff = function(actual, expected) {
2457 return exports.inlineDiffs
2458 ? inlineDiff(actual, expected)
2459 : unifiedDiff(actual, expected);
2460});
2461
2462/**
2463 * Outputs the given `failures` as a list.
2464 *
2465 * @public
2466 * @memberof Mocha.reporters.Base
2467 * @variation 1
2468 * @param {Object[]} failures - Each is Test instance with corresponding
2469 * Error property
2470 */
2471exports.list = function(failures) {
2472 var multipleErr, multipleTest;
2473 Base.consoleLog();
2474 failures.forEach(function(test, i) {
2475 // format
2476 var fmt =
2477 color('error title', ' %s) %s:\n') +
2478 color('error message', ' %s') +
2479 color('error stack', '\n%s\n');
2480
2481 // msg
2482 var msg;
2483 var err;
2484 if (test.err && test.err.multiple) {
2485 if (multipleTest !== test) {
2486 multipleTest = test;
2487 multipleErr = [test.err].concat(test.err.multiple);
2488 }
2489 err = multipleErr.shift();
2490 } else {
2491 err = test.err;
2492 }
2493 var message;
2494 if (err.message && typeof err.message.toString === 'function') {
2495 message = err.message + '';
2496 } else if (typeof err.inspect === 'function') {
2497 message = err.inspect() + '';
2498 } else {
2499 message = '';
2500 }
2501 var stack = err.stack || message;
2502 var index = message ? stack.indexOf(message) : -1;
2503
2504 if (index === -1) {
2505 msg = message;
2506 } else {
2507 index += message.length;
2508 msg = stack.slice(0, index);
2509 // remove msg from stack
2510 stack = stack.slice(index + 1);
2511 }
2512
2513 // uncaught
2514 if (err.uncaught) {
2515 msg = 'Uncaught ' + msg;
2516 }
2517 // explicitly show diff
2518 if (!exports.hideDiff && showDiff(err)) {
2519 stringifyDiffObjs(err);
2520 fmt =
2521 color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
2522 var match = message.match(/^([^:]+): expected/);
2523 msg = '\n ' + color('error message', match ? match[1] : msg);
2524
2525 msg += generateDiff(err.actual, err.expected);
2526 }
2527
2528 // indent stack trace
2529 stack = stack.replace(/^/gm, ' ');
2530
2531 // indented test title
2532 var testTitle = '';
2533 test.titlePath().forEach(function(str, index) {
2534 if (index !== 0) {
2535 testTitle += '\n ';
2536 }
2537 for (var i = 0; i < index; i++) {
2538 testTitle += ' ';
2539 }
2540 testTitle += str;
2541 });
2542
2543 Base.consoleLog(fmt, i + 1, testTitle, msg, stack);
2544 });
2545};
2546
2547/**
2548 * Constructs a new `Base` reporter instance.
2549 *
2550 * @description
2551 * All other reporters generally inherit from this reporter.
2552 *
2553 * @public
2554 * @class
2555 * @memberof Mocha.reporters
2556 * @param {Runner} runner - Instance triggers reporter actions.
2557 * @param {Object} [options] - runner options
2558 */
2559function Base(runner, options) {
2560 var failures = (this.failures = []);
2561
2562 if (!runner) {
2563 throw new TypeError('Missing runner argument');
2564 }
2565 this.options = options || {};
2566 this.runner = runner;
2567 this.stats = runner.stats; // assigned so Reporters keep a closer reference
2568
2569 runner.on(EVENT_TEST_PASS, function(test) {
2570 if (test.duration > test.slow()) {
2571 test.speed = 'slow';
2572 } else if (test.duration > test.slow() / 2) {
2573 test.speed = 'medium';
2574 } else {
2575 test.speed = 'fast';
2576 }
2577 });
2578
2579 runner.on(EVENT_TEST_FAIL, function(test, err) {
2580 if (showDiff(err)) {
2581 stringifyDiffObjs(err);
2582 }
2583 // more than one error per test
2584 if (test.err && err instanceof Error) {
2585 test.err.multiple = (test.err.multiple || []).concat(err);
2586 } else {
2587 test.err = err;
2588 }
2589 failures.push(test);
2590 });
2591}
2592
2593/**
2594 * Outputs common epilogue used by many of the bundled reporters.
2595 *
2596 * @public
2597 * @memberof Mocha.reporters
2598 */
2599Base.prototype.epilogue = function() {
2600 var stats = this.stats;
2601 var fmt;
2602
2603 Base.consoleLog();
2604
2605 // passes
2606 fmt =
2607 color('bright pass', ' ') +
2608 color('green', ' %d passing') +
2609 color('light', ' (%s)');
2610
2611 Base.consoleLog(fmt, stats.passes || 0, milliseconds(stats.duration));
2612
2613 // pending
2614 if (stats.pending) {
2615 fmt = color('pending', ' ') + color('pending', ' %d pending');
2616
2617 Base.consoleLog(fmt, stats.pending);
2618 }
2619
2620 // failures
2621 if (stats.failures) {
2622 fmt = color('fail', ' %d failing');
2623
2624 Base.consoleLog(fmt, stats.failures);
2625
2626 Base.list(this.failures);
2627 Base.consoleLog();
2628 }
2629
2630 Base.consoleLog();
2631};
2632
2633/**
2634 * Pads the given `str` to `len`.
2635 *
2636 * @private
2637 * @param {string} str
2638 * @param {string} len
2639 * @return {string}
2640 */
2641function pad(str, len) {
2642 str = String(str);
2643 return Array(len - str.length + 1).join(' ') + str;
2644}
2645
2646/**
2647 * Returns inline diff between 2 strings with coloured ANSI output.
2648 *
2649 * @private
2650 * @param {String} actual
2651 * @param {String} expected
2652 * @return {string} Diff
2653 */
2654function inlineDiff(actual, expected) {
2655 var msg = errorDiff(actual, expected);
2656
2657 // linenos
2658 var lines = msg.split('\n');
2659 if (lines.length > 4) {
2660 var width = String(lines.length).length;
2661 msg = lines
2662 .map(function(str, i) {
2663 return pad(++i, width) + ' |' + ' ' + str;
2664 })
2665 .join('\n');
2666 }
2667
2668 // legend
2669 msg =
2670 '\n' +
2671 color('diff removed', 'actual') +
2672 ' ' +
2673 color('diff added', 'expected') +
2674 '\n\n' +
2675 msg +
2676 '\n';
2677
2678 // indent
2679 msg = msg.replace(/^/gm, ' ');
2680 return msg;
2681}
2682
2683/**
2684 * Returns unified diff between two strings with coloured ANSI output.
2685 *
2686 * @private
2687 * @param {String} actual
2688 * @param {String} expected
2689 * @return {string} The diff.
2690 */
2691function unifiedDiff(actual, expected) {
2692 var indent = ' ';
2693 function cleanUp(line) {
2694 if (line[0] === '+') {
2695 return indent + colorLines('diff added', line);
2696 }
2697 if (line[0] === '-') {
2698 return indent + colorLines('diff removed', line);
2699 }
2700 if (line.match(/@@/)) {
2701 return '--';
2702 }
2703 if (line.match(/\\ No newline/)) {
2704 return null;
2705 }
2706 return indent + line;
2707 }
2708 function notBlank(line) {
2709 return typeof line !== 'undefined' && line !== null;
2710 }
2711 var msg = diff.createPatch('string', actual, expected);
2712 var lines = msg.split('\n').splice(5);
2713 return (
2714 '\n ' +
2715 colorLines('diff added', '+ expected') +
2716 ' ' +
2717 colorLines('diff removed', '- actual') +
2718 '\n\n' +
2719 lines
2720 .map(cleanUp)
2721 .filter(notBlank)
2722 .join('\n')
2723 );
2724}
2725
2726/**
2727 * Returns character diff for `err`.
2728 *
2729 * @private
2730 * @param {String} actual
2731 * @param {String} expected
2732 * @return {string} the diff
2733 */
2734function errorDiff(actual, expected) {
2735 return diff
2736 .diffWordsWithSpace(actual, expected)
2737 .map(function(str) {
2738 if (str.added) {
2739 return colorLines('diff added', str.value);
2740 }
2741 if (str.removed) {
2742 return colorLines('diff removed', str.value);
2743 }
2744 return str.value;
2745 })
2746 .join('');
2747}
2748
2749/**
2750 * Colors lines for `str`, using the color `name`.
2751 *
2752 * @private
2753 * @param {string} name
2754 * @param {string} str
2755 * @return {string}
2756 */
2757function colorLines(name, str) {
2758 return str
2759 .split('\n')
2760 .map(function(str) {
2761 return color(name, str);
2762 })
2763 .join('\n');
2764}
2765
2766/**
2767 * Object#toString reference.
2768 */
2769var objToString = Object.prototype.toString;
2770
2771/**
2772 * Checks that a / b have the same type.
2773 *
2774 * @private
2775 * @param {Object} a
2776 * @param {Object} b
2777 * @return {boolean}
2778 */
2779function sameType(a, b) {
2780 return objToString.call(a) === objToString.call(b);
2781}
2782
2783Base.consoleLog = consoleLog;
2784
2785Base.abstract = true;
2786
2787}).call(this,require('_process'))
2788},{"../runner":34,"../utils":38,"_process":69,"diff":48,"ms":60,"supports-color":42,"tty":4}],18:[function(require,module,exports){
2789'use strict';
2790/**
2791 * @module Doc
2792 */
2793/**
2794 * Module dependencies.
2795 */
2796
2797var Base = require('./base');
2798var utils = require('../utils');
2799var constants = require('../runner').constants;
2800var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2801var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2802var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
2803var EVENT_SUITE_END = constants.EVENT_SUITE_END;
2804
2805/**
2806 * Expose `Doc`.
2807 */
2808
2809exports = module.exports = Doc;
2810
2811/**
2812 * Constructs a new `Doc` reporter instance.
2813 *
2814 * @public
2815 * @class
2816 * @memberof Mocha.reporters
2817 * @extends Mocha.reporters.Base
2818 * @param {Runner} runner - Instance triggers reporter actions.
2819 * @param {Object} [options] - runner options
2820 */
2821function Doc(runner, options) {
2822 Base.call(this, runner, options);
2823
2824 var indents = 2;
2825
2826 function indent() {
2827 return Array(indents).join(' ');
2828 }
2829
2830 runner.on(EVENT_SUITE_BEGIN, function(suite) {
2831 if (suite.root) {
2832 return;
2833 }
2834 ++indents;
2835 Base.consoleLog('%s<section class="suite">', indent());
2836 ++indents;
2837 Base.consoleLog('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
2838 Base.consoleLog('%s<dl>', indent());
2839 });
2840
2841 runner.on(EVENT_SUITE_END, function(suite) {
2842 if (suite.root) {
2843 return;
2844 }
2845 Base.consoleLog('%s</dl>', indent());
2846 --indents;
2847 Base.consoleLog('%s</section>', indent());
2848 --indents;
2849 });
2850
2851 runner.on(EVENT_TEST_PASS, function(test) {
2852 Base.consoleLog('%s <dt>%s</dt>', indent(), utils.escape(test.title));
2853 var code = utils.escape(utils.clean(test.body));
2854 Base.consoleLog('%s <dd><pre><code>%s</code></pre></dd>', indent(), code);
2855 });
2856
2857 runner.on(EVENT_TEST_FAIL, function(test, err) {
2858 Base.consoleLog(
2859 '%s <dt class="error">%s</dt>',
2860 indent(),
2861 utils.escape(test.title)
2862 );
2863 var code = utils.escape(utils.clean(test.body));
2864 Base.consoleLog(
2865 '%s <dd class="error"><pre><code>%s</code></pre></dd>',
2866 indent(),
2867 code
2868 );
2869 Base.consoleLog(
2870 '%s <dd class="error">%s</dd>',
2871 indent(),
2872 utils.escape(err)
2873 );
2874 });
2875}
2876
2877Doc.description = 'HTML documentation';
2878
2879},{"../runner":34,"../utils":38,"./base":17}],19:[function(require,module,exports){
2880(function (process){
2881'use strict';
2882/**
2883 * @module Dot
2884 */
2885/**
2886 * Module dependencies.
2887 */
2888
2889var Base = require('./base');
2890var inherits = require('../utils').inherits;
2891var constants = require('../runner').constants;
2892var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2893var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2894var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
2895var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
2896var EVENT_RUN_END = constants.EVENT_RUN_END;
2897
2898/**
2899 * Expose `Dot`.
2900 */
2901
2902exports = module.exports = Dot;
2903
2904/**
2905 * Constructs a new `Dot` reporter instance.
2906 *
2907 * @public
2908 * @class
2909 * @memberof Mocha.reporters
2910 * @extends Mocha.reporters.Base
2911 * @param {Runner} runner - Instance triggers reporter actions.
2912 * @param {Object} [options] - runner options
2913 */
2914function Dot(runner, options) {
2915 Base.call(this, runner, options);
2916
2917 var self = this;
2918 var width = (Base.window.width * 0.75) | 0;
2919 var n = -1;
2920
2921 runner.on(EVENT_RUN_BEGIN, function() {
2922 process.stdout.write('\n');
2923 });
2924
2925 runner.on(EVENT_TEST_PENDING, function() {
2926 if (++n % width === 0) {
2927 process.stdout.write('\n ');
2928 }
2929 process.stdout.write(Base.color('pending', Base.symbols.comma));
2930 });
2931
2932 runner.on(EVENT_TEST_PASS, function(test) {
2933 if (++n % width === 0) {
2934 process.stdout.write('\n ');
2935 }
2936 if (test.speed === 'slow') {
2937 process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
2938 } else {
2939 process.stdout.write(Base.color(test.speed, Base.symbols.dot));
2940 }
2941 });
2942
2943 runner.on(EVENT_TEST_FAIL, function() {
2944 if (++n % width === 0) {
2945 process.stdout.write('\n ');
2946 }
2947 process.stdout.write(Base.color('fail', Base.symbols.bang));
2948 });
2949
2950 runner.once(EVENT_RUN_END, function() {
2951 process.stdout.write('\n');
2952 self.epilogue();
2953 });
2954}
2955
2956/**
2957 * Inherit from `Base.prototype`.
2958 */
2959inherits(Dot, Base);
2960
2961Dot.description = 'dot matrix representation';
2962
2963}).call(this,require('_process'))
2964},{"../runner":34,"../utils":38,"./base":17,"_process":69}],20:[function(require,module,exports){
2965(function (global){
2966'use strict';
2967
2968/* eslint-env browser */
2969/**
2970 * @module HTML
2971 */
2972/**
2973 * Module dependencies.
2974 */
2975
2976var Base = require('./base');
2977var utils = require('../utils');
2978var Progress = require('../browser/progress');
2979var escapeRe = require('escape-string-regexp');
2980var constants = require('../runner').constants;
2981var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
2982var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
2983var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
2984var EVENT_SUITE_END = constants.EVENT_SUITE_END;
2985var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
2986var escape = utils.escape;
2987
2988/**
2989 * Save timer references to avoid Sinon interfering (see GH-237).
2990 */
2991
2992var Date = global.Date;
2993
2994/**
2995 * Expose `HTML`.
2996 */
2997
2998exports = module.exports = HTML;
2999
3000/**
3001 * Stats template.
3002 */
3003
3004var statsTemplate =
3005 '<ul id="mocha-stats">' +
3006 '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
3007 '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
3008 '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
3009 '<li class="duration">duration: <em>0</em>s</li>' +
3010 '</ul>';
3011
3012var playIcon = '&#x2023;';
3013
3014/**
3015 * Constructs a new `HTML` reporter instance.
3016 *
3017 * @public
3018 * @class
3019 * @memberof Mocha.reporters
3020 * @extends Mocha.reporters.Base
3021 * @param {Runner} runner - Instance triggers reporter actions.
3022 * @param {Object} [options] - runner options
3023 */
3024function HTML(runner, options) {
3025 Base.call(this, runner, options);
3026
3027 var self = this;
3028 var stats = this.stats;
3029 var stat = fragment(statsTemplate);
3030 var items = stat.getElementsByTagName('li');
3031 var passes = items[1].getElementsByTagName('em')[0];
3032 var passesLink = items[1].getElementsByTagName('a')[0];
3033 var failures = items[2].getElementsByTagName('em')[0];
3034 var failuresLink = items[2].getElementsByTagName('a')[0];
3035 var duration = items[3].getElementsByTagName('em')[0];
3036 var canvas = stat.getElementsByTagName('canvas')[0];
3037 var report = fragment('<ul id="mocha-report"></ul>');
3038 var stack = [report];
3039 var progress;
3040 var ctx;
3041 var root = document.getElementById('mocha');
3042
3043 if (canvas.getContext) {
3044 var ratio = window.devicePixelRatio || 1;
3045 canvas.style.width = canvas.width;
3046 canvas.style.height = canvas.height;
3047 canvas.width *= ratio;
3048 canvas.height *= ratio;
3049 ctx = canvas.getContext('2d');
3050 ctx.scale(ratio, ratio);
3051 progress = new Progress();
3052 }
3053
3054 if (!root) {
3055 return error('#mocha div missing, add it to your document');
3056 }
3057
3058 // pass toggle
3059 on(passesLink, 'click', function(evt) {
3060 evt.preventDefault();
3061 unhide();
3062 var name = /pass/.test(report.className) ? '' : ' pass';
3063 report.className = report.className.replace(/fail|pass/g, '') + name;
3064 if (report.className.trim()) {
3065 hideSuitesWithout('test pass');
3066 }
3067 });
3068
3069 // failure toggle
3070 on(failuresLink, 'click', function(evt) {
3071 evt.preventDefault();
3072 unhide();
3073 var name = /fail/.test(report.className) ? '' : ' fail';
3074 report.className = report.className.replace(/fail|pass/g, '') + name;
3075 if (report.className.trim()) {
3076 hideSuitesWithout('test fail');
3077 }
3078 });
3079
3080 root.appendChild(stat);
3081 root.appendChild(report);
3082
3083 if (progress) {
3084 progress.size(40);
3085 }
3086
3087 runner.on(EVENT_SUITE_BEGIN, function(suite) {
3088 if (suite.root) {
3089 return;
3090 }
3091
3092 // suite
3093 var url = self.suiteURL(suite);
3094 var el = fragment(
3095 '<li class="suite"><h1><a href="%s">%s</a></h1></li>',
3096 url,
3097 escape(suite.title)
3098 );
3099
3100 // container
3101 stack[0].appendChild(el);
3102 stack.unshift(document.createElement('ul'));
3103 el.appendChild(stack[0]);
3104 });
3105
3106 runner.on(EVENT_SUITE_END, function(suite) {
3107 if (suite.root) {
3108 updateStats();
3109 return;
3110 }
3111 stack.shift();
3112 });
3113
3114 runner.on(EVENT_TEST_PASS, function(test) {
3115 var url = self.testURL(test);
3116 var markup =
3117 '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
3118 '<a href="%s" class="replay">' +
3119 playIcon +
3120 '</a></h2></li>';
3121 var el = fragment(markup, test.speed, test.title, test.duration, url);
3122 self.addCodeToggle(el, test.body);
3123 appendToStack(el);
3124 updateStats();
3125 });
3126
3127 runner.on(EVENT_TEST_FAIL, function(test) {
3128 var el = fragment(
3129 '<li class="test fail"><h2>%e <a href="%e" class="replay">' +
3130 playIcon +
3131 '</a></h2></li>',
3132 test.title,
3133 self.testURL(test)
3134 );
3135 var stackString; // Note: Includes leading newline
3136 var message = test.err.toString();
3137
3138 // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
3139 // check for the result of the stringifying.
3140 if (message === '[object Error]') {
3141 message = test.err.message;
3142 }
3143
3144 if (test.err.stack) {
3145 var indexOfMessage = test.err.stack.indexOf(test.err.message);
3146 if (indexOfMessage === -1) {
3147 stackString = test.err.stack;
3148 } else {
3149 stackString = test.err.stack.substr(
3150 test.err.message.length + indexOfMessage
3151 );
3152 }
3153 } else if (test.err.sourceURL && test.err.line !== undefined) {
3154 // Safari doesn't give you a stack. Let's at least provide a source line.
3155 stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
3156 }
3157
3158 stackString = stackString || '';
3159
3160 if (test.err.htmlMessage && stackString) {
3161 el.appendChild(
3162 fragment(
3163 '<div class="html-error">%s\n<pre class="error">%e</pre></div>',
3164 test.err.htmlMessage,
3165 stackString
3166 )
3167 );
3168 } else if (test.err.htmlMessage) {
3169 el.appendChild(
3170 fragment('<div class="html-error">%s</div>', test.err.htmlMessage)
3171 );
3172 } else {
3173 el.appendChild(
3174 fragment('<pre class="error">%e%e</pre>', message, stackString)
3175 );
3176 }
3177
3178 self.addCodeToggle(el, test.body);
3179 appendToStack(el);
3180 updateStats();
3181 });
3182
3183 runner.on(EVENT_TEST_PENDING, function(test) {
3184 var el = fragment(
3185 '<li class="test pass pending"><h2>%e</h2></li>',
3186 test.title
3187 );
3188 appendToStack(el);
3189 updateStats();
3190 });
3191
3192 function appendToStack(el) {
3193 // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
3194 if (stack[0]) {
3195 stack[0].appendChild(el);
3196 }
3197 }
3198
3199 function updateStats() {
3200 // TODO: add to stats
3201 var percent = ((stats.tests / runner.total) * 100) | 0;
3202 if (progress) {
3203 progress.update(percent).draw(ctx);
3204 }
3205
3206 // update stats
3207 var ms = new Date() - stats.start;
3208 text(passes, stats.passes);
3209 text(failures, stats.failures);
3210 text(duration, (ms / 1000).toFixed(2));
3211 }
3212}
3213
3214/**
3215 * Makes a URL, preserving querystring ("search") parameters.
3216 *
3217 * @param {string} s
3218 * @return {string} A new URL.
3219 */
3220function makeUrl(s) {
3221 var search = window.location.search;
3222
3223 // Remove previous grep query parameter if present
3224 if (search) {
3225 search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
3226 }
3227
3228 return (
3229 window.location.pathname +
3230 (search ? search + '&' : '?') +
3231 'grep=' +
3232 encodeURIComponent(escapeRe(s))
3233 );
3234}
3235
3236/**
3237 * Provide suite URL.
3238 *
3239 * @param {Object} [suite]
3240 */
3241HTML.prototype.suiteURL = function(suite) {
3242 return makeUrl(suite.fullTitle());
3243};
3244
3245/**
3246 * Provide test URL.
3247 *
3248 * @param {Object} [test]
3249 */
3250HTML.prototype.testURL = function(test) {
3251 return makeUrl(test.fullTitle());
3252};
3253
3254/**
3255 * Adds code toggle functionality for the provided test's list element.
3256 *
3257 * @param {HTMLLIElement} el
3258 * @param {string} contents
3259 */
3260HTML.prototype.addCodeToggle = function(el, contents) {
3261 var h2 = el.getElementsByTagName('h2')[0];
3262
3263 on(h2, 'click', function() {
3264 pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
3265 });
3266
3267 var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents));
3268 el.appendChild(pre);
3269 pre.style.display = 'none';
3270};
3271
3272/**
3273 * Display error `msg`.
3274 *
3275 * @param {string} msg
3276 */
3277function error(msg) {
3278 document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
3279}
3280
3281/**
3282 * Return a DOM fragment from `html`.
3283 *
3284 * @param {string} html
3285 */
3286function fragment(html) {
3287 var args = arguments;
3288 var div = document.createElement('div');
3289 var i = 1;
3290
3291 div.innerHTML = html.replace(/%([se])/g, function(_, type) {
3292 switch (type) {
3293 case 's':
3294 return String(args[i++]);
3295 case 'e':
3296 return escape(args[i++]);
3297 // no default
3298 }
3299 });
3300
3301 return div.firstChild;
3302}
3303
3304/**
3305 * Check for suites that do not have elements
3306 * with `classname`, and hide them.
3307 *
3308 * @param {text} classname
3309 */
3310function hideSuitesWithout(classname) {
3311 var suites = document.getElementsByClassName('suite');
3312 for (var i = 0; i < suites.length; i++) {
3313 var els = suites[i].getElementsByClassName(classname);
3314 if (!els.length) {
3315 suites[i].className += ' hidden';
3316 }
3317 }
3318}
3319
3320/**
3321 * Unhide .hidden suites.
3322 */
3323function unhide() {
3324 var els = document.getElementsByClassName('suite hidden');
3325 while (els.length > 0) {
3326 els[0].className = els[0].className.replace('suite hidden', 'suite');
3327 }
3328}
3329
3330/**
3331 * Set an element's text contents.
3332 *
3333 * @param {HTMLElement} el
3334 * @param {string} contents
3335 */
3336function text(el, contents) {
3337 if (el.textContent) {
3338 el.textContent = contents;
3339 } else {
3340 el.innerText = contents;
3341 }
3342}
3343
3344/**
3345 * Listen on `event` with callback `fn`.
3346 */
3347function on(el, event, fn) {
3348 if (el.addEventListener) {
3349 el.addEventListener(event, fn, false);
3350 } else {
3351 el.attachEvent('on' + event, fn);
3352 }
3353}
3354
3355HTML.browserOnly = true;
3356
3357}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3358},{"../browser/progress":3,"../runner":34,"../utils":38,"./base":17,"escape-string-regexp":49}],21:[function(require,module,exports){
3359'use strict';
3360
3361// Alias exports to a their normalized format Mocha#reporter to prevent a need
3362// for dynamic (try/catch) requires, which Browserify doesn't handle.
3363exports.Base = exports.base = require('./base');
3364exports.Dot = exports.dot = require('./dot');
3365exports.Doc = exports.doc = require('./doc');
3366exports.TAP = exports.tap = require('./tap');
3367exports.JSON = exports.json = require('./json');
3368exports.HTML = exports.html = require('./html');
3369exports.List = exports.list = require('./list');
3370exports.Min = exports.min = require('./min');
3371exports.Spec = exports.spec = require('./spec');
3372exports.Nyan = exports.nyan = require('./nyan');
3373exports.XUnit = exports.xunit = require('./xunit');
3374exports.Markdown = exports.markdown = require('./markdown');
3375exports.Progress = exports.progress = require('./progress');
3376exports.Landing = exports.landing = require('./landing');
3377exports.JSONStream = exports['json-stream'] = require('./json-stream');
3378
3379},{"./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){
3380(function (process){
3381'use strict';
3382/**
3383 * @module JSONStream
3384 */
3385/**
3386 * Module dependencies.
3387 */
3388
3389var Base = require('./base');
3390var constants = require('../runner').constants;
3391var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3392var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3393var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3394var EVENT_RUN_END = constants.EVENT_RUN_END;
3395
3396/**
3397 * Expose `JSONStream`.
3398 */
3399
3400exports = module.exports = JSONStream;
3401
3402/**
3403 * Constructs a new `JSONStream` reporter instance.
3404 *
3405 * @public
3406 * @class
3407 * @memberof Mocha.reporters
3408 * @extends Mocha.reporters.Base
3409 * @param {Runner} runner - Instance triggers reporter actions.
3410 * @param {Object} [options] - runner options
3411 */
3412function JSONStream(runner, options) {
3413 Base.call(this, runner, options);
3414
3415 var self = this;
3416 var total = runner.total;
3417
3418 runner.once(EVENT_RUN_BEGIN, function() {
3419 writeEvent(['start', {total: total}]);
3420 });
3421
3422 runner.on(EVENT_TEST_PASS, function(test) {
3423 writeEvent(['pass', clean(test)]);
3424 });
3425
3426 runner.on(EVENT_TEST_FAIL, function(test, err) {
3427 test = clean(test);
3428 test.err = err.message;
3429 test.stack = err.stack || null;
3430 writeEvent(['fail', test]);
3431 });
3432
3433 runner.once(EVENT_RUN_END, function() {
3434 writeEvent(['end', self.stats]);
3435 });
3436}
3437
3438/**
3439 * Mocha event to be written to the output stream.
3440 * @typedef {Array} JSONStream~MochaEvent
3441 */
3442
3443/**
3444 * Writes Mocha event to reporter output stream.
3445 *
3446 * @private
3447 * @param {JSONStream~MochaEvent} event - Mocha event to be output.
3448 */
3449function writeEvent(event) {
3450 process.stdout.write(JSON.stringify(event) + '\n');
3451}
3452
3453/**
3454 * Returns an object literal representation of `test`
3455 * free of cyclic properties, etc.
3456 *
3457 * @private
3458 * @param {Test} test - Instance used as data source.
3459 * @return {Object} object containing pared-down test instance data
3460 */
3461function clean(test) {
3462 return {
3463 title: test.title,
3464 fullTitle: test.fullTitle(),
3465 duration: test.duration,
3466 currentRetry: test.currentRetry()
3467 };
3468}
3469
3470JSONStream.description = 'newline delimited JSON events';
3471
3472}).call(this,require('_process'))
3473},{"../runner":34,"./base":17,"_process":69}],23:[function(require,module,exports){
3474(function (process){
3475'use strict';
3476/**
3477 * @module JSON
3478 */
3479/**
3480 * Module dependencies.
3481 */
3482
3483var Base = require('./base');
3484var constants = require('../runner').constants;
3485var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3486var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3487var EVENT_TEST_END = constants.EVENT_TEST_END;
3488var EVENT_RUN_END = constants.EVENT_RUN_END;
3489var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3490
3491/**
3492 * Expose `JSON`.
3493 */
3494
3495exports = module.exports = JSONReporter;
3496
3497/**
3498 * Constructs a new `JSON` reporter instance.
3499 *
3500 * @public
3501 * @class JSON
3502 * @memberof Mocha.reporters
3503 * @extends Mocha.reporters.Base
3504 * @param {Runner} runner - Instance triggers reporter actions.
3505 * @param {Object} [options] - runner options
3506 */
3507function JSONReporter(runner, options) {
3508 Base.call(this, runner, options);
3509
3510 var self = this;
3511 var tests = [];
3512 var pending = [];
3513 var failures = [];
3514 var passes = [];
3515
3516 runner.on(EVENT_TEST_END, function(test) {
3517 tests.push(test);
3518 });
3519
3520 runner.on(EVENT_TEST_PASS, function(test) {
3521 passes.push(test);
3522 });
3523
3524 runner.on(EVENT_TEST_FAIL, function(test) {
3525 failures.push(test);
3526 });
3527
3528 runner.on(EVENT_TEST_PENDING, function(test) {
3529 pending.push(test);
3530 });
3531
3532 runner.once(EVENT_RUN_END, function() {
3533 var obj = {
3534 stats: self.stats,
3535 tests: tests.map(clean),
3536 pending: pending.map(clean),
3537 failures: failures.map(clean),
3538 passes: passes.map(clean)
3539 };
3540
3541 runner.testResults = obj;
3542
3543 process.stdout.write(JSON.stringify(obj, null, 2));
3544 });
3545}
3546
3547/**
3548 * Return a plain-object representation of `test`
3549 * free of cyclic properties etc.
3550 *
3551 * @private
3552 * @param {Object} test
3553 * @return {Object}
3554 */
3555function clean(test) {
3556 var err = test.err || {};
3557 if (err instanceof Error) {
3558 err = errorJSON(err);
3559 }
3560
3561 return {
3562 title: test.title,
3563 fullTitle: test.fullTitle(),
3564 duration: test.duration,
3565 currentRetry: test.currentRetry(),
3566 err: cleanCycles(err)
3567 };
3568}
3569
3570/**
3571 * Replaces any circular references inside `obj` with '[object Object]'
3572 *
3573 * @private
3574 * @param {Object} obj
3575 * @return {Object}
3576 */
3577function cleanCycles(obj) {
3578 var cache = [];
3579 return JSON.parse(
3580 JSON.stringify(obj, function(key, value) {
3581 if (typeof value === 'object' && value !== null) {
3582 if (cache.indexOf(value) !== -1) {
3583 // Instead of going in a circle, we'll print [object Object]
3584 return '' + value;
3585 }
3586 cache.push(value);
3587 }
3588
3589 return value;
3590 })
3591 );
3592}
3593
3594/**
3595 * Transform an Error object into a JSON object.
3596 *
3597 * @private
3598 * @param {Error} err
3599 * @return {Object}
3600 */
3601function errorJSON(err) {
3602 var res = {};
3603 Object.getOwnPropertyNames(err).forEach(function(key) {
3604 res[key] = err[key];
3605 }, err);
3606 return res;
3607}
3608
3609JSONReporter.description = 'single JSON object';
3610
3611}).call(this,require('_process'))
3612},{"../runner":34,"./base":17,"_process":69}],24:[function(require,module,exports){
3613(function (process){
3614'use strict';
3615/**
3616 * @module Landing
3617 */
3618/**
3619 * Module dependencies.
3620 */
3621
3622var Base = require('./base');
3623var inherits = require('../utils').inherits;
3624var constants = require('../runner').constants;
3625var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3626var EVENT_RUN_END = constants.EVENT_RUN_END;
3627var EVENT_TEST_END = constants.EVENT_TEST_END;
3628var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
3629
3630var cursor = Base.cursor;
3631var color = Base.color;
3632
3633/**
3634 * Expose `Landing`.
3635 */
3636
3637exports = module.exports = Landing;
3638
3639/**
3640 * Airplane color.
3641 */
3642
3643Base.colors.plane = 0;
3644
3645/**
3646 * Airplane crash color.
3647 */
3648
3649Base.colors['plane crash'] = 31;
3650
3651/**
3652 * Runway color.
3653 */
3654
3655Base.colors.runway = 90;
3656
3657/**
3658 * Constructs a new `Landing` reporter instance.
3659 *
3660 * @public
3661 * @class
3662 * @memberof Mocha.reporters
3663 * @extends Mocha.reporters.Base
3664 * @param {Runner} runner - Instance triggers reporter actions.
3665 * @param {Object} [options] - runner options
3666 */
3667function Landing(runner, options) {
3668 Base.call(this, runner, options);
3669
3670 var self = this;
3671 var width = (Base.window.width * 0.75) | 0;
3672 var total = runner.total;
3673 var stream = process.stdout;
3674 var plane = color('plane', '✈');
3675 var crashed = -1;
3676 var n = 0;
3677
3678 function runway() {
3679 var buf = Array(width).join('-');
3680 return ' ' + color('runway', buf);
3681 }
3682
3683 runner.on(EVENT_RUN_BEGIN, function() {
3684 stream.write('\n\n\n ');
3685 cursor.hide();
3686 });
3687
3688 runner.on(EVENT_TEST_END, function(test) {
3689 // check if the plane crashed
3690 var col = crashed === -1 ? ((width * ++n) / total) | 0 : crashed;
3691
3692 // show the crash
3693 if (test.state === STATE_FAILED) {
3694 plane = color('plane crash', '✈');
3695 crashed = col;
3696 }
3697
3698 // render landing strip
3699 stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
3700 stream.write(runway());
3701 stream.write('\n ');
3702 stream.write(color('runway', Array(col).join('⋅')));
3703 stream.write(plane);
3704 stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
3705 stream.write(runway());
3706 stream.write('\u001b[0m');
3707 });
3708
3709 runner.once(EVENT_RUN_END, function() {
3710 cursor.show();
3711 process.stdout.write('\n');
3712 self.epilogue();
3713 });
3714}
3715
3716/**
3717 * Inherit from `Base.prototype`.
3718 */
3719inherits(Landing, Base);
3720
3721Landing.description = 'Unicode landing strip';
3722
3723}).call(this,require('_process'))
3724},{"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69}],25:[function(require,module,exports){
3725(function (process){
3726'use strict';
3727/**
3728 * @module List
3729 */
3730/**
3731 * Module dependencies.
3732 */
3733
3734var Base = require('./base');
3735var inherits = require('../utils').inherits;
3736var constants = require('../runner').constants;
3737var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3738var EVENT_RUN_END = constants.EVENT_RUN_END;
3739var EVENT_TEST_BEGIN = constants.EVENT_TEST_BEGIN;
3740var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3741var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3742var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3743var color = Base.color;
3744var cursor = Base.cursor;
3745
3746/**
3747 * Expose `List`.
3748 */
3749
3750exports = module.exports = List;
3751
3752/**
3753 * Constructs a new `List` reporter instance.
3754 *
3755 * @public
3756 * @class
3757 * @memberof Mocha.reporters
3758 * @extends Mocha.reporters.Base
3759 * @param {Runner} runner - Instance triggers reporter actions.
3760 * @param {Object} [options] - runner options
3761 */
3762function List(runner, options) {
3763 Base.call(this, runner, options);
3764
3765 var self = this;
3766 var n = 0;
3767
3768 runner.on(EVENT_RUN_BEGIN, function() {
3769 Base.consoleLog();
3770 });
3771
3772 runner.on(EVENT_TEST_BEGIN, function(test) {
3773 process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
3774 });
3775
3776 runner.on(EVENT_TEST_PENDING, function(test) {
3777 var fmt = color('checkmark', ' -') + color('pending', ' %s');
3778 Base.consoleLog(fmt, test.fullTitle());
3779 });
3780
3781 runner.on(EVENT_TEST_PASS, function(test) {
3782 var fmt =
3783 color('checkmark', ' ' + Base.symbols.ok) +
3784 color('pass', ' %s: ') +
3785 color(test.speed, '%dms');
3786 cursor.CR();
3787 Base.consoleLog(fmt, test.fullTitle(), test.duration);
3788 });
3789
3790 runner.on(EVENT_TEST_FAIL, function(test) {
3791 cursor.CR();
3792 Base.consoleLog(color('fail', ' %d) %s'), ++n, test.fullTitle());
3793 });
3794
3795 runner.once(EVENT_RUN_END, self.epilogue.bind(self));
3796}
3797
3798/**
3799 * Inherit from `Base.prototype`.
3800 */
3801inherits(List, Base);
3802
3803List.description = 'like "spec" reporter but flat';
3804
3805}).call(this,require('_process'))
3806},{"../runner":34,"../utils":38,"./base":17,"_process":69}],26:[function(require,module,exports){
3807(function (process){
3808'use strict';
3809/**
3810 * @module Markdown
3811 */
3812/**
3813 * Module dependencies.
3814 */
3815
3816var Base = require('./base');
3817var utils = require('../utils');
3818var constants = require('../runner').constants;
3819var EVENT_RUN_END = constants.EVENT_RUN_END;
3820var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
3821var EVENT_SUITE_END = constants.EVENT_SUITE_END;
3822var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3823
3824/**
3825 * Constants
3826 */
3827
3828var SUITE_PREFIX = '$';
3829
3830/**
3831 * Expose `Markdown`.
3832 */
3833
3834exports = module.exports = Markdown;
3835
3836/**
3837 * Constructs a new `Markdown` reporter instance.
3838 *
3839 * @public
3840 * @class
3841 * @memberof Mocha.reporters
3842 * @extends Mocha.reporters.Base
3843 * @param {Runner} runner - Instance triggers reporter actions.
3844 * @param {Object} [options] - runner options
3845 */
3846function Markdown(runner, options) {
3847 Base.call(this, runner, options);
3848
3849 var level = 0;
3850 var buf = '';
3851
3852 function title(str) {
3853 return Array(level).join('#') + ' ' + str;
3854 }
3855
3856 function mapTOC(suite, obj) {
3857 var ret = obj;
3858 var key = SUITE_PREFIX + suite.title;
3859
3860 obj = obj[key] = obj[key] || {suite: suite};
3861 suite.suites.forEach(function(suite) {
3862 mapTOC(suite, obj);
3863 });
3864
3865 return ret;
3866 }
3867
3868 function stringifyTOC(obj, level) {
3869 ++level;
3870 var buf = '';
3871 var link;
3872 for (var key in obj) {
3873 if (key === 'suite') {
3874 continue;
3875 }
3876 if (key !== SUITE_PREFIX) {
3877 link = ' - [' + key.substring(1) + ']';
3878 link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
3879 buf += Array(level).join(' ') + link;
3880 }
3881 buf += stringifyTOC(obj[key], level);
3882 }
3883 return buf;
3884 }
3885
3886 function generateTOC(suite) {
3887 var obj = mapTOC(suite, {});
3888 return stringifyTOC(obj, 0);
3889 }
3890
3891 generateTOC(runner.suite);
3892
3893 runner.on(EVENT_SUITE_BEGIN, function(suite) {
3894 ++level;
3895 var slug = utils.slug(suite.fullTitle());
3896 buf += '<a name="' + slug + '"></a>' + '\n';
3897 buf += title(suite.title) + '\n';
3898 });
3899
3900 runner.on(EVENT_SUITE_END, function() {
3901 --level;
3902 });
3903
3904 runner.on(EVENT_TEST_PASS, function(test) {
3905 var code = utils.clean(test.body);
3906 buf += test.title + '.\n';
3907 buf += '\n```js\n';
3908 buf += code + '\n';
3909 buf += '```\n\n';
3910 });
3911
3912 runner.once(EVENT_RUN_END, function() {
3913 process.stdout.write('# TOC\n');
3914 process.stdout.write(generateTOC(runner.suite));
3915 process.stdout.write(buf);
3916 });
3917}
3918
3919Markdown.description = 'GitHub Flavored Markdown';
3920
3921}).call(this,require('_process'))
3922},{"../runner":34,"../utils":38,"./base":17,"_process":69}],27:[function(require,module,exports){
3923(function (process){
3924'use strict';
3925/**
3926 * @module Min
3927 */
3928/**
3929 * Module dependencies.
3930 */
3931
3932var Base = require('./base');
3933var inherits = require('../utils').inherits;
3934var constants = require('../runner').constants;
3935var EVENT_RUN_END = constants.EVENT_RUN_END;
3936var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3937
3938/**
3939 * Expose `Min`.
3940 */
3941
3942exports = module.exports = Min;
3943
3944/**
3945 * Constructs a new `Min` reporter instance.
3946 *
3947 * @description
3948 * This minimal test reporter is best used with '--watch'.
3949 *
3950 * @public
3951 * @class
3952 * @memberof Mocha.reporters
3953 * @extends Mocha.reporters.Base
3954 * @param {Runner} runner - Instance triggers reporter actions.
3955 * @param {Object} [options] - runner options
3956 */
3957function Min(runner, options) {
3958 Base.call(this, runner, options);
3959
3960 runner.on(EVENT_RUN_BEGIN, function() {
3961 // clear screen
3962 process.stdout.write('\u001b[2J');
3963 // set cursor position
3964 process.stdout.write('\u001b[1;3H');
3965 });
3966
3967 runner.once(EVENT_RUN_END, this.epilogue.bind(this));
3968}
3969
3970/**
3971 * Inherit from `Base.prototype`.
3972 */
3973inherits(Min, Base);
3974
3975Min.description = 'essentially just a summary';
3976
3977}).call(this,require('_process'))
3978},{"../runner":34,"../utils":38,"./base":17,"_process":69}],28:[function(require,module,exports){
3979(function (process){
3980'use strict';
3981/**
3982 * @module Nyan
3983 */
3984/**
3985 * Module dependencies.
3986 */
3987
3988var Base = require('./base');
3989var constants = require('../runner').constants;
3990var inherits = require('../utils').inherits;
3991var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
3992var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
3993var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
3994var EVENT_RUN_END = constants.EVENT_RUN_END;
3995var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
3996
3997/**
3998 * Expose `Dot`.
3999 */
4000
4001exports = module.exports = NyanCat;
4002
4003/**
4004 * Constructs a new `Nyan` reporter instance.
4005 *
4006 * @public
4007 * @class Nyan
4008 * @memberof Mocha.reporters
4009 * @extends Mocha.reporters.Base
4010 * @param {Runner} runner - Instance triggers reporter actions.
4011 * @param {Object} [options] - runner options
4012 */
4013function NyanCat(runner, options) {
4014 Base.call(this, runner, options);
4015
4016 var self = this;
4017 var width = (Base.window.width * 0.75) | 0;
4018 var nyanCatWidth = (this.nyanCatWidth = 11);
4019
4020 this.colorIndex = 0;
4021 this.numberOfLines = 4;
4022 this.rainbowColors = self.generateColors();
4023 this.scoreboardWidth = 5;
4024 this.tick = 0;
4025 this.trajectories = [[], [], [], []];
4026 this.trajectoryWidthMax = width - nyanCatWidth;
4027
4028 runner.on(EVENT_RUN_BEGIN, function() {
4029 Base.cursor.hide();
4030 self.draw();
4031 });
4032
4033 runner.on(EVENT_TEST_PENDING, function() {
4034 self.draw();
4035 });
4036
4037 runner.on(EVENT_TEST_PASS, function() {
4038 self.draw();
4039 });
4040
4041 runner.on(EVENT_TEST_FAIL, function() {
4042 self.draw();
4043 });
4044
4045 runner.once(EVENT_RUN_END, function() {
4046 Base.cursor.show();
4047 for (var i = 0; i < self.numberOfLines; i++) {
4048 write('\n');
4049 }
4050 self.epilogue();
4051 });
4052}
4053
4054/**
4055 * Inherit from `Base.prototype`.
4056 */
4057inherits(NyanCat, Base);
4058
4059/**
4060 * Draw the nyan cat
4061 *
4062 * @private
4063 */
4064
4065NyanCat.prototype.draw = function() {
4066 this.appendRainbow();
4067 this.drawScoreboard();
4068 this.drawRainbow();
4069 this.drawNyanCat();
4070 this.tick = !this.tick;
4071};
4072
4073/**
4074 * Draw the "scoreboard" showing the number
4075 * of passes, failures and pending tests.
4076 *
4077 * @private
4078 */
4079
4080NyanCat.prototype.drawScoreboard = function() {
4081 var stats = this.stats;
4082
4083 function draw(type, n) {
4084 write(' ');
4085 write(Base.color(type, n));
4086 write('\n');
4087 }
4088
4089 draw('green', stats.passes);
4090 draw('fail', stats.failures);
4091 draw('pending', stats.pending);
4092 write('\n');
4093
4094 this.cursorUp(this.numberOfLines);
4095};
4096
4097/**
4098 * Append the rainbow.
4099 *
4100 * @private
4101 */
4102
4103NyanCat.prototype.appendRainbow = function() {
4104 var segment = this.tick ? '_' : '-';
4105 var rainbowified = this.rainbowify(segment);
4106
4107 for (var index = 0; index < this.numberOfLines; index++) {
4108 var trajectory = this.trajectories[index];
4109 if (trajectory.length >= this.trajectoryWidthMax) {
4110 trajectory.shift();
4111 }
4112 trajectory.push(rainbowified);
4113 }
4114};
4115
4116/**
4117 * Draw the rainbow.
4118 *
4119 * @private
4120 */
4121
4122NyanCat.prototype.drawRainbow = function() {
4123 var self = this;
4124
4125 this.trajectories.forEach(function(line) {
4126 write('\u001b[' + self.scoreboardWidth + 'C');
4127 write(line.join(''));
4128 write('\n');
4129 });
4130
4131 this.cursorUp(this.numberOfLines);
4132};
4133
4134/**
4135 * Draw the nyan cat
4136 *
4137 * @private
4138 */
4139NyanCat.prototype.drawNyanCat = function() {
4140 var self = this;
4141 var startWidth = this.scoreboardWidth + this.trajectories[0].length;
4142 var dist = '\u001b[' + startWidth + 'C';
4143 var padding = '';
4144
4145 write(dist);
4146 write('_,------,');
4147 write('\n');
4148
4149 write(dist);
4150 padding = self.tick ? ' ' : ' ';
4151 write('_|' + padding + '/\\_/\\ ');
4152 write('\n');
4153
4154 write(dist);
4155 padding = self.tick ? '_' : '__';
4156 var tail = self.tick ? '~' : '^';
4157 write(tail + '|' + padding + this.face() + ' ');
4158 write('\n');
4159
4160 write(dist);
4161 padding = self.tick ? ' ' : ' ';
4162 write(padding + '"" "" ');
4163 write('\n');
4164
4165 this.cursorUp(this.numberOfLines);
4166};
4167
4168/**
4169 * Draw nyan cat face.
4170 *
4171 * @private
4172 * @return {string}
4173 */
4174
4175NyanCat.prototype.face = function() {
4176 var stats = this.stats;
4177 if (stats.failures) {
4178 return '( x .x)';
4179 } else if (stats.pending) {
4180 return '( o .o)';
4181 } else if (stats.passes) {
4182 return '( ^ .^)';
4183 }
4184 return '( - .-)';
4185};
4186
4187/**
4188 * Move cursor up `n`.
4189 *
4190 * @private
4191 * @param {number} n
4192 */
4193
4194NyanCat.prototype.cursorUp = function(n) {
4195 write('\u001b[' + n + 'A');
4196};
4197
4198/**
4199 * Move cursor down `n`.
4200 *
4201 * @private
4202 * @param {number} n
4203 */
4204
4205NyanCat.prototype.cursorDown = function(n) {
4206 write('\u001b[' + n + 'B');
4207};
4208
4209/**
4210 * Generate rainbow colors.
4211 *
4212 * @private
4213 * @return {Array}
4214 */
4215NyanCat.prototype.generateColors = function() {
4216 var colors = [];
4217
4218 for (var i = 0; i < 6 * 7; i++) {
4219 var pi3 = Math.floor(Math.PI / 3);
4220 var n = i * (1.0 / 6);
4221 var r = Math.floor(3 * Math.sin(n) + 3);
4222 var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
4223 var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
4224 colors.push(36 * r + 6 * g + b + 16);
4225 }
4226
4227 return colors;
4228};
4229
4230/**
4231 * Apply rainbow to the given `str`.
4232 *
4233 * @private
4234 * @param {string} str
4235 * @return {string}
4236 */
4237NyanCat.prototype.rainbowify = function(str) {
4238 if (!Base.useColors) {
4239 return str;
4240 }
4241 var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
4242 this.colorIndex += 1;
4243 return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
4244};
4245
4246/**
4247 * Stdout helper.
4248 *
4249 * @param {string} string A message to write to stdout.
4250 */
4251function write(string) {
4252 process.stdout.write(string);
4253}
4254
4255NyanCat.description = '"nyan cat"';
4256
4257}).call(this,require('_process'))
4258},{"../runner":34,"../utils":38,"./base":17,"_process":69}],29:[function(require,module,exports){
4259(function (process){
4260'use strict';
4261/**
4262 * @module Progress
4263 */
4264/**
4265 * Module dependencies.
4266 */
4267
4268var Base = require('./base');
4269var constants = require('../runner').constants;
4270var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4271var EVENT_TEST_END = constants.EVENT_TEST_END;
4272var EVENT_RUN_END = constants.EVENT_RUN_END;
4273var inherits = require('../utils').inherits;
4274var color = Base.color;
4275var cursor = Base.cursor;
4276
4277/**
4278 * Expose `Progress`.
4279 */
4280
4281exports = module.exports = Progress;
4282
4283/**
4284 * General progress bar color.
4285 */
4286
4287Base.colors.progress = 90;
4288
4289/**
4290 * Constructs a new `Progress` reporter instance.
4291 *
4292 * @public
4293 * @class
4294 * @memberof Mocha.reporters
4295 * @extends Mocha.reporters.Base
4296 * @param {Runner} runner - Instance triggers reporter actions.
4297 * @param {Object} [options] - runner options
4298 */
4299function Progress(runner, options) {
4300 Base.call(this, runner, options);
4301
4302 var self = this;
4303 var width = (Base.window.width * 0.5) | 0;
4304 var total = runner.total;
4305 var complete = 0;
4306 var lastN = -1;
4307
4308 // default chars
4309 options = options || {};
4310 var reporterOptions = options.reporterOptions || {};
4311
4312 options.open = reporterOptions.open || '[';
4313 options.complete = reporterOptions.complete || '▬';
4314 options.incomplete = reporterOptions.incomplete || Base.symbols.dot;
4315 options.close = reporterOptions.close || ']';
4316 options.verbose = reporterOptions.verbose || false;
4317
4318 // tests started
4319 runner.on(EVENT_RUN_BEGIN, function() {
4320 process.stdout.write('\n');
4321 cursor.hide();
4322 });
4323
4324 // tests complete
4325 runner.on(EVENT_TEST_END, function() {
4326 complete++;
4327
4328 var percent = complete / total;
4329 var n = (width * percent) | 0;
4330 var i = width - n;
4331
4332 if (n === lastN && !options.verbose) {
4333 // Don't re-render the line if it hasn't changed
4334 return;
4335 }
4336 lastN = n;
4337
4338 cursor.CR();
4339 process.stdout.write('\u001b[J');
4340 process.stdout.write(color('progress', ' ' + options.open));
4341 process.stdout.write(Array(n).join(options.complete));
4342 process.stdout.write(Array(i).join(options.incomplete));
4343 process.stdout.write(color('progress', options.close));
4344 if (options.verbose) {
4345 process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
4346 }
4347 });
4348
4349 // tests are complete, output some stats
4350 // and the failures if any
4351 runner.once(EVENT_RUN_END, function() {
4352 cursor.show();
4353 process.stdout.write('\n');
4354 self.epilogue();
4355 });
4356}
4357
4358/**
4359 * Inherit from `Base.prototype`.
4360 */
4361inherits(Progress, Base);
4362
4363Progress.description = 'a progress bar';
4364
4365}).call(this,require('_process'))
4366},{"../runner":34,"../utils":38,"./base":17,"_process":69}],30:[function(require,module,exports){
4367'use strict';
4368/**
4369 * @module Spec
4370 */
4371/**
4372 * Module dependencies.
4373 */
4374
4375var Base = require('./base');
4376var constants = require('../runner').constants;
4377var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4378var EVENT_RUN_END = constants.EVENT_RUN_END;
4379var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
4380var EVENT_SUITE_END = constants.EVENT_SUITE_END;
4381var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4382var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4383var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4384var inherits = require('../utils').inherits;
4385var color = Base.color;
4386
4387/**
4388 * Expose `Spec`.
4389 */
4390
4391exports = module.exports = Spec;
4392
4393/**
4394 * Constructs a new `Spec` reporter instance.
4395 *
4396 * @public
4397 * @class
4398 * @memberof Mocha.reporters
4399 * @extends Mocha.reporters.Base
4400 * @param {Runner} runner - Instance triggers reporter actions.
4401 * @param {Object} [options] - runner options
4402 */
4403function Spec(runner, options) {
4404 Base.call(this, runner, options);
4405
4406 var self = this;
4407 var indents = 0;
4408 var n = 0;
4409
4410 function indent() {
4411 return Array(indents).join(' ');
4412 }
4413
4414 runner.on(EVENT_RUN_BEGIN, function() {
4415 Base.consoleLog();
4416 });
4417
4418 runner.on(EVENT_SUITE_BEGIN, function(suite) {
4419 ++indents;
4420 Base.consoleLog(color('suite', '%s%s'), indent(), suite.title);
4421 });
4422
4423 runner.on(EVENT_SUITE_END, function() {
4424 --indents;
4425 if (indents === 1) {
4426 Base.consoleLog();
4427 }
4428 });
4429
4430 runner.on(EVENT_TEST_PENDING, function(test) {
4431 var fmt = indent() + color('pending', ' - %s');
4432 Base.consoleLog(fmt, test.title);
4433 });
4434
4435 runner.on(EVENT_TEST_PASS, function(test) {
4436 var fmt;
4437 if (test.speed === 'fast') {
4438 fmt =
4439 indent() +
4440 color('checkmark', ' ' + Base.symbols.ok) +
4441 color('pass', ' %s');
4442 Base.consoleLog(fmt, test.title);
4443 } else {
4444 fmt =
4445 indent() +
4446 color('checkmark', ' ' + Base.symbols.ok) +
4447 color('pass', ' %s') +
4448 color(test.speed, ' (%dms)');
4449 Base.consoleLog(fmt, test.title, test.duration);
4450 }
4451 });
4452
4453 runner.on(EVENT_TEST_FAIL, function(test) {
4454 Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title);
4455 });
4456
4457 runner.once(EVENT_RUN_END, self.epilogue.bind(self));
4458}
4459
4460/**
4461 * Inherit from `Base.prototype`.
4462 */
4463inherits(Spec, Base);
4464
4465Spec.description = 'hierarchical & verbose [default]';
4466
4467},{"../runner":34,"../utils":38,"./base":17}],31:[function(require,module,exports){
4468(function (process){
4469'use strict';
4470/**
4471 * @module TAP
4472 */
4473/**
4474 * Module dependencies.
4475 */
4476
4477var util = require('util');
4478var Base = require('./base');
4479var constants = require('../runner').constants;
4480var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4481var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4482var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
4483var EVENT_RUN_END = constants.EVENT_RUN_END;
4484var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4485var EVENT_TEST_END = constants.EVENT_TEST_END;
4486var inherits = require('../utils').inherits;
4487var sprintf = util.format;
4488
4489/**
4490 * Expose `TAP`.
4491 */
4492
4493exports = module.exports = TAP;
4494
4495/**
4496 * Constructs a new `TAP` reporter instance.
4497 *
4498 * @public
4499 * @class
4500 * @memberof Mocha.reporters
4501 * @extends Mocha.reporters.Base
4502 * @param {Runner} runner - Instance triggers reporter actions.
4503 * @param {Object} [options] - runner options
4504 */
4505function TAP(runner, options) {
4506 Base.call(this, runner, options);
4507
4508 var self = this;
4509 var n = 1;
4510
4511 var tapVersion = '12';
4512 if (options && options.reporterOptions) {
4513 if (options.reporterOptions.tapVersion) {
4514 tapVersion = options.reporterOptions.tapVersion.toString();
4515 }
4516 }
4517
4518 this._producer = createProducer(tapVersion);
4519
4520 runner.once(EVENT_RUN_BEGIN, function() {
4521 var ntests = runner.grepTotal(runner.suite);
4522 self._producer.writeVersion();
4523 self._producer.writePlan(ntests);
4524 });
4525
4526 runner.on(EVENT_TEST_END, function() {
4527 ++n;
4528 });
4529
4530 runner.on(EVENT_TEST_PENDING, function(test) {
4531 self._producer.writePending(n, test);
4532 });
4533
4534 runner.on(EVENT_TEST_PASS, function(test) {
4535 self._producer.writePass(n, test);
4536 });
4537
4538 runner.on(EVENT_TEST_FAIL, function(test, err) {
4539 self._producer.writeFail(n, test, err);
4540 });
4541
4542 runner.once(EVENT_RUN_END, function() {
4543 self._producer.writeEpilogue(runner.stats);
4544 });
4545}
4546
4547/**
4548 * Inherit from `Base.prototype`.
4549 */
4550inherits(TAP, Base);
4551
4552/**
4553 * Returns a TAP-safe title of `test`.
4554 *
4555 * @private
4556 * @param {Test} test - Test instance.
4557 * @return {String} title with any hash character removed
4558 */
4559function title(test) {
4560 return test.fullTitle().replace(/#/g, '');
4561}
4562
4563/**
4564 * Writes newline-terminated formatted string to reporter output stream.
4565 *
4566 * @private
4567 * @param {string} format - `printf`-like format string
4568 * @param {...*} [varArgs] - Format string arguments
4569 */
4570function println(format, varArgs) {
4571 var vargs = Array.from(arguments);
4572 vargs[0] += '\n';
4573 process.stdout.write(sprintf.apply(null, vargs));
4574}
4575
4576/**
4577 * Returns a `tapVersion`-appropriate TAP producer instance, if possible.
4578 *
4579 * @private
4580 * @param {string} tapVersion - Version of TAP specification to produce.
4581 * @returns {TAPProducer} specification-appropriate instance
4582 * @throws {Error} if specification version has no associated producer.
4583 */
4584function createProducer(tapVersion) {
4585 var producers = {
4586 '12': new TAP12Producer(),
4587 '13': new TAP13Producer()
4588 };
4589 var producer = producers[tapVersion];
4590
4591 if (!producer) {
4592 throw new Error(
4593 'invalid or unsupported TAP version: ' + JSON.stringify(tapVersion)
4594 );
4595 }
4596
4597 return producer;
4598}
4599
4600/**
4601 * @summary
4602 * Constructs a new TAPProducer.
4603 *
4604 * @description
4605 * <em>Only</em> to be used as an abstract base class.
4606 *
4607 * @private
4608 * @constructor
4609 */
4610function TAPProducer() {}
4611
4612/**
4613 * Writes the TAP version to reporter output stream.
4614 *
4615 * @abstract
4616 */
4617TAPProducer.prototype.writeVersion = function() {};
4618
4619/**
4620 * Writes the plan to reporter output stream.
4621 *
4622 * @abstract
4623 * @param {number} ntests - Number of tests that are planned to run.
4624 */
4625TAPProducer.prototype.writePlan = function(ntests) {
4626 println('%d..%d', 1, ntests);
4627};
4628
4629/**
4630 * Writes that test passed to reporter output stream.
4631 *
4632 * @abstract
4633 * @param {number} n - Index of test that passed.
4634 * @param {Test} test - Instance containing test information.
4635 */
4636TAPProducer.prototype.writePass = function(n, test) {
4637 println('ok %d %s', n, title(test));
4638};
4639
4640/**
4641 * Writes that test was skipped to reporter output stream.
4642 *
4643 * @abstract
4644 * @param {number} n - Index of test that was skipped.
4645 * @param {Test} test - Instance containing test information.
4646 */
4647TAPProducer.prototype.writePending = function(n, test) {
4648 println('ok %d %s # SKIP -', n, title(test));
4649};
4650
4651/**
4652 * Writes that test failed to reporter output stream.
4653 *
4654 * @abstract
4655 * @param {number} n - Index of test that failed.
4656 * @param {Test} test - Instance containing test information.
4657 * @param {Error} err - Reason the test failed.
4658 */
4659TAPProducer.prototype.writeFail = function(n, test, err) {
4660 println('not ok %d %s', n, title(test));
4661};
4662
4663/**
4664 * Writes the summary epilogue to reporter output stream.
4665 *
4666 * @abstract
4667 * @param {Object} stats - Object containing run statistics.
4668 */
4669TAPProducer.prototype.writeEpilogue = function(stats) {
4670 // :TBD: Why is this not counting pending tests?
4671 println('# tests ' + (stats.passes + stats.failures));
4672 println('# pass ' + stats.passes);
4673 // :TBD: Why are we not showing pending results?
4674 println('# fail ' + stats.failures);
4675};
4676
4677/**
4678 * @summary
4679 * Constructs a new TAP12Producer.
4680 *
4681 * @description
4682 * Produces output conforming to the TAP12 specification.
4683 *
4684 * @private
4685 * @constructor
4686 * @extends TAPProducer
4687 * @see {@link https://testanything.org/tap-specification.html|Specification}
4688 */
4689function TAP12Producer() {
4690 /**
4691 * Writes that test failed to reporter output stream, with error formatting.
4692 * @override
4693 */
4694 this.writeFail = function(n, test, err) {
4695 TAPProducer.prototype.writeFail.call(this, n, test, err);
4696 if (err.message) {
4697 println(err.message.replace(/^/gm, ' '));
4698 }
4699 if (err.stack) {
4700 println(err.stack.replace(/^/gm, ' '));
4701 }
4702 };
4703}
4704
4705/**
4706 * Inherit from `TAPProducer.prototype`.
4707 */
4708inherits(TAP12Producer, TAPProducer);
4709
4710/**
4711 * @summary
4712 * Constructs a new TAP13Producer.
4713 *
4714 * @description
4715 * Produces output conforming to the TAP13 specification.
4716 *
4717 * @private
4718 * @constructor
4719 * @extends TAPProducer
4720 * @see {@link https://testanything.org/tap-version-13-specification.html|Specification}
4721 */
4722function TAP13Producer() {
4723 /**
4724 * Writes the TAP version to reporter output stream.
4725 * @override
4726 */
4727 this.writeVersion = function() {
4728 println('TAP version 13');
4729 };
4730
4731 /**
4732 * Writes that test failed to reporter output stream, with error formatting.
4733 * @override
4734 */
4735 this.writeFail = function(n, test, err) {
4736 TAPProducer.prototype.writeFail.call(this, n, test, err);
4737 var emitYamlBlock = err.message != null || err.stack != null;
4738 if (emitYamlBlock) {
4739 println(indent(1) + '---');
4740 if (err.message) {
4741 println(indent(2) + 'message: |-');
4742 println(err.message.replace(/^/gm, indent(3)));
4743 }
4744 if (err.stack) {
4745 println(indent(2) + 'stack: |-');
4746 println(err.stack.replace(/^/gm, indent(3)));
4747 }
4748 println(indent(1) + '...');
4749 }
4750 };
4751
4752 function indent(level) {
4753 return Array(level + 1).join(' ');
4754 }
4755}
4756
4757/**
4758 * Inherit from `TAPProducer.prototype`.
4759 */
4760inherits(TAP13Producer, TAPProducer);
4761
4762TAP.description = 'TAP-compatible output';
4763
4764}).call(this,require('_process'))
4765},{"../runner":34,"../utils":38,"./base":17,"_process":69,"util":89}],32:[function(require,module,exports){
4766(function (process,global){
4767'use strict';
4768/**
4769 * @module XUnit
4770 */
4771/**
4772 * Module dependencies.
4773 */
4774
4775var Base = require('./base');
4776var utils = require('../utils');
4777var fs = require('fs');
4778var mkdirp = require('mkdirp');
4779var path = require('path');
4780var errors = require('../errors');
4781var createUnsupportedError = errors.createUnsupportedError;
4782var constants = require('../runner').constants;
4783var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
4784var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
4785var EVENT_RUN_END = constants.EVENT_RUN_END;
4786var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
4787var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
4788var inherits = utils.inherits;
4789var escape = utils.escape;
4790
4791/**
4792 * Save timer references to avoid Sinon interfering (see GH-237).
4793 */
4794var Date = global.Date;
4795
4796/**
4797 * Expose `XUnit`.
4798 */
4799
4800exports = module.exports = XUnit;
4801
4802/**
4803 * Constructs a new `XUnit` reporter instance.
4804 *
4805 * @public
4806 * @class
4807 * @memberof Mocha.reporters
4808 * @extends Mocha.reporters.Base
4809 * @param {Runner} runner - Instance triggers reporter actions.
4810 * @param {Object} [options] - runner options
4811 */
4812function XUnit(runner, options) {
4813 Base.call(this, runner, options);
4814
4815 var stats = this.stats;
4816 var tests = [];
4817 var self = this;
4818
4819 // the name of the test suite, as it will appear in the resulting XML file
4820 var suiteName;
4821
4822 // the default name of the test suite if none is provided
4823 var DEFAULT_SUITE_NAME = 'Mocha Tests';
4824
4825 if (options && options.reporterOptions) {
4826 if (options.reporterOptions.output) {
4827 if (!fs.createWriteStream) {
4828 throw createUnsupportedError('file output not supported in browser');
4829 }
4830
4831 mkdirp.sync(path.dirname(options.reporterOptions.output));
4832 self.fileStream = fs.createWriteStream(options.reporterOptions.output);
4833 }
4834
4835 // get the suite name from the reporter options (if provided)
4836 suiteName = options.reporterOptions.suiteName;
4837 }
4838
4839 // fall back to the default suite name
4840 suiteName = suiteName || DEFAULT_SUITE_NAME;
4841
4842 runner.on(EVENT_TEST_PENDING, function(test) {
4843 tests.push(test);
4844 });
4845
4846 runner.on(EVENT_TEST_PASS, function(test) {
4847 tests.push(test);
4848 });
4849
4850 runner.on(EVENT_TEST_FAIL, function(test) {
4851 tests.push(test);
4852 });
4853
4854 runner.once(EVENT_RUN_END, function() {
4855 self.write(
4856 tag(
4857 'testsuite',
4858 {
4859 name: suiteName,
4860 tests: stats.tests,
4861 failures: 0,
4862 errors: stats.failures,
4863 skipped: stats.tests - stats.failures - stats.passes,
4864 timestamp: new Date().toUTCString(),
4865 time: stats.duration / 1000 || 0
4866 },
4867 false
4868 )
4869 );
4870
4871 tests.forEach(function(t) {
4872 self.test(t);
4873 });
4874
4875 self.write('</testsuite>');
4876 });
4877}
4878
4879/**
4880 * Inherit from `Base.prototype`.
4881 */
4882inherits(XUnit, Base);
4883
4884/**
4885 * Override done to close the stream (if it's a file).
4886 *
4887 * @param failures
4888 * @param {Function} fn
4889 */
4890XUnit.prototype.done = function(failures, fn) {
4891 if (this.fileStream) {
4892 this.fileStream.end(function() {
4893 fn(failures);
4894 });
4895 } else {
4896 fn(failures);
4897 }
4898};
4899
4900/**
4901 * Write out the given line.
4902 *
4903 * @param {string} line
4904 */
4905XUnit.prototype.write = function(line) {
4906 if (this.fileStream) {
4907 this.fileStream.write(line + '\n');
4908 } else if (typeof process === 'object' && process.stdout) {
4909 process.stdout.write(line + '\n');
4910 } else {
4911 Base.consoleLog(line);
4912 }
4913};
4914
4915/**
4916 * Output tag for the given `test.`
4917 *
4918 * @param {Test} test
4919 */
4920XUnit.prototype.test = function(test) {
4921 Base.useColors = false;
4922
4923 var attrs = {
4924 classname: test.parent.fullTitle(),
4925 name: test.title,
4926 time: test.duration / 1000 || 0
4927 };
4928
4929 if (test.state === STATE_FAILED) {
4930 var err = test.err;
4931 var diff =
4932 Base.hideDiff || !err.actual || !err.expected
4933 ? ''
4934 : '\n' + Base.generateDiff(err.actual, err.expected);
4935 this.write(
4936 tag(
4937 'testcase',
4938 attrs,
4939 false,
4940 tag(
4941 'failure',
4942 {},
4943 false,
4944 escape(err.message) + escape(diff) + '\n' + escape(err.stack)
4945 )
4946 )
4947 );
4948 } else if (test.isPending()) {
4949 this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
4950 } else {
4951 this.write(tag('testcase', attrs, true));
4952 }
4953};
4954
4955/**
4956 * HTML tag helper.
4957 *
4958 * @param name
4959 * @param attrs
4960 * @param close
4961 * @param content
4962 * @return {string}
4963 */
4964function tag(name, attrs, close, content) {
4965 var end = close ? '/>' : '>';
4966 var pairs = [];
4967 var tag;
4968
4969 for (var key in attrs) {
4970 if (Object.prototype.hasOwnProperty.call(attrs, key)) {
4971 pairs.push(key + '="' + escape(attrs[key]) + '"');
4972 }
4973 }
4974
4975 tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
4976 if (content) {
4977 tag += content + '</' + name + end;
4978 }
4979 return tag;
4980}
4981
4982XUnit.description = 'XUnit-compatible XML output';
4983
4984}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4985},{"../errors":6,"../runnable":33,"../runner":34,"../utils":38,"./base":17,"_process":69,"fs":42,"mkdirp":59,"path":42}],33:[function(require,module,exports){
4986(function (global){
4987'use strict';
4988
4989var EventEmitter = require('events').EventEmitter;
4990var Pending = require('./pending');
4991var debug = require('debug')('mocha:runnable');
4992var milliseconds = require('ms');
4993var utils = require('./utils');
4994var createInvalidExceptionError = require('./errors')
4995 .createInvalidExceptionError;
4996
4997/**
4998 * Save timer references to avoid Sinon interfering (see GH-237).
4999 */
5000var Date = global.Date;
5001var setTimeout = global.setTimeout;
5002var clearTimeout = global.clearTimeout;
5003var toString = Object.prototype.toString;
5004
5005module.exports = Runnable;
5006
5007/**
5008 * Initialize a new `Runnable` with the given `title` and callback `fn`.
5009 *
5010 * @class
5011 * @extends external:EventEmitter
5012 * @public
5013 * @param {String} title
5014 * @param {Function} fn
5015 */
5016function Runnable(title, fn) {
5017 this.title = title;
5018 this.fn = fn;
5019 this.body = (fn || '').toString();
5020 this.async = fn && fn.length;
5021 this.sync = !this.async;
5022 this._timeout = 2000;
5023 this._slow = 75;
5024 this._enableTimeouts = true;
5025 this.timedOut = false;
5026 this._retries = -1;
5027 this._currentRetry = 0;
5028 this.pending = false;
5029}
5030
5031/**
5032 * Inherit from `EventEmitter.prototype`.
5033 */
5034utils.inherits(Runnable, EventEmitter);
5035
5036/**
5037 * Get current timeout value in msecs.
5038 *
5039 * @private
5040 * @returns {number} current timeout threshold value
5041 */
5042/**
5043 * @summary
5044 * Set timeout threshold value (msecs).
5045 *
5046 * @description
5047 * A string argument can use shorthand (e.g., "2s") and will be converted.
5048 * The value will be clamped to range [<code>0</code>, <code>2^<sup>31</sup>-1</code>].
5049 * If clamped value matches either range endpoint, timeouts will be disabled.
5050 *
5051 * @private
5052 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout#Maximum_delay_value}
5053 * @param {number|string} ms - Timeout threshold value.
5054 * @returns {Runnable} this
5055 * @chainable
5056 */
5057Runnable.prototype.timeout = function(ms) {
5058 if (!arguments.length) {
5059 return this._timeout;
5060 }
5061 if (typeof ms === 'string') {
5062 ms = milliseconds(ms);
5063 }
5064
5065 // Clamp to range
5066 var INT_MAX = Math.pow(2, 31) - 1;
5067 var range = [0, INT_MAX];
5068 ms = utils.clamp(ms, range);
5069
5070 // see #1652 for reasoning
5071 if (ms === range[0] || ms === range[1]) {
5072 this._enableTimeouts = false;
5073 }
5074 debug('timeout %d', ms);
5075 this._timeout = ms;
5076 if (this.timer) {
5077 this.resetTimeout();
5078 }
5079 return this;
5080};
5081
5082/**
5083 * Set or get slow `ms`.
5084 *
5085 * @private
5086 * @param {number|string} ms
5087 * @return {Runnable|number} ms or Runnable instance.
5088 */
5089Runnable.prototype.slow = function(ms) {
5090 if (!arguments.length || typeof ms === 'undefined') {
5091 return this._slow;
5092 }
5093 if (typeof ms === 'string') {
5094 ms = milliseconds(ms);
5095 }
5096 debug('slow %d', ms);
5097 this._slow = ms;
5098 return this;
5099};
5100
5101/**
5102 * Set and get whether timeout is `enabled`.
5103 *
5104 * @private
5105 * @param {boolean} enabled
5106 * @return {Runnable|boolean} enabled or Runnable instance.
5107 */
5108Runnable.prototype.enableTimeouts = function(enabled) {
5109 if (!arguments.length) {
5110 return this._enableTimeouts;
5111 }
5112 debug('enableTimeouts %s', enabled);
5113 this._enableTimeouts = enabled;
5114 return this;
5115};
5116
5117/**
5118 * Halt and mark as pending.
5119 *
5120 * @memberof Mocha.Runnable
5121 * @public
5122 */
5123Runnable.prototype.skip = function() {
5124 throw new Pending('sync skip');
5125};
5126
5127/**
5128 * Check if this runnable or its parent suite is marked as pending.
5129 *
5130 * @private
5131 */
5132Runnable.prototype.isPending = function() {
5133 return this.pending || (this.parent && this.parent.isPending());
5134};
5135
5136/**
5137 * Return `true` if this Runnable has failed.
5138 * @return {boolean}
5139 * @private
5140 */
5141Runnable.prototype.isFailed = function() {
5142 return !this.isPending() && this.state === constants.STATE_FAILED;
5143};
5144
5145/**
5146 * Return `true` if this Runnable has passed.
5147 * @return {boolean}
5148 * @private
5149 */
5150Runnable.prototype.isPassed = function() {
5151 return !this.isPending() && this.state === constants.STATE_PASSED;
5152};
5153
5154/**
5155 * Set or get number of retries.
5156 *
5157 * @private
5158 */
5159Runnable.prototype.retries = function(n) {
5160 if (!arguments.length) {
5161 return this._retries;
5162 }
5163 this._retries = n;
5164};
5165
5166/**
5167 * Set or get current retry
5168 *
5169 * @private
5170 */
5171Runnable.prototype.currentRetry = function(n) {
5172 if (!arguments.length) {
5173 return this._currentRetry;
5174 }
5175 this._currentRetry = n;
5176};
5177
5178/**
5179 * Return the full title generated by recursively concatenating the parent's
5180 * full title.
5181 *
5182 * @memberof Mocha.Runnable
5183 * @public
5184 * @return {string}
5185 */
5186Runnable.prototype.fullTitle = function() {
5187 return this.titlePath().join(' ');
5188};
5189
5190/**
5191 * Return the title path generated by concatenating the parent's title path with the title.
5192 *
5193 * @memberof Mocha.Runnable
5194 * @public
5195 * @return {string}
5196 */
5197Runnable.prototype.titlePath = function() {
5198 return this.parent.titlePath().concat([this.title]);
5199};
5200
5201/**
5202 * Clear the timeout.
5203 *
5204 * @private
5205 */
5206Runnable.prototype.clearTimeout = function() {
5207 clearTimeout(this.timer);
5208};
5209
5210/**
5211 * Inspect the runnable void of private properties.
5212 *
5213 * @private
5214 * @return {string}
5215 */
5216Runnable.prototype.inspect = function() {
5217 return JSON.stringify(
5218 this,
5219 function(key, val) {
5220 if (key[0] === '_') {
5221 return;
5222 }
5223 if (key === 'parent') {
5224 return '#<Suite>';
5225 }
5226 if (key === 'ctx') {
5227 return '#<Context>';
5228 }
5229 return val;
5230 },
5231 2
5232 );
5233};
5234
5235/**
5236 * Reset the timeout.
5237 *
5238 * @private
5239 */
5240Runnable.prototype.resetTimeout = function() {
5241 var self = this;
5242 var ms = this.timeout() || 1e9;
5243
5244 if (!this._enableTimeouts) {
5245 return;
5246 }
5247 this.clearTimeout();
5248 this.timer = setTimeout(function() {
5249 if (!self._enableTimeouts) {
5250 return;
5251 }
5252 self.callback(self._timeoutError(ms));
5253 self.timedOut = true;
5254 }, ms);
5255};
5256
5257/**
5258 * Set or get a list of whitelisted globals for this test run.
5259 *
5260 * @private
5261 * @param {string[]} globals
5262 */
5263Runnable.prototype.globals = function(globals) {
5264 if (!arguments.length) {
5265 return this._allowedGlobals;
5266 }
5267 this._allowedGlobals = globals;
5268};
5269
5270/**
5271 * Run the test and invoke `fn(err)`.
5272 *
5273 * @param {Function} fn
5274 * @private
5275 */
5276Runnable.prototype.run = function(fn) {
5277 var self = this;
5278 var start = new Date();
5279 var ctx = this.ctx;
5280 var finished;
5281 var emitted;
5282
5283 // Sometimes the ctx exists, but it is not runnable
5284 if (ctx && ctx.runnable) {
5285 ctx.runnable(this);
5286 }
5287
5288 // called multiple times
5289 function multiple(err) {
5290 if (emitted) {
5291 return;
5292 }
5293 emitted = true;
5294 var msg = 'done() called multiple times';
5295 if (err && err.message) {
5296 err.message += " (and Mocha's " + msg + ')';
5297 self.emit('error', err);
5298 } else {
5299 self.emit('error', new Error(msg));
5300 }
5301 }
5302
5303 // finished
5304 function done(err) {
5305 var ms = self.timeout();
5306 if (self.timedOut) {
5307 return;
5308 }
5309
5310 if (finished) {
5311 return multiple(err);
5312 }
5313
5314 self.clearTimeout();
5315 self.duration = new Date() - start;
5316 finished = true;
5317 if (!err && self.duration > ms && self._enableTimeouts) {
5318 err = self._timeoutError(ms);
5319 }
5320 fn(err);
5321 }
5322
5323 // for .resetTimeout()
5324 this.callback = done;
5325
5326 // explicit async with `done` argument
5327 if (this.async) {
5328 this.resetTimeout();
5329
5330 // allows skip() to be used in an explicit async context
5331 this.skip = function asyncSkip() {
5332 done(new Pending('async skip call'));
5333 // halt execution. the Runnable will be marked pending
5334 // by the previous call, and the uncaught handler will ignore
5335 // the failure.
5336 throw new Pending('async skip; aborting execution');
5337 };
5338
5339 if (this.allowUncaught) {
5340 return callFnAsync(this.fn);
5341 }
5342 try {
5343 callFnAsync(this.fn);
5344 } catch (err) {
5345 emitted = true;
5346 done(Runnable.toValueOrError(err));
5347 }
5348 return;
5349 }
5350
5351 if (this.allowUncaught) {
5352 if (this.isPending()) {
5353 done();
5354 } else {
5355 callFn(this.fn);
5356 }
5357 return;
5358 }
5359
5360 // sync or promise-returning
5361 try {
5362 if (this.isPending()) {
5363 done();
5364 } else {
5365 callFn(this.fn);
5366 }
5367 } catch (err) {
5368 emitted = true;
5369 done(Runnable.toValueOrError(err));
5370 }
5371
5372 function callFn(fn) {
5373 var result = fn.call(ctx);
5374 if (result && typeof result.then === 'function') {
5375 self.resetTimeout();
5376 result.then(
5377 function() {
5378 done();
5379 // Return null so libraries like bluebird do not warn about
5380 // subsequently constructed Promises.
5381 return null;
5382 },
5383 function(reason) {
5384 done(reason || new Error('Promise rejected with no or falsy reason'));
5385 }
5386 );
5387 } else {
5388 if (self.asyncOnly) {
5389 return done(
5390 new Error(
5391 '--async-only option in use without declaring `done()` or returning a promise'
5392 )
5393 );
5394 }
5395
5396 done();
5397 }
5398 }
5399
5400 function callFnAsync(fn) {
5401 var result = fn.call(ctx, function(err) {
5402 if (err instanceof Error || toString.call(err) === '[object Error]') {
5403 return done(err);
5404 }
5405 if (err) {
5406 if (Object.prototype.toString.call(err) === '[object Object]') {
5407 return done(
5408 new Error('done() invoked with non-Error: ' + JSON.stringify(err))
5409 );
5410 }
5411 return done(new Error('done() invoked with non-Error: ' + err));
5412 }
5413 if (result && utils.isPromise(result)) {
5414 return done(
5415 new Error(
5416 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
5417 )
5418 );
5419 }
5420
5421 done();
5422 });
5423 }
5424};
5425
5426/**
5427 * Instantiates a "timeout" error
5428 *
5429 * @param {number} ms - Timeout (in milliseconds)
5430 * @returns {Error} a "timeout" error
5431 * @private
5432 */
5433Runnable.prototype._timeoutError = function(ms) {
5434 var msg =
5435 'Timeout of ' +
5436 ms +
5437 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.';
5438 if (this.file) {
5439 msg += ' (' + this.file + ')';
5440 }
5441 return new Error(msg);
5442};
5443
5444var constants = utils.defineConstants(
5445 /**
5446 * {@link Runnable}-related constants.
5447 * @public
5448 * @memberof Runnable
5449 * @readonly
5450 * @static
5451 * @alias constants
5452 * @enum {string}
5453 */
5454 {
5455 /**
5456 * Value of `state` prop when a `Runnable` has failed
5457 */
5458 STATE_FAILED: 'failed',
5459 /**
5460 * Value of `state` prop when a `Runnable` has passed
5461 */
5462 STATE_PASSED: 'passed'
5463 }
5464);
5465
5466/**
5467 * Given `value`, return identity if truthy, otherwise create an "invalid exception" error and return that.
5468 * @param {*} [value] - Value to return, if present
5469 * @returns {*|Error} `value`, otherwise an `Error`
5470 * @private
5471 */
5472Runnable.toValueOrError = function(value) {
5473 return (
5474 value ||
5475 createInvalidExceptionError(
5476 'Runnable failed with falsy or undefined exception. Please throw an Error instead.',
5477 value
5478 )
5479 );
5480};
5481
5482Runnable.constants = constants;
5483
5484}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5485},{"./errors":6,"./pending":16,"./utils":38,"debug":45,"events":50,"ms":60}],34:[function(require,module,exports){
5486(function (process,global){
5487'use strict';
5488
5489/**
5490 * Module dependencies.
5491 */
5492var util = require('util');
5493var EventEmitter = require('events').EventEmitter;
5494var Pending = require('./pending');
5495var utils = require('./utils');
5496var inherits = utils.inherits;
5497var debug = require('debug')('mocha:runner');
5498var Runnable = require('./runnable');
5499var Suite = require('./suite');
5500var HOOK_TYPE_BEFORE_EACH = Suite.constants.HOOK_TYPE_BEFORE_EACH;
5501var HOOK_TYPE_AFTER_EACH = Suite.constants.HOOK_TYPE_AFTER_EACH;
5502var HOOK_TYPE_AFTER_ALL = Suite.constants.HOOK_TYPE_AFTER_ALL;
5503var HOOK_TYPE_BEFORE_ALL = Suite.constants.HOOK_TYPE_BEFORE_ALL;
5504var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN;
5505var STATE_FAILED = Runnable.constants.STATE_FAILED;
5506var STATE_PASSED = Runnable.constants.STATE_PASSED;
5507var dQuote = utils.dQuote;
5508var ngettext = utils.ngettext;
5509var sQuote = utils.sQuote;
5510var stackFilter = utils.stackTraceFilter();
5511var stringify = utils.stringify;
5512var type = utils.type;
5513var createInvalidExceptionError = require('./errors')
5514 .createInvalidExceptionError;
5515
5516/**
5517 * Non-enumerable globals.
5518 * @readonly
5519 */
5520var globals = [
5521 'setTimeout',
5522 'clearTimeout',
5523 'setInterval',
5524 'clearInterval',
5525 'XMLHttpRequest',
5526 'Date',
5527 'setImmediate',
5528 'clearImmediate'
5529];
5530
5531var constants = utils.defineConstants(
5532 /**
5533 * {@link Runner}-related constants.
5534 * @public
5535 * @memberof Runner
5536 * @readonly
5537 * @alias constants
5538 * @static
5539 * @enum {string}
5540 */
5541 {
5542 /**
5543 * Emitted when {@link Hook} execution begins
5544 */
5545 EVENT_HOOK_BEGIN: 'hook',
5546 /**
5547 * Emitted when {@link Hook} execution ends
5548 */
5549 EVENT_HOOK_END: 'hook end',
5550 /**
5551 * Emitted when Root {@link Suite} execution begins (all files have been parsed and hooks/tests are ready for execution)
5552 */
5553 EVENT_RUN_BEGIN: 'start',
5554 /**
5555 * Emitted when Root {@link Suite} execution has been delayed via `delay` option
5556 */
5557 EVENT_DELAY_BEGIN: 'waiting',
5558 /**
5559 * Emitted when delayed Root {@link Suite} execution is triggered by user via `global.run()`
5560 */
5561 EVENT_DELAY_END: 'ready',
5562 /**
5563 * Emitted when Root {@link Suite} execution ends
5564 */
5565 EVENT_RUN_END: 'end',
5566 /**
5567 * Emitted when {@link Suite} execution begins
5568 */
5569 EVENT_SUITE_BEGIN: 'suite',
5570 /**
5571 * Emitted when {@link Suite} execution ends
5572 */
5573 EVENT_SUITE_END: 'suite end',
5574 /**
5575 * Emitted when {@link Test} execution begins
5576 */
5577 EVENT_TEST_BEGIN: 'test',
5578 /**
5579 * Emitted when {@link Test} execution ends
5580 */
5581 EVENT_TEST_END: 'test end',
5582 /**
5583 * Emitted when {@link Test} execution fails
5584 */
5585 EVENT_TEST_FAIL: 'fail',
5586 /**
5587 * Emitted when {@link Test} execution succeeds
5588 */
5589 EVENT_TEST_PASS: 'pass',
5590 /**
5591 * Emitted when {@link Test} becomes pending
5592 */
5593 EVENT_TEST_PENDING: 'pending',
5594 /**
5595 * Emitted when {@link Test} execution has failed, but will retry
5596 */
5597 EVENT_TEST_RETRY: 'retry'
5598 }
5599);
5600
5601module.exports = Runner;
5602
5603/**
5604 * Initialize a `Runner` at the Root {@link Suite}, which represents a hierarchy of {@link Suite|Suites} and {@link Test|Tests}.
5605 *
5606 * @extends external:EventEmitter
5607 * @public
5608 * @class
5609 * @param {Suite} suite Root suite
5610 * @param {boolean} [delay] Whether or not to delay execution of root suite
5611 * until ready.
5612 */
5613function Runner(suite, delay) {
5614 var self = this;
5615 this._globals = [];
5616 this._abort = false;
5617 this._delay = delay;
5618 this.suite = suite;
5619 this.started = false;
5620 this.total = suite.total();
5621 this.failures = 0;
5622 this.on(constants.EVENT_TEST_END, function(test) {
5623 self.checkGlobals(test);
5624 });
5625 this.on(constants.EVENT_HOOK_END, function(hook) {
5626 self.checkGlobals(hook);
5627 });
5628 this._defaultGrep = /.*/;
5629 this.grep(this._defaultGrep);
5630 this.globals(this.globalProps());
5631}
5632
5633/**
5634 * Wrapper for setImmediate, process.nextTick, or browser polyfill.
5635 *
5636 * @param {Function} fn
5637 * @private
5638 */
5639Runner.immediately = global.setImmediate || process.nextTick;
5640
5641/**
5642 * Inherit from `EventEmitter.prototype`.
5643 */
5644inherits(Runner, EventEmitter);
5645
5646/**
5647 * Run tests with full titles matching `re`. Updates runner.total
5648 * with number of tests matched.
5649 *
5650 * @public
5651 * @memberof Runner
5652 * @param {RegExp} re
5653 * @param {boolean} invert
5654 * @return {Runner} Runner instance.
5655 */
5656Runner.prototype.grep = function(re, invert) {
5657 debug('grep %s', re);
5658 this._grep = re;
5659 this._invert = invert;
5660 this.total = this.grepTotal(this.suite);
5661 return this;
5662};
5663
5664/**
5665 * Returns the number of tests matching the grep search for the
5666 * given suite.
5667 *
5668 * @memberof Runner
5669 * @public
5670 * @param {Suite} suite
5671 * @return {number}
5672 */
5673Runner.prototype.grepTotal = function(suite) {
5674 var self = this;
5675 var total = 0;
5676
5677 suite.eachTest(function(test) {
5678 var match = self._grep.test(test.fullTitle());
5679 if (self._invert) {
5680 match = !match;
5681 }
5682 if (match) {
5683 total++;
5684 }
5685 });
5686
5687 return total;
5688};
5689
5690/**
5691 * Return a list of global properties.
5692 *
5693 * @return {Array}
5694 * @private
5695 */
5696Runner.prototype.globalProps = function() {
5697 var props = Object.keys(global);
5698
5699 // non-enumerables
5700 for (var i = 0; i < globals.length; ++i) {
5701 if (~props.indexOf(globals[i])) {
5702 continue;
5703 }
5704 props.push(globals[i]);
5705 }
5706
5707 return props;
5708};
5709
5710/**
5711 * Allow the given `arr` of globals.
5712 *
5713 * @public
5714 * @memberof Runner
5715 * @param {Array} arr
5716 * @return {Runner} Runner instance.
5717 */
5718Runner.prototype.globals = function(arr) {
5719 if (!arguments.length) {
5720 return this._globals;
5721 }
5722 debug('globals %j', arr);
5723 this._globals = this._globals.concat(arr);
5724 return this;
5725};
5726
5727/**
5728 * Check for global variable leaks.
5729 *
5730 * @private
5731 */
5732Runner.prototype.checkGlobals = function(test) {
5733 if (this.ignoreLeaks) {
5734 return;
5735 }
5736 var ok = this._globals;
5737
5738 var globals = this.globalProps();
5739 var leaks;
5740
5741 if (test) {
5742 ok = ok.concat(test._allowedGlobals || []);
5743 }
5744
5745 if (this.prevGlobalsLength === globals.length) {
5746 return;
5747 }
5748 this.prevGlobalsLength = globals.length;
5749
5750 leaks = filterLeaks(ok, globals);
5751 this._globals = this._globals.concat(leaks);
5752
5753 if (leaks.length) {
5754 var format = ngettext(
5755 leaks.length,
5756 'global leak detected: %s',
5757 'global leaks detected: %s'
5758 );
5759 var error = new Error(util.format(format, leaks.map(sQuote).join(', ')));
5760 this.fail(test, error);
5761 }
5762};
5763
5764/**
5765 * Fail the given `test`.
5766 *
5767 * @private
5768 * @param {Test} test
5769 * @param {Error} err
5770 */
5771Runner.prototype.fail = function(test, err) {
5772 if (test.isPending()) {
5773 return;
5774 }
5775
5776 ++this.failures;
5777 test.state = STATE_FAILED;
5778
5779 if (!isError(err)) {
5780 err = thrown2Error(err);
5781 }
5782
5783 try {
5784 err.stack =
5785 this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
5786 } catch (ignore) {
5787 // some environments do not take kindly to monkeying with the stack
5788 }
5789
5790 this.emit(constants.EVENT_TEST_FAIL, test, err);
5791};
5792
5793/**
5794 * Fail the given `hook` with `err`.
5795 *
5796 * Hook failures work in the following pattern:
5797 * - If bail, run corresponding `after each` and `after` hooks,
5798 * then exit
5799 * - Failed `before` hook skips all tests in a suite and subsuites,
5800 * but jumps to corresponding `after` hook
5801 * - Failed `before each` hook skips remaining tests in a
5802 * suite and jumps to corresponding `after each` hook,
5803 * which is run only once
5804 * - Failed `after` hook does not alter
5805 * execution order
5806 * - Failed `after each` hook skips remaining tests in a
5807 * suite and subsuites, but executes other `after each`
5808 * hooks
5809 *
5810 * @private
5811 * @param {Hook} hook
5812 * @param {Error} err
5813 */
5814Runner.prototype.failHook = function(hook, err) {
5815 hook.originalTitle = hook.originalTitle || hook.title;
5816 if (hook.ctx && hook.ctx.currentTest) {
5817 hook.title =
5818 hook.originalTitle + ' for ' + dQuote(hook.ctx.currentTest.title);
5819 } else {
5820 var parentTitle;
5821 if (hook.parent.title) {
5822 parentTitle = hook.parent.title;
5823 } else {
5824 parentTitle = hook.parent.root ? '{root}' : '';
5825 }
5826 hook.title = hook.originalTitle + ' in ' + dQuote(parentTitle);
5827 }
5828
5829 this.fail(hook, err);
5830};
5831
5832/**
5833 * Run hook `name` callbacks and then invoke `fn()`.
5834 *
5835 * @private
5836 * @param {string} name
5837 * @param {Function} fn
5838 */
5839
5840Runner.prototype.hook = function(name, fn) {
5841 var suite = this.suite;
5842 var hooks = suite.getHooks(name);
5843 var self = this;
5844
5845 function next(i) {
5846 var hook = hooks[i];
5847 if (!hook) {
5848 return fn();
5849 }
5850 self.currentRunnable = hook;
5851
5852 if (name === HOOK_TYPE_BEFORE_ALL) {
5853 hook.ctx.currentTest = hook.parent.tests[0];
5854 } else if (name === HOOK_TYPE_AFTER_ALL) {
5855 hook.ctx.currentTest = hook.parent.tests[hook.parent.tests.length - 1];
5856 } else {
5857 hook.ctx.currentTest = self.test;
5858 }
5859
5860 hook.allowUncaught = self.allowUncaught;
5861
5862 self.emit(constants.EVENT_HOOK_BEGIN, hook);
5863
5864 if (!hook.listeners('error').length) {
5865 hook.on('error', function(err) {
5866 self.failHook(hook, err);
5867 });
5868 }
5869
5870 hook.run(function(err) {
5871 var testError = hook.error();
5872 if (testError) {
5873 self.fail(self.test, testError);
5874 }
5875 if (err) {
5876 if (err instanceof Pending) {
5877 if (name === HOOK_TYPE_AFTER_ALL) {
5878 utils.deprecate(
5879 'Skipping a test within an "after all" hook is DEPRECATED and will throw an exception in a future version of Mocha. ' +
5880 'Use a return statement or other means to abort hook execution.'
5881 );
5882 }
5883 if (name === HOOK_TYPE_BEFORE_EACH || name === HOOK_TYPE_AFTER_EACH) {
5884 if (self.test) {
5885 self.test.pending = true;
5886 }
5887 } else {
5888 suite.tests.forEach(function(test) {
5889 test.pending = true;
5890 });
5891 suite.suites.forEach(function(suite) {
5892 suite.pending = true;
5893 });
5894 // a pending hook won't be executed twice.
5895 hook.pending = true;
5896 }
5897 } else {
5898 self.failHook(hook, err);
5899
5900 // stop executing hooks, notify callee of hook err
5901 return fn(err);
5902 }
5903 }
5904 self.emit(constants.EVENT_HOOK_END, hook);
5905 delete hook.ctx.currentTest;
5906 next(++i);
5907 });
5908 }
5909
5910 Runner.immediately(function() {
5911 next(0);
5912 });
5913};
5914
5915/**
5916 * Run hook `name` for the given array of `suites`
5917 * in order, and callback `fn(err, errSuite)`.
5918 *
5919 * @private
5920 * @param {string} name
5921 * @param {Array} suites
5922 * @param {Function} fn
5923 */
5924Runner.prototype.hooks = function(name, suites, fn) {
5925 var self = this;
5926 var orig = this.suite;
5927
5928 function next(suite) {
5929 self.suite = suite;
5930
5931 if (!suite) {
5932 self.suite = orig;
5933 return fn();
5934 }
5935
5936 self.hook(name, function(err) {
5937 if (err) {
5938 var errSuite = self.suite;
5939 self.suite = orig;
5940 return fn(err, errSuite);
5941 }
5942
5943 next(suites.pop());
5944 });
5945 }
5946
5947 next(suites.pop());
5948};
5949
5950/**
5951 * Run hooks from the top level down.
5952 *
5953 * @param {String} name
5954 * @param {Function} fn
5955 * @private
5956 */
5957Runner.prototype.hookUp = function(name, fn) {
5958 var suites = [this.suite].concat(this.parents()).reverse();
5959 this.hooks(name, suites, fn);
5960};
5961
5962/**
5963 * Run hooks from the bottom up.
5964 *
5965 * @param {String} name
5966 * @param {Function} fn
5967 * @private
5968 */
5969Runner.prototype.hookDown = function(name, fn) {
5970 var suites = [this.suite].concat(this.parents());
5971 this.hooks(name, suites, fn);
5972};
5973
5974/**
5975 * Return an array of parent Suites from
5976 * closest to furthest.
5977 *
5978 * @return {Array}
5979 * @private
5980 */
5981Runner.prototype.parents = function() {
5982 var suite = this.suite;
5983 var suites = [];
5984 while (suite.parent) {
5985 suite = suite.parent;
5986 suites.push(suite);
5987 }
5988 return suites;
5989};
5990
5991/**
5992 * Run the current test and callback `fn(err)`.
5993 *
5994 * @param {Function} fn
5995 * @private
5996 */
5997Runner.prototype.runTest = function(fn) {
5998 var self = this;
5999 var test = this.test;
6000
6001 if (!test) {
6002 return;
6003 }
6004
6005 var suite = this.parents().reverse()[0] || this.suite;
6006 if (this.forbidOnly && suite.hasOnly()) {
6007 fn(new Error('`.only` forbidden'));
6008 return;
6009 }
6010 if (this.asyncOnly) {
6011 test.asyncOnly = true;
6012 }
6013 test.on('error', function(err) {
6014 self.fail(test, err);
6015 });
6016 if (this.allowUncaught) {
6017 test.allowUncaught = true;
6018 return test.run(fn);
6019 }
6020 try {
6021 test.run(fn);
6022 } catch (err) {
6023 fn(err);
6024 }
6025};
6026
6027/**
6028 * Run tests in the given `suite` and invoke the callback `fn()` when complete.
6029 *
6030 * @private
6031 * @param {Suite} suite
6032 * @param {Function} fn
6033 */
6034Runner.prototype.runTests = function(suite, fn) {
6035 var self = this;
6036 var tests = suite.tests.slice();
6037 var test;
6038
6039 function hookErr(_, errSuite, after) {
6040 // before/after Each hook for errSuite failed:
6041 var orig = self.suite;
6042
6043 // for failed 'after each' hook start from errSuite parent,
6044 // otherwise start from errSuite itself
6045 self.suite = after ? errSuite.parent : errSuite;
6046
6047 if (self.suite) {
6048 // call hookUp afterEach
6049 self.hookUp(HOOK_TYPE_AFTER_EACH, function(err2, errSuite2) {
6050 self.suite = orig;
6051 // some hooks may fail even now
6052 if (err2) {
6053 return hookErr(err2, errSuite2, true);
6054 }
6055 // report error suite
6056 fn(errSuite);
6057 });
6058 } else {
6059 // there is no need calling other 'after each' hooks
6060 self.suite = orig;
6061 fn(errSuite);
6062 }
6063 }
6064
6065 function next(err, errSuite) {
6066 // if we bail after first err
6067 if (self.failures && suite._bail) {
6068 tests = [];
6069 }
6070
6071 if (self._abort) {
6072 return fn();
6073 }
6074
6075 if (err) {
6076 return hookErr(err, errSuite, true);
6077 }
6078
6079 // next test
6080 test = tests.shift();
6081
6082 // all done
6083 if (!test) {
6084 return fn();
6085 }
6086
6087 // grep
6088 var match = self._grep.test(test.fullTitle());
6089 if (self._invert) {
6090 match = !match;
6091 }
6092 if (!match) {
6093 // Run immediately only if we have defined a grep. When we
6094 // define a grep — It can cause maximum callstack error if
6095 // the grep is doing a large recursive loop by neglecting
6096 // all tests. The run immediately function also comes with
6097 // a performance cost. So we don't want to run immediately
6098 // if we run the whole test suite, because running the whole
6099 // test suite don't do any immediate recursive loops. Thus,
6100 // allowing a JS runtime to breathe.
6101 if (self._grep !== self._defaultGrep) {
6102 Runner.immediately(next);
6103 } else {
6104 next();
6105 }
6106 return;
6107 }
6108
6109 if (test.isPending()) {
6110 if (self.forbidPending) {
6111 test.isPending = alwaysFalse;
6112 self.fail(test, new Error('Pending test forbidden'));
6113 delete test.isPending;
6114 } else {
6115 self.emit(constants.EVENT_TEST_PENDING, test);
6116 }
6117 self.emit(constants.EVENT_TEST_END, test);
6118 return next();
6119 }
6120
6121 // execute test and hook(s)
6122 self.emit(constants.EVENT_TEST_BEGIN, (self.test = test));
6123 self.hookDown(HOOK_TYPE_BEFORE_EACH, function(err, errSuite) {
6124 if (test.isPending()) {
6125 if (self.forbidPending) {
6126 test.isPending = alwaysFalse;
6127 self.fail(test, new Error('Pending test forbidden'));
6128 delete test.isPending;
6129 } else {
6130 self.emit(constants.EVENT_TEST_PENDING, test);
6131 }
6132 self.emit(constants.EVENT_TEST_END, test);
6133 return next();
6134 }
6135 if (err) {
6136 return hookErr(err, errSuite, false);
6137 }
6138 self.currentRunnable = self.test;
6139 self.runTest(function(err) {
6140 test = self.test;
6141 if (err) {
6142 var retry = test.currentRetry();
6143 if (err instanceof Pending && self.forbidPending) {
6144 self.fail(test, new Error('Pending test forbidden'));
6145 } else if (err instanceof Pending) {
6146 test.pending = true;
6147 self.emit(constants.EVENT_TEST_PENDING, test);
6148 } else if (retry < test.retries()) {
6149 var clonedTest = test.clone();
6150 clonedTest.currentRetry(retry + 1);
6151 tests.unshift(clonedTest);
6152
6153 self.emit(constants.EVENT_TEST_RETRY, test, err);
6154
6155 // Early return + hook trigger so that it doesn't
6156 // increment the count wrong
6157 return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6158 } else {
6159 self.fail(test, err);
6160 }
6161 self.emit(constants.EVENT_TEST_END, test);
6162
6163 if (err instanceof Pending) {
6164 return next();
6165 }
6166
6167 return self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6168 }
6169
6170 test.state = STATE_PASSED;
6171 self.emit(constants.EVENT_TEST_PASS, test);
6172 self.emit(constants.EVENT_TEST_END, test);
6173 self.hookUp(HOOK_TYPE_AFTER_EACH, next);
6174 });
6175 });
6176 }
6177
6178 this.next = next;
6179 this.hookErr = hookErr;
6180 next();
6181};
6182
6183function alwaysFalse() {
6184 return false;
6185}
6186
6187/**
6188 * Run the given `suite` and invoke the callback `fn()` when complete.
6189 *
6190 * @private
6191 * @param {Suite} suite
6192 * @param {Function} fn
6193 */
6194Runner.prototype.runSuite = function(suite, fn) {
6195 var i = 0;
6196 var self = this;
6197 var total = this.grepTotal(suite);
6198 var afterAllHookCalled = false;
6199
6200 debug('run suite %s', suite.fullTitle());
6201
6202 if (!total || (self.failures && suite._bail)) {
6203 return fn();
6204 }
6205
6206 this.emit(constants.EVENT_SUITE_BEGIN, (this.suite = suite));
6207
6208 function next(errSuite) {
6209 if (errSuite) {
6210 // current suite failed on a hook from errSuite
6211 if (errSuite === suite) {
6212 // if errSuite is current suite
6213 // continue to the next sibling suite
6214 return done();
6215 }
6216 // errSuite is among the parents of current suite
6217 // stop execution of errSuite and all sub-suites
6218 return done(errSuite);
6219 }
6220
6221 if (self._abort) {
6222 return done();
6223 }
6224
6225 var curr = suite.suites[i++];
6226 if (!curr) {
6227 return done();
6228 }
6229
6230 // Avoid grep neglecting large number of tests causing a
6231 // huge recursive loop and thus a maximum call stack error.
6232 // See comment in `this.runTests()` for more information.
6233 if (self._grep !== self._defaultGrep) {
6234 Runner.immediately(function() {
6235 self.runSuite(curr, next);
6236 });
6237 } else {
6238 self.runSuite(curr, next);
6239 }
6240 }
6241
6242 function done(errSuite) {
6243 self.suite = suite;
6244 self.nextSuite = next;
6245
6246 if (afterAllHookCalled) {
6247 fn(errSuite);
6248 } else {
6249 // mark that the afterAll block has been called once
6250 // and so can be skipped if there is an error in it.
6251 afterAllHookCalled = true;
6252
6253 // remove reference to test
6254 delete self.test;
6255
6256 self.hook(HOOK_TYPE_AFTER_ALL, function() {
6257 self.emit(constants.EVENT_SUITE_END, suite);
6258 fn(errSuite);
6259 });
6260 }
6261 }
6262
6263 this.nextSuite = next;
6264
6265 this.hook(HOOK_TYPE_BEFORE_ALL, function(err) {
6266 if (err) {
6267 return done();
6268 }
6269 self.runTests(suite, next);
6270 });
6271};
6272
6273/**
6274 * Handle uncaught exceptions.
6275 *
6276 * @param {Error} err
6277 * @private
6278 */
6279Runner.prototype.uncaught = function(err) {
6280 if (err instanceof Pending) {
6281 return;
6282 }
6283 if (err) {
6284 debug('uncaught exception %O', err);
6285 } else {
6286 debug('uncaught undefined/falsy exception');
6287 err = createInvalidExceptionError(
6288 'Caught falsy/undefined exception which would otherwise be uncaught. No stack trace found; try a debugger',
6289 err
6290 );
6291 }
6292
6293 if (!isError(err)) {
6294 err = thrown2Error(err);
6295 }
6296 err.uncaught = true;
6297
6298 var runnable = this.currentRunnable;
6299
6300 if (!runnable) {
6301 runnable = new Runnable('Uncaught error outside test suite');
6302 runnable.parent = this.suite;
6303
6304 if (this.started) {
6305 this.fail(runnable, err);
6306 } else {
6307 // Can't recover from this failure
6308 this.emit(constants.EVENT_RUN_BEGIN);
6309 this.fail(runnable, err);
6310 this.emit(constants.EVENT_RUN_END);
6311 }
6312
6313 return;
6314 }
6315
6316 runnable.clearTimeout();
6317
6318 // Ignore errors if already failed or pending
6319 // See #3226
6320 if (runnable.isFailed() || runnable.isPending()) {
6321 return;
6322 }
6323 // we cannot recover gracefully if a Runnable has already passed
6324 // then fails asynchronously
6325 var alreadyPassed = runnable.isPassed();
6326 // this will change the state to "failed" regardless of the current value
6327 this.fail(runnable, err);
6328 if (!alreadyPassed) {
6329 // recover from test
6330 if (runnable.type === constants.EVENT_TEST_BEGIN) {
6331 this.emit(constants.EVENT_TEST_END, runnable);
6332 this.hookUp(HOOK_TYPE_AFTER_EACH, this.next);
6333 return;
6334 }
6335 debug(runnable);
6336
6337 // recover from hooks
6338 var errSuite = this.suite;
6339
6340 // XXX how about a less awful way to determine this?
6341 // if hook failure is in afterEach block
6342 if (runnable.fullTitle().indexOf('after each') > -1) {
6343 return this.hookErr(err, errSuite, true);
6344 }
6345 // if hook failure is in beforeEach block
6346 if (runnable.fullTitle().indexOf('before each') > -1) {
6347 return this.hookErr(err, errSuite, false);
6348 }
6349 // if hook failure is in after or before blocks
6350 return this.nextSuite(errSuite);
6351 }
6352
6353 // bail
6354 this.abort();
6355};
6356
6357/**
6358 * Run the root suite and invoke `fn(failures)`
6359 * on completion.
6360 *
6361 * @public
6362 * @memberof Runner
6363 * @param {Function} fn
6364 * @return {Runner} Runner instance.
6365 */
6366Runner.prototype.run = function(fn) {
6367 var self = this;
6368 var rootSuite = this.suite;
6369
6370 fn = fn || function() {};
6371
6372 function uncaught(err) {
6373 self.uncaught(err);
6374 }
6375
6376 function start() {
6377 // If there is an `only` filter
6378 if (rootSuite.hasOnly()) {
6379 rootSuite.filterOnly();
6380 }
6381 self.started = true;
6382 if (self._delay) {
6383 self.emit(constants.EVENT_DELAY_END);
6384 }
6385 self.emit(constants.EVENT_RUN_BEGIN);
6386
6387 self.runSuite(rootSuite, function() {
6388 debug('finished running');
6389 self.emit(constants.EVENT_RUN_END);
6390 });
6391 }
6392
6393 debug(constants.EVENT_RUN_BEGIN);
6394
6395 // references cleanup to avoid memory leaks
6396 this.on(constants.EVENT_SUITE_END, function(suite) {
6397 suite.cleanReferences();
6398 });
6399
6400 // callback
6401 this.on(constants.EVENT_RUN_END, function() {
6402 debug(constants.EVENT_RUN_END);
6403 process.removeListener('uncaughtException', uncaught);
6404 fn(self.failures);
6405 });
6406
6407 // uncaught exception
6408 process.on('uncaughtException', uncaught);
6409
6410 if (this._delay) {
6411 // for reporters, I guess.
6412 // might be nice to debounce some dots while we wait.
6413 this.emit(constants.EVENT_DELAY_BEGIN, rootSuite);
6414 rootSuite.once(EVENT_ROOT_SUITE_RUN, start);
6415 } else {
6416 start();
6417 }
6418
6419 return this;
6420};
6421
6422/**
6423 * Cleanly abort execution.
6424 *
6425 * @memberof Runner
6426 * @public
6427 * @return {Runner} Runner instance.
6428 */
6429Runner.prototype.abort = function() {
6430 debug('aborting');
6431 this._abort = true;
6432
6433 return this;
6434};
6435
6436/**
6437 * Filter leaks with the given globals flagged as `ok`.
6438 *
6439 * @private
6440 * @param {Array} ok
6441 * @param {Array} globals
6442 * @return {Array}
6443 */
6444function filterLeaks(ok, globals) {
6445 return globals.filter(function(key) {
6446 // Firefox and Chrome exposes iframes as index inside the window object
6447 if (/^\d+/.test(key)) {
6448 return false;
6449 }
6450
6451 // in firefox
6452 // if runner runs in an iframe, this iframe's window.getInterface method
6453 // not init at first it is assigned in some seconds
6454 if (global.navigator && /^getInterface/.test(key)) {
6455 return false;
6456 }
6457
6458 // an iframe could be approached by window[iframeIndex]
6459 // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
6460 if (global.navigator && /^\d+/.test(key)) {
6461 return false;
6462 }
6463
6464 // Opera and IE expose global variables for HTML element IDs (issue #243)
6465 if (/^mocha-/.test(key)) {
6466 return false;
6467 }
6468
6469 var matched = ok.filter(function(ok) {
6470 if (~ok.indexOf('*')) {
6471 return key.indexOf(ok.split('*')[0]) === 0;
6472 }
6473 return key === ok;
6474 });
6475 return !matched.length && (!global.navigator || key !== 'onerror');
6476 });
6477}
6478
6479/**
6480 * Check if argument is an instance of Error object or a duck-typed equivalent.
6481 *
6482 * @private
6483 * @param {Object} err - object to check
6484 * @param {string} err.message - error message
6485 * @returns {boolean}
6486 */
6487function isError(err) {
6488 return err instanceof Error || (err && typeof err.message === 'string');
6489}
6490
6491/**
6492 *
6493 * Converts thrown non-extensible type into proper Error.
6494 *
6495 * @private
6496 * @param {*} thrown - Non-extensible type thrown by code
6497 * @return {Error}
6498 */
6499function thrown2Error(err) {
6500 return new Error(
6501 'the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)'
6502 );
6503}
6504
6505Runner.constants = constants;
6506
6507/**
6508 * Node.js' `EventEmitter`
6509 * @external EventEmitter
6510 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter}
6511 */
6512
6513}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
6514},{"./errors":6,"./pending":16,"./runnable":33,"./suite":36,"./utils":38,"_process":69,"debug":45,"events":50,"util":89}],35:[function(require,module,exports){
6515(function (global){
6516'use strict';
6517
6518/**
6519 * Provides a factory function for a {@link StatsCollector} object.
6520 * @module
6521 */
6522
6523var constants = require('./runner').constants;
6524var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
6525var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
6526var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
6527var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
6528var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
6529var EVENT_RUN_END = constants.EVENT_RUN_END;
6530var EVENT_TEST_END = constants.EVENT_TEST_END;
6531
6532/**
6533 * Test statistics collector.
6534 *
6535 * @public
6536 * @typedef {Object} StatsCollector
6537 * @property {number} suites - integer count of suites run.
6538 * @property {number} tests - integer count of tests run.
6539 * @property {number} passes - integer count of passing tests.
6540 * @property {number} pending - integer count of pending tests.
6541 * @property {number} failures - integer count of failed tests.
6542 * @property {Date} start - time when testing began.
6543 * @property {Date} end - time when testing concluded.
6544 * @property {number} duration - number of msecs that testing took.
6545 */
6546
6547var Date = global.Date;
6548
6549/**
6550 * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`.
6551 *
6552 * @private
6553 * @param {Runner} runner - Runner instance
6554 * @throws {TypeError} If falsy `runner`
6555 */
6556function createStatsCollector(runner) {
6557 /**
6558 * @type StatsCollector
6559 */
6560 var stats = {
6561 suites: 0,
6562 tests: 0,
6563 passes: 0,
6564 pending: 0,
6565 failures: 0
6566 };
6567
6568 if (!runner) {
6569 throw new TypeError('Missing runner argument');
6570 }
6571
6572 runner.stats = stats;
6573
6574 runner.once(EVENT_RUN_BEGIN, function() {
6575 stats.start = new Date();
6576 });
6577 runner.on(EVENT_SUITE_BEGIN, function(suite) {
6578 suite.root || stats.suites++;
6579 });
6580 runner.on(EVENT_TEST_PASS, function() {
6581 stats.passes++;
6582 });
6583 runner.on(EVENT_TEST_FAIL, function() {
6584 stats.failures++;
6585 });
6586 runner.on(EVENT_TEST_PENDING, function() {
6587 stats.pending++;
6588 });
6589 runner.on(EVENT_TEST_END, function() {
6590 stats.tests++;
6591 });
6592 runner.once(EVENT_RUN_END, function() {
6593 stats.end = new Date();
6594 stats.duration = stats.end - stats.start;
6595 });
6596}
6597
6598module.exports = createStatsCollector;
6599
6600}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
6601},{"./runner":34}],36:[function(require,module,exports){
6602'use strict';
6603
6604/**
6605 * Module dependencies.
6606 */
6607var EventEmitter = require('events').EventEmitter;
6608var Hook = require('./hook');
6609var utils = require('./utils');
6610var inherits = utils.inherits;
6611var debug = require('debug')('mocha:suite');
6612var milliseconds = require('ms');
6613var errors = require('./errors');
6614var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
6615
6616/**
6617 * Expose `Suite`.
6618 */
6619
6620exports = module.exports = Suite;
6621
6622/**
6623 * Create a new `Suite` with the given `title` and parent `Suite`.
6624 *
6625 * @public
6626 * @param {Suite} parent - Parent suite (required!)
6627 * @param {string} title - Title
6628 * @return {Suite}
6629 */
6630Suite.create = function(parent, title) {
6631 var suite = new Suite(title, parent.ctx);
6632 suite.parent = parent;
6633 title = suite.fullTitle();
6634 parent.addSuite(suite);
6635 return suite;
6636};
6637
6638/**
6639 * Constructs a new `Suite` instance with the given `title`, `ctx`, and `isRoot`.
6640 *
6641 * @public
6642 * @class
6643 * @extends EventEmitter
6644 * @see {@link https://nodejs.org/api/events.html#events_class_eventemitter|EventEmitter}
6645 * @param {string} title - Suite title.
6646 * @param {Context} parentContext - Parent context instance.
6647 * @param {boolean} [isRoot=false] - Whether this is the root suite.
6648 */
6649function Suite(title, parentContext, isRoot) {
6650 if (!utils.isString(title)) {
6651 throw createInvalidArgumentTypeError(
6652 'Suite argument "title" must be a string. Received type "' +
6653 typeof title +
6654 '"',
6655 'title',
6656 'string'
6657 );
6658 }
6659 this.title = title;
6660 function Context() {}
6661 Context.prototype = parentContext;
6662 this.ctx = new Context();
6663 this.suites = [];
6664 this.tests = [];
6665 this.pending = false;
6666 this._beforeEach = [];
6667 this._beforeAll = [];
6668 this._afterEach = [];
6669 this._afterAll = [];
6670 this.root = isRoot === true;
6671 this._timeout = 2000;
6672 this._enableTimeouts = true;
6673 this._slow = 75;
6674 this._bail = false;
6675 this._retries = -1;
6676 this._onlyTests = [];
6677 this._onlySuites = [];
6678 this.delayed = false;
6679
6680 this.on('newListener', function(event) {
6681 if (deprecatedEvents[event]) {
6682 utils.deprecate(
6683 'Event "' +
6684 event +
6685 '" is deprecated. Please let the Mocha team know about your use case: https://git.io/v6Lwm'
6686 );
6687 }
6688 });
6689}
6690
6691/**
6692 * Inherit from `EventEmitter.prototype`.
6693 */
6694inherits(Suite, EventEmitter);
6695
6696/**
6697 * Return a clone of this `Suite`.
6698 *
6699 * @private
6700 * @return {Suite}
6701 */
6702Suite.prototype.clone = function() {
6703 var suite = new Suite(this.title);
6704 debug('clone');
6705 suite.ctx = this.ctx;
6706 suite.root = this.root;
6707 suite.timeout(this.timeout());
6708 suite.retries(this.retries());
6709 suite.enableTimeouts(this.enableTimeouts());
6710 suite.slow(this.slow());
6711 suite.bail(this.bail());
6712 return suite;
6713};
6714
6715/**
6716 * Set or get timeout `ms` or short-hand such as "2s".
6717 *
6718 * @private
6719 * @todo Do not attempt to set value if `ms` is undefined
6720 * @param {number|string} ms
6721 * @return {Suite|number} for chaining
6722 */
6723Suite.prototype.timeout = function(ms) {
6724 if (!arguments.length) {
6725 return this._timeout;
6726 }
6727 if (ms.toString() === '0') {
6728 this._enableTimeouts = false;
6729 }
6730 if (typeof ms === 'string') {
6731 ms = milliseconds(ms);
6732 }
6733 debug('timeout %d', ms);
6734 this._timeout = parseInt(ms, 10);
6735 return this;
6736};
6737
6738/**
6739 * Set or get number of times to retry a failed test.
6740 *
6741 * @private
6742 * @param {number|string} n
6743 * @return {Suite|number} for chaining
6744 */
6745Suite.prototype.retries = function(n) {
6746 if (!arguments.length) {
6747 return this._retries;
6748 }
6749 debug('retries %d', n);
6750 this._retries = parseInt(n, 10) || 0;
6751 return this;
6752};
6753
6754/**
6755 * Set or get timeout to `enabled`.
6756 *
6757 * @private
6758 * @param {boolean} enabled
6759 * @return {Suite|boolean} self or enabled
6760 */
6761Suite.prototype.enableTimeouts = function(enabled) {
6762 if (!arguments.length) {
6763 return this._enableTimeouts;
6764 }
6765 debug('enableTimeouts %s', enabled);
6766 this._enableTimeouts = enabled;
6767 return this;
6768};
6769
6770/**
6771 * Set or get slow `ms` or short-hand such as "2s".
6772 *
6773 * @private
6774 * @param {number|string} ms
6775 * @return {Suite|number} for chaining
6776 */
6777Suite.prototype.slow = function(ms) {
6778 if (!arguments.length) {
6779 return this._slow;
6780 }
6781 if (typeof ms === 'string') {
6782 ms = milliseconds(ms);
6783 }
6784 debug('slow %d', ms);
6785 this._slow = ms;
6786 return this;
6787};
6788
6789/**
6790 * Set or get whether to bail after first error.
6791 *
6792 * @private
6793 * @param {boolean} bail
6794 * @return {Suite|number} for chaining
6795 */
6796Suite.prototype.bail = function(bail) {
6797 if (!arguments.length) {
6798 return this._bail;
6799 }
6800 debug('bail %s', bail);
6801 this._bail = bail;
6802 return this;
6803};
6804
6805/**
6806 * Check if this suite or its parent suite is marked as pending.
6807 *
6808 * @private
6809 */
6810Suite.prototype.isPending = function() {
6811 return this.pending || (this.parent && this.parent.isPending());
6812};
6813
6814/**
6815 * Generic hook-creator.
6816 * @private
6817 * @param {string} title - Title of hook
6818 * @param {Function} fn - Hook callback
6819 * @returns {Hook} A new hook
6820 */
6821Suite.prototype._createHook = function(title, fn) {
6822 var hook = new Hook(title, fn);
6823 hook.parent = this;
6824 hook.timeout(this.timeout());
6825 hook.retries(this.retries());
6826 hook.enableTimeouts(this.enableTimeouts());
6827 hook.slow(this.slow());
6828 hook.ctx = this.ctx;
6829 hook.file = this.file;
6830 return hook;
6831};
6832
6833/**
6834 * Run `fn(test[, done])` before running tests.
6835 *
6836 * @private
6837 * @param {string} title
6838 * @param {Function} fn
6839 * @return {Suite} for chaining
6840 */
6841Suite.prototype.beforeAll = function(title, fn) {
6842 if (this.isPending()) {
6843 return this;
6844 }
6845 if (typeof title === 'function') {
6846 fn = title;
6847 title = fn.name;
6848 }
6849 title = '"before all" hook' + (title ? ': ' + title : '');
6850
6851 var hook = this._createHook(title, fn);
6852 this._beforeAll.push(hook);
6853 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
6854 return this;
6855};
6856
6857/**
6858 * Run `fn(test[, done])` after running tests.
6859 *
6860 * @private
6861 * @param {string} title
6862 * @param {Function} fn
6863 * @return {Suite} for chaining
6864 */
6865Suite.prototype.afterAll = function(title, fn) {
6866 if (this.isPending()) {
6867 return this;
6868 }
6869 if (typeof title === 'function') {
6870 fn = title;
6871 title = fn.name;
6872 }
6873 title = '"after all" hook' + (title ? ': ' + title : '');
6874
6875 var hook = this._createHook(title, fn);
6876 this._afterAll.push(hook);
6877 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
6878 return this;
6879};
6880
6881/**
6882 * Run `fn(test[, done])` before each test case.
6883 *
6884 * @private
6885 * @param {string} title
6886 * @param {Function} fn
6887 * @return {Suite} for chaining
6888 */
6889Suite.prototype.beforeEach = function(title, fn) {
6890 if (this.isPending()) {
6891 return this;
6892 }
6893 if (typeof title === 'function') {
6894 fn = title;
6895 title = fn.name;
6896 }
6897 title = '"before each" hook' + (title ? ': ' + title : '');
6898
6899 var hook = this._createHook(title, fn);
6900 this._beforeEach.push(hook);
6901 this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
6902 return this;
6903};
6904
6905/**
6906 * Run `fn(test[, done])` after each test case.
6907 *
6908 * @private
6909 * @param {string} title
6910 * @param {Function} fn
6911 * @return {Suite} for chaining
6912 */
6913Suite.prototype.afterEach = function(title, fn) {
6914 if (this.isPending()) {
6915 return this;
6916 }
6917 if (typeof title === 'function') {
6918 fn = title;
6919 title = fn.name;
6920 }
6921 title = '"after each" hook' + (title ? ': ' + title : '');
6922
6923 var hook = this._createHook(title, fn);
6924 this._afterEach.push(hook);
6925 this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
6926 return this;
6927};
6928
6929/**
6930 * Add a test `suite`.
6931 *
6932 * @private
6933 * @param {Suite} suite
6934 * @return {Suite} for chaining
6935 */
6936Suite.prototype.addSuite = function(suite) {
6937 suite.parent = this;
6938 suite.root = false;
6939 suite.timeout(this.timeout());
6940 suite.retries(this.retries());
6941 suite.enableTimeouts(this.enableTimeouts());
6942 suite.slow(this.slow());
6943 suite.bail(this.bail());
6944 this.suites.push(suite);
6945 this.emit(constants.EVENT_SUITE_ADD_SUITE, suite);
6946 return this;
6947};
6948
6949/**
6950 * Add a `test` to this suite.
6951 *
6952 * @private
6953 * @param {Test} test
6954 * @return {Suite} for chaining
6955 */
6956Suite.prototype.addTest = function(test) {
6957 test.parent = this;
6958 test.timeout(this.timeout());
6959 test.retries(this.retries());
6960 test.enableTimeouts(this.enableTimeouts());
6961 test.slow(this.slow());
6962 test.ctx = this.ctx;
6963 this.tests.push(test);
6964 this.emit(constants.EVENT_SUITE_ADD_TEST, test);
6965 return this;
6966};
6967
6968/**
6969 * Return the full title generated by recursively concatenating the parent's
6970 * full title.
6971 *
6972 * @memberof Suite
6973 * @public
6974 * @return {string}
6975 */
6976Suite.prototype.fullTitle = function() {
6977 return this.titlePath().join(' ');
6978};
6979
6980/**
6981 * Return the title path generated by recursively concatenating the parent's
6982 * title path.
6983 *
6984 * @memberof Suite
6985 * @public
6986 * @return {string}
6987 */
6988Suite.prototype.titlePath = function() {
6989 var result = [];
6990 if (this.parent) {
6991 result = result.concat(this.parent.titlePath());
6992 }
6993 if (!this.root) {
6994 result.push(this.title);
6995 }
6996 return result;
6997};
6998
6999/**
7000 * Return the total number of tests.
7001 *
7002 * @memberof Suite
7003 * @public
7004 * @return {number}
7005 */
7006Suite.prototype.total = function() {
7007 return (
7008 this.suites.reduce(function(sum, suite) {
7009 return sum + suite.total();
7010 }, 0) + this.tests.length
7011 );
7012};
7013
7014/**
7015 * Iterates through each suite recursively to find all tests. Applies a
7016 * function in the format `fn(test)`.
7017 *
7018 * @private
7019 * @param {Function} fn
7020 * @return {Suite}
7021 */
7022Suite.prototype.eachTest = function(fn) {
7023 this.tests.forEach(fn);
7024 this.suites.forEach(function(suite) {
7025 suite.eachTest(fn);
7026 });
7027 return this;
7028};
7029
7030/**
7031 * This will run the root suite if we happen to be running in delayed mode.
7032 * @private
7033 */
7034Suite.prototype.run = function run() {
7035 if (this.root) {
7036 this.emit(constants.EVENT_ROOT_SUITE_RUN);
7037 }
7038};
7039
7040/**
7041 * Determines whether a suite has an `only` test or suite as a descendant.
7042 *
7043 * @private
7044 * @returns {Boolean}
7045 */
7046Suite.prototype.hasOnly = function hasOnly() {
7047 return (
7048 this._onlyTests.length > 0 ||
7049 this._onlySuites.length > 0 ||
7050 this.suites.some(function(suite) {
7051 return suite.hasOnly();
7052 })
7053 );
7054};
7055
7056/**
7057 * Filter suites based on `isOnly` logic.
7058 *
7059 * @private
7060 * @returns {Boolean}
7061 */
7062Suite.prototype.filterOnly = function filterOnly() {
7063 if (this._onlyTests.length) {
7064 // If the suite contains `only` tests, run those and ignore any nested suites.
7065 this.tests = this._onlyTests;
7066 this.suites = [];
7067 } else {
7068 // Otherwise, do not run any of the tests in this suite.
7069 this.tests = [];
7070 this._onlySuites.forEach(function(onlySuite) {
7071 // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
7072 // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
7073 if (onlySuite.hasOnly()) {
7074 onlySuite.filterOnly();
7075 }
7076 });
7077 // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
7078 var onlySuites = this._onlySuites;
7079 this.suites = this.suites.filter(function(childSuite) {
7080 return onlySuites.indexOf(childSuite) !== -1 || childSuite.filterOnly();
7081 });
7082 }
7083 // Keep the suite only if there is something to run
7084 return this.tests.length > 0 || this.suites.length > 0;
7085};
7086
7087/**
7088 * Adds a suite to the list of subsuites marked `only`.
7089 *
7090 * @private
7091 * @param {Suite} suite
7092 */
7093Suite.prototype.appendOnlySuite = function(suite) {
7094 this._onlySuites.push(suite);
7095};
7096
7097/**
7098 * Adds a test to the list of tests marked `only`.
7099 *
7100 * @private
7101 * @param {Test} test
7102 */
7103Suite.prototype.appendOnlyTest = function(test) {
7104 this._onlyTests.push(test);
7105};
7106
7107/**
7108 * Returns the array of hooks by hook name; see `HOOK_TYPE_*` constants.
7109 * @private
7110 */
7111Suite.prototype.getHooks = function getHooks(name) {
7112 return this['_' + name];
7113};
7114
7115/**
7116 * Cleans up the references to all the deferred functions
7117 * (before/after/beforeEach/afterEach) and tests of a Suite.
7118 * These must be deleted otherwise a memory leak can happen,
7119 * as those functions may reference variables from closures,
7120 * thus those variables can never be garbage collected as long
7121 * as the deferred functions exist.
7122 *
7123 * @private
7124 */
7125Suite.prototype.cleanReferences = function cleanReferences() {
7126 function cleanArrReferences(arr) {
7127 for (var i = 0; i < arr.length; i++) {
7128 delete arr[i].fn;
7129 }
7130 }
7131
7132 if (Array.isArray(this._beforeAll)) {
7133 cleanArrReferences(this._beforeAll);
7134 }
7135
7136 if (Array.isArray(this._beforeEach)) {
7137 cleanArrReferences(this._beforeEach);
7138 }
7139
7140 if (Array.isArray(this._afterAll)) {
7141 cleanArrReferences(this._afterAll);
7142 }
7143
7144 if (Array.isArray(this._afterEach)) {
7145 cleanArrReferences(this._afterEach);
7146 }
7147
7148 for (var i = 0; i < this.tests.length; i++) {
7149 delete this.tests[i].fn;
7150 }
7151};
7152
7153var constants = utils.defineConstants(
7154 /**
7155 * {@link Suite}-related constants.
7156 * @public
7157 * @memberof Suite
7158 * @alias constants
7159 * @readonly
7160 * @static
7161 * @enum {string}
7162 */
7163 {
7164 /**
7165 * Event emitted after a test file has been loaded Not emitted in browser.
7166 */
7167 EVENT_FILE_POST_REQUIRE: 'post-require',
7168 /**
7169 * Event emitted before a test file has been loaded. In browser, this is emitted once an interface has been selected.
7170 */
7171 EVENT_FILE_PRE_REQUIRE: 'pre-require',
7172 /**
7173 * Event emitted immediately after a test file has been loaded. Not emitted in browser.
7174 */
7175 EVENT_FILE_REQUIRE: 'require',
7176 /**
7177 * Event emitted when `global.run()` is called (use with `delay` option)
7178 */
7179 EVENT_ROOT_SUITE_RUN: 'run',
7180
7181 /**
7182 * Namespace for collection of a `Suite`'s "after all" hooks
7183 */
7184 HOOK_TYPE_AFTER_ALL: 'afterAll',
7185 /**
7186 * Namespace for collection of a `Suite`'s "after each" hooks
7187 */
7188 HOOK_TYPE_AFTER_EACH: 'afterEach',
7189 /**
7190 * Namespace for collection of a `Suite`'s "before all" hooks
7191 */
7192 HOOK_TYPE_BEFORE_ALL: 'beforeAll',
7193 /**
7194 * Namespace for collection of a `Suite`'s "before all" hooks
7195 */
7196 HOOK_TYPE_BEFORE_EACH: 'beforeEach',
7197
7198 // the following events are all deprecated
7199
7200 /**
7201 * Emitted after an "after all" `Hook` has been added to a `Suite`. Deprecated
7202 */
7203 EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll',
7204 /**
7205 * Emitted after an "after each" `Hook` has been added to a `Suite` Deprecated
7206 */
7207 EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach',
7208 /**
7209 * Emitted after an "before all" `Hook` has been added to a `Suite` Deprecated
7210 */
7211 EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll',
7212 /**
7213 * Emitted after an "before each" `Hook` has been added to a `Suite` Deprecated
7214 */
7215 EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach',
7216 /**
7217 * Emitted after a child `Suite` has been added to a `Suite`. Deprecated
7218 */
7219 EVENT_SUITE_ADD_SUITE: 'suite',
7220 /**
7221 * Emitted after a `Test` has been added to a `Suite`. Deprecated
7222 */
7223 EVENT_SUITE_ADD_TEST: 'test'
7224 }
7225);
7226
7227/**
7228 * @summary There are no known use cases for these events.
7229 * @desc This is a `Set`-like object having all keys being the constant's string value and the value being `true`.
7230 * @todo Remove eventually
7231 * @type {Object<string,boolean>}
7232 * @ignore
7233 */
7234var deprecatedEvents = Object.keys(constants)
7235 .filter(function(constant) {
7236 return constant.substring(0, 15) === 'EVENT_SUITE_ADD';
7237 })
7238 .reduce(function(acc, constant) {
7239 acc[constants[constant]] = true;
7240 return acc;
7241 }, utils.createMap());
7242
7243Suite.constants = constants;
7244
7245},{"./errors":6,"./hook":7,"./utils":38,"debug":45,"events":50,"ms":60}],37:[function(require,module,exports){
7246'use strict';
7247var Runnable = require('./runnable');
7248var utils = require('./utils');
7249var errors = require('./errors');
7250var createInvalidArgumentTypeError = errors.createInvalidArgumentTypeError;
7251var isString = utils.isString;
7252
7253module.exports = Test;
7254
7255/**
7256 * Initialize a new `Test` with the given `title` and callback `fn`.
7257 *
7258 * @public
7259 * @class
7260 * @extends Runnable
7261 * @param {String} title - Test title (required)
7262 * @param {Function} [fn] - Test callback. If omitted, the Test is considered "pending"
7263 */
7264function Test(title, fn) {
7265 if (!isString(title)) {
7266 throw createInvalidArgumentTypeError(
7267 'Test argument "title" should be a string. Received type "' +
7268 typeof title +
7269 '"',
7270 'title',
7271 'string'
7272 );
7273 }
7274 Runnable.call(this, title, fn);
7275 this.pending = !fn;
7276 this.type = 'test';
7277}
7278
7279/**
7280 * Inherit from `Runnable.prototype`.
7281 */
7282utils.inherits(Test, Runnable);
7283
7284Test.prototype.clone = function() {
7285 var test = new Test(this.title, this.fn);
7286 test.timeout(this.timeout());
7287 test.slow(this.slow());
7288 test.enableTimeouts(this.enableTimeouts());
7289 test.retries(this.retries());
7290 test.currentRetry(this.currentRetry());
7291 test.globals(this.globals());
7292 test.parent = this.parent;
7293 test.file = this.file;
7294 test.ctx = this.ctx;
7295 return test;
7296};
7297
7298},{"./errors":6,"./runnable":33,"./utils":38}],38:[function(require,module,exports){
7299(function (process,Buffer){
7300'use strict';
7301
7302/**
7303 * Various utility functions used throughout Mocha's codebase.
7304 * @module utils
7305 */
7306
7307/**
7308 * Module dependencies.
7309 */
7310
7311var fs = require('fs');
7312var path = require('path');
7313var util = require('util');
7314var glob = require('glob');
7315var he = require('he');
7316var errors = require('./errors');
7317var createNoFilesMatchPatternError = errors.createNoFilesMatchPatternError;
7318var createMissingArgumentError = errors.createMissingArgumentError;
7319
7320var assign = (exports.assign = require('object.assign').getPolyfill());
7321
7322/**
7323 * Inherit the prototype methods from one constructor into another.
7324 *
7325 * @param {function} ctor - Constructor function which needs to inherit the
7326 * prototype.
7327 * @param {function} superCtor - Constructor function to inherit prototype from.
7328 * @throws {TypeError} if either constructor is null, or if super constructor
7329 * lacks a prototype.
7330 */
7331exports.inherits = util.inherits;
7332
7333/**
7334 * Escape special characters in the given string of html.
7335 *
7336 * @private
7337 * @param {string} html
7338 * @return {string}
7339 */
7340exports.escape = function(html) {
7341 return he.encode(String(html), {useNamedReferences: false});
7342};
7343
7344/**
7345 * Test if the given obj is type of string.
7346 *
7347 * @private
7348 * @param {Object} obj
7349 * @return {boolean}
7350 */
7351exports.isString = function(obj) {
7352 return typeof obj === 'string';
7353};
7354
7355/**
7356 * Watch the given `files` for changes
7357 * and invoke `fn(file)` on modification.
7358 *
7359 * @private
7360 * @param {Array} files
7361 * @param {Function} fn
7362 */
7363exports.watch = function(files, fn) {
7364 var options = {interval: 100};
7365 var debug = require('debug')('mocha:watch');
7366 files.forEach(function(file) {
7367 debug('file %s', file);
7368 fs.watchFile(file, options, function(curr, prev) {
7369 if (prev.mtime < curr.mtime) {
7370 fn(file);
7371 }
7372 });
7373 });
7374};
7375
7376/**
7377 * Predicate to screen `pathname` for further consideration.
7378 *
7379 * @description
7380 * Returns <code>false</code> for pathname referencing:
7381 * <ul>
7382 * <li>'npm' package installation directory
7383 * <li>'git' version control directory
7384 * </ul>
7385 *
7386 * @private
7387 * @param {string} pathname - File or directory name to screen
7388 * @return {boolean} whether pathname should be further considered
7389 * @example
7390 * ['node_modules', 'test.js'].filter(considerFurther); // => ['test.js']
7391 */
7392function considerFurther(pathname) {
7393 var ignore = ['node_modules', '.git'];
7394
7395 return !~ignore.indexOf(pathname);
7396}
7397
7398/**
7399 * Lookup files in the given `dir`.
7400 *
7401 * @description
7402 * Filenames are returned in _traversal_ order by the OS/filesystem.
7403 * **Make no assumption that the names will be sorted in any fashion.**
7404 *
7405 * @private
7406 * @param {string} dir
7407 * @param {string[]} [exts=['js']]
7408 * @param {Array} [ret=[]]
7409 * @return {Array}
7410 */
7411exports.files = function(dir, exts, ret) {
7412 ret = ret || [];
7413 exts = exts || ['js'];
7414
7415 fs.readdirSync(dir)
7416 .filter(considerFurther)
7417 .forEach(function(dirent) {
7418 var pathname = path.join(dir, dirent);
7419 if (fs.lstatSync(pathname).isDirectory()) {
7420 exports.files(pathname, exts, ret);
7421 } else if (hasMatchingExtname(pathname, exts)) {
7422 ret.push(pathname);
7423 }
7424 });
7425
7426 return ret;
7427};
7428
7429/**
7430 * Compute a slug from the given `str`.
7431 *
7432 * @private
7433 * @param {string} str
7434 * @return {string}
7435 */
7436exports.slug = function(str) {
7437 return str
7438 .toLowerCase()
7439 .replace(/ +/g, '-')
7440 .replace(/[^-\w]/g, '');
7441};
7442
7443/**
7444 * Strip the function definition from `str`, and re-indent for pre whitespace.
7445 *
7446 * @param {string} str
7447 * @return {string}
7448 */
7449exports.clean = function(str) {
7450 str = str
7451 .replace(/\r\n?|[\n\u2028\u2029]/g, '\n')
7452 .replace(/^\uFEFF/, '')
7453 // (traditional)-> space/name parameters body (lambda)-> parameters body multi-statement/single keep body content
7454 .replace(
7455 /^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/,
7456 '$1$2$3'
7457 );
7458
7459 var spaces = str.match(/^\n?( *)/)[1].length;
7460 var tabs = str.match(/^\n?(\t*)/)[1].length;
7461 var re = new RegExp(
7462 '^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}',
7463 'gm'
7464 );
7465
7466 str = str.replace(re, '');
7467
7468 return str.trim();
7469};
7470
7471/**
7472 * Parse the given `qs`.
7473 *
7474 * @private
7475 * @param {string} qs
7476 * @return {Object}
7477 */
7478exports.parseQuery = function(qs) {
7479 return qs
7480 .replace('?', '')
7481 .split('&')
7482 .reduce(function(obj, pair) {
7483 var i = pair.indexOf('=');
7484 var key = pair.slice(0, i);
7485 var val = pair.slice(++i);
7486
7487 // Due to how the URLSearchParams API treats spaces
7488 obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
7489
7490 return obj;
7491 }, {});
7492};
7493
7494/**
7495 * Highlight the given string of `js`.
7496 *
7497 * @private
7498 * @param {string} js
7499 * @return {string}
7500 */
7501function highlight(js) {
7502 return js
7503 .replace(/</g, '&lt;')
7504 .replace(/>/g, '&gt;')
7505 .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
7506 .replace(/('.*?')/gm, '<span class="string">$1</span>')
7507 .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
7508 .replace(/(\d+)/gm, '<span class="number">$1</span>')
7509 .replace(
7510 /\bnew[ \t]+(\w+)/gm,
7511 '<span class="keyword">new</span> <span class="init">$1</span>'
7512 )
7513 .replace(
7514 /\b(function|new|throw|return|var|if|else)\b/gm,
7515 '<span class="keyword">$1</span>'
7516 );
7517}
7518
7519/**
7520 * Highlight the contents of tag `name`.
7521 *
7522 * @private
7523 * @param {string} name
7524 */
7525exports.highlightTags = function(name) {
7526 var code = document.getElementById('mocha').getElementsByTagName(name);
7527 for (var i = 0, len = code.length; i < len; ++i) {
7528 code[i].innerHTML = highlight(code[i].innerHTML);
7529 }
7530};
7531
7532/**
7533 * If a value could have properties, and has none, this function is called,
7534 * which returns a string representation of the empty value.
7535 *
7536 * Functions w/ no properties return `'[Function]'`
7537 * Arrays w/ length === 0 return `'[]'`
7538 * Objects w/ no properties return `'{}'`
7539 * All else: return result of `value.toString()`
7540 *
7541 * @private
7542 * @param {*} value The value to inspect.
7543 * @param {string} typeHint The type of the value
7544 * @returns {string}
7545 */
7546function emptyRepresentation(value, typeHint) {
7547 switch (typeHint) {
7548 case 'function':
7549 return '[Function]';
7550 case 'object':
7551 return '{}';
7552 case 'array':
7553 return '[]';
7554 default:
7555 return value.toString();
7556 }
7557}
7558
7559/**
7560 * Takes some variable and asks `Object.prototype.toString()` what it thinks it
7561 * is.
7562 *
7563 * @private
7564 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
7565 * @param {*} value The value to test.
7566 * @returns {string} Computed type
7567 * @example
7568 * type({}) // 'object'
7569 * type([]) // 'array'
7570 * type(1) // 'number'
7571 * type(false) // 'boolean'
7572 * type(Infinity) // 'number'
7573 * type(null) // 'null'
7574 * type(new Date()) // 'date'
7575 * type(/foo/) // 'regexp'
7576 * type('type') // 'string'
7577 * type(global) // 'global'
7578 * type(new String('foo') // 'object'
7579 */
7580var type = (exports.type = function type(value) {
7581 if (value === undefined) {
7582 return 'undefined';
7583 } else if (value === null) {
7584 return 'null';
7585 } else if (Buffer.isBuffer(value)) {
7586 return 'buffer';
7587 }
7588 return Object.prototype.toString
7589 .call(value)
7590 .replace(/^\[.+\s(.+?)]$/, '$1')
7591 .toLowerCase();
7592});
7593
7594/**
7595 * Stringify `value`. Different behavior depending on type of value:
7596 *
7597 * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
7598 * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
7599 * - If `value` is an *empty* object, function, or array, return result of function
7600 * {@link emptyRepresentation}.
7601 * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
7602 * JSON.stringify().
7603 *
7604 * @private
7605 * @see exports.type
7606 * @param {*} value
7607 * @return {string}
7608 */
7609exports.stringify = function(value) {
7610 var typeHint = type(value);
7611
7612 if (!~['object', 'array', 'function'].indexOf(typeHint)) {
7613 if (typeHint === 'buffer') {
7614 var json = Buffer.prototype.toJSON.call(value);
7615 // Based on the toJSON result
7616 return jsonStringify(
7617 json.data && json.type ? json.data : json,
7618 2
7619 ).replace(/,(\n|$)/g, '$1');
7620 }
7621
7622 // IE7/IE8 has a bizarre String constructor; needs to be coerced
7623 // into an array and back to obj.
7624 if (typeHint === 'string' && typeof value === 'object') {
7625 value = value.split('').reduce(function(acc, char, idx) {
7626 acc[idx] = char;
7627 return acc;
7628 }, {});
7629 typeHint = 'object';
7630 } else {
7631 return jsonStringify(value);
7632 }
7633 }
7634
7635 for (var prop in value) {
7636 if (Object.prototype.hasOwnProperty.call(value, prop)) {
7637 return jsonStringify(
7638 exports.canonicalize(value, null, typeHint),
7639 2
7640 ).replace(/,(\n|$)/g, '$1');
7641 }
7642 }
7643
7644 return emptyRepresentation(value, typeHint);
7645};
7646
7647/**
7648 * like JSON.stringify but more sense.
7649 *
7650 * @private
7651 * @param {Object} object
7652 * @param {number=} spaces
7653 * @param {number=} depth
7654 * @returns {*}
7655 */
7656function jsonStringify(object, spaces, depth) {
7657 if (typeof spaces === 'undefined') {
7658 // primitive types
7659 return _stringify(object);
7660 }
7661
7662 depth = depth || 1;
7663 var space = spaces * depth;
7664 var str = Array.isArray(object) ? '[' : '{';
7665 var end = Array.isArray(object) ? ']' : '}';
7666 var length =
7667 typeof object.length === 'number'
7668 ? object.length
7669 : Object.keys(object).length;
7670 // `.repeat()` polyfill
7671 function repeat(s, n) {
7672 return new Array(n).join(s);
7673 }
7674
7675 function _stringify(val) {
7676 switch (type(val)) {
7677 case 'null':
7678 case 'undefined':
7679 val = '[' + val + ']';
7680 break;
7681 case 'array':
7682 case 'object':
7683 val = jsonStringify(val, spaces, depth + 1);
7684 break;
7685 case 'boolean':
7686 case 'regexp':
7687 case 'symbol':
7688 case 'number':
7689 val =
7690 val === 0 && 1 / val === -Infinity // `-0`
7691 ? '-0'
7692 : val.toString();
7693 break;
7694 case 'date':
7695 var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
7696 val = '[Date: ' + sDate + ']';
7697 break;
7698 case 'buffer':
7699 var json = val.toJSON();
7700 // Based on the toJSON result
7701 json = json.data && json.type ? json.data : json;
7702 val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
7703 break;
7704 default:
7705 val =
7706 val === '[Function]' || val === '[Circular]'
7707 ? val
7708 : JSON.stringify(val); // string
7709 }
7710 return val;
7711 }
7712
7713 for (var i in object) {
7714 if (!Object.prototype.hasOwnProperty.call(object, i)) {
7715 continue; // not my business
7716 }
7717 --length;
7718 str +=
7719 '\n ' +
7720 repeat(' ', space) +
7721 (Array.isArray(object) ? '' : '"' + i + '": ') + // key
7722 _stringify(object[i]) + // value
7723 (length ? ',' : ''); // comma
7724 }
7725
7726 return (
7727 str +
7728 // [], {}
7729 (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end)
7730 );
7731}
7732
7733/**
7734 * Return a new Thing that has the keys in sorted order. Recursive.
7735 *
7736 * If the Thing...
7737 * - has already been seen, return string `'[Circular]'`
7738 * - is `undefined`, return string `'[undefined]'`
7739 * - is `null`, return value `null`
7740 * - is some other primitive, return the value
7741 * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
7742 * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
7743 * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
7744 *
7745 * @private
7746 * @see {@link exports.stringify}
7747 * @param {*} value Thing to inspect. May or may not have properties.
7748 * @param {Array} [stack=[]] Stack of seen values
7749 * @param {string} [typeHint] Type hint
7750 * @return {(Object|Array|Function|string|undefined)}
7751 */
7752exports.canonicalize = function canonicalize(value, stack, typeHint) {
7753 var canonicalizedObj;
7754 /* eslint-disable no-unused-vars */
7755 var prop;
7756 /* eslint-enable no-unused-vars */
7757 typeHint = typeHint || type(value);
7758 function withStack(value, fn) {
7759 stack.push(value);
7760 fn();
7761 stack.pop();
7762 }
7763
7764 stack = stack || [];
7765
7766 if (stack.indexOf(value) !== -1) {
7767 return '[Circular]';
7768 }
7769
7770 switch (typeHint) {
7771 case 'undefined':
7772 case 'buffer':
7773 case 'null':
7774 canonicalizedObj = value;
7775 break;
7776 case 'array':
7777 withStack(value, function() {
7778 canonicalizedObj = value.map(function(item) {
7779 return exports.canonicalize(item, stack);
7780 });
7781 });
7782 break;
7783 case 'function':
7784 /* eslint-disable guard-for-in */
7785 for (prop in value) {
7786 canonicalizedObj = {};
7787 break;
7788 }
7789 /* eslint-enable guard-for-in */
7790 if (!canonicalizedObj) {
7791 canonicalizedObj = emptyRepresentation(value, typeHint);
7792 break;
7793 }
7794 /* falls through */
7795 case 'object':
7796 canonicalizedObj = canonicalizedObj || {};
7797 withStack(value, function() {
7798 Object.keys(value)
7799 .sort()
7800 .forEach(function(key) {
7801 canonicalizedObj[key] = exports.canonicalize(value[key], stack);
7802 });
7803 });
7804 break;
7805 case 'date':
7806 case 'number':
7807 case 'regexp':
7808 case 'boolean':
7809 case 'symbol':
7810 canonicalizedObj = value;
7811 break;
7812 default:
7813 canonicalizedObj = value + '';
7814 }
7815
7816 return canonicalizedObj;
7817};
7818
7819/**
7820 * Determines if pathname has a matching file extension.
7821 *
7822 * @private
7823 * @param {string} pathname - Pathname to check for match.
7824 * @param {string[]} exts - List of file extensions (sans period).
7825 * @return {boolean} whether file extension matches.
7826 * @example
7827 * hasMatchingExtname('foo.html', ['js', 'css']); // => false
7828 */
7829function hasMatchingExtname(pathname, exts) {
7830 var suffix = path.extname(pathname).slice(1);
7831 return exts.some(function(element) {
7832 return suffix === element;
7833 });
7834}
7835
7836/**
7837 * Determines if pathname would be a "hidden" file (or directory) on UN*X.
7838 *
7839 * @description
7840 * On UN*X, pathnames beginning with a full stop (aka dot) are hidden during
7841 * typical usage. Dotfiles, plain-text configuration files, are prime examples.
7842 *
7843 * @see {@link http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html|Origin of Dot File Names}
7844 *
7845 * @private
7846 * @param {string} pathname - Pathname to check for match.
7847 * @return {boolean} whether pathname would be considered a hidden file.
7848 * @example
7849 * isHiddenOnUnix('.profile'); // => true
7850 */
7851function isHiddenOnUnix(pathname) {
7852 return path.basename(pathname)[0] === '.';
7853}
7854
7855/**
7856 * Lookup file names at the given `path`.
7857 *
7858 * @description
7859 * Filenames are returned in _traversal_ order by the OS/filesystem.
7860 * **Make no assumption that the names will be sorted in any fashion.**
7861 *
7862 * @public
7863 * @memberof Mocha.utils
7864 * @param {string} filepath - Base path to start searching from.
7865 * @param {string[]} [extensions=[]] - File extensions to look for.
7866 * @param {boolean} [recursive=false] - Whether to recurse into subdirectories.
7867 * @return {string[]} An array of paths.
7868 * @throws {Error} if no files match pattern.
7869 * @throws {TypeError} if `filepath` is directory and `extensions` not provided.
7870 */
7871exports.lookupFiles = function lookupFiles(filepath, extensions, recursive) {
7872 extensions = extensions || [];
7873 recursive = recursive || false;
7874 var files = [];
7875 var stat;
7876
7877 if (!fs.existsSync(filepath)) {
7878 var pattern;
7879 if (glob.hasMagic(filepath)) {
7880 // Handle glob as is without extensions
7881 pattern = filepath;
7882 } else {
7883 // glob pattern e.g. 'filepath+(.js|.ts)'
7884 var strExtensions = extensions
7885 .map(function(v) {
7886 return '.' + v;
7887 })
7888 .join('|');
7889 pattern = filepath + '+(' + strExtensions + ')';
7890 }
7891 files = glob.sync(pattern, {nodir: true});
7892 if (!files.length) {
7893 throw createNoFilesMatchPatternError(
7894 'Cannot find any files matching pattern ' + exports.dQuote(filepath),
7895 filepath
7896 );
7897 }
7898 return files;
7899 }
7900
7901 // Handle file
7902 try {
7903 stat = fs.statSync(filepath);
7904 if (stat.isFile()) {
7905 return filepath;
7906 }
7907 } catch (err) {
7908 // ignore error
7909 return;
7910 }
7911
7912 // Handle directory
7913 fs.readdirSync(filepath).forEach(function(dirent) {
7914 var pathname = path.join(filepath, dirent);
7915 var stat;
7916
7917 try {
7918 stat = fs.statSync(pathname);
7919 if (stat.isDirectory()) {
7920 if (recursive) {
7921 files = files.concat(lookupFiles(pathname, extensions, recursive));
7922 }
7923 return;
7924 }
7925 } catch (err) {
7926 // ignore error
7927 return;
7928 }
7929 if (!extensions.length) {
7930 throw createMissingArgumentError(
7931 util.format(
7932 'Argument %s required when argument %s is a directory',
7933 exports.sQuote('extensions'),
7934 exports.sQuote('filepath')
7935 ),
7936 'extensions',
7937 'array'
7938 );
7939 }
7940
7941 if (
7942 !stat.isFile() ||
7943 !hasMatchingExtname(pathname, extensions) ||
7944 isHiddenOnUnix(pathname)
7945 ) {
7946 return;
7947 }
7948 files.push(pathname);
7949 });
7950
7951 return files;
7952};
7953
7954/**
7955 * process.emitWarning or a polyfill
7956 * @see https://nodejs.org/api/process.html#process_process_emitwarning_warning_options
7957 * @ignore
7958 */
7959function emitWarning(msg, type) {
7960 if (process.emitWarning) {
7961 process.emitWarning(msg, type);
7962 } else {
7963 process.nextTick(function() {
7964 console.warn(type + ': ' + msg);
7965 });
7966 }
7967}
7968
7969/**
7970 * Show a deprecation warning. Each distinct message is only displayed once.
7971 * Ignores empty messages.
7972 *
7973 * @param {string} [msg] - Warning to print
7974 * @private
7975 */
7976exports.deprecate = function deprecate(msg) {
7977 msg = String(msg);
7978 if (msg && !deprecate.cache[msg]) {
7979 deprecate.cache[msg] = true;
7980 emitWarning(msg, 'DeprecationWarning');
7981 }
7982};
7983exports.deprecate.cache = {};
7984
7985/**
7986 * Show a generic warning.
7987 * Ignores empty messages.
7988 *
7989 * @param {string} [msg] - Warning to print
7990 * @private
7991 */
7992exports.warn = function warn(msg) {
7993 if (msg) {
7994 emitWarning(msg);
7995 }
7996};
7997
7998/**
7999 * @summary
8000 * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
8001 * @description
8002 * When invoking this function you get a filter function that get the Error.stack as an input,
8003 * and return a prettify output.
8004 * (i.e: strip Mocha and internal node functions from stack trace).
8005 * @returns {Function}
8006 */
8007exports.stackTraceFilter = function() {
8008 // TODO: Replace with `process.browser`
8009 var is = typeof document === 'undefined' ? {node: true} : {browser: true};
8010 var slash = path.sep;
8011 var cwd;
8012 if (is.node) {
8013 cwd = process.cwd() + slash;
8014 } else {
8015 cwd = (typeof location === 'undefined'
8016 ? window.location
8017 : location
8018 ).href.replace(/\/[^/]*$/, '/');
8019 slash = '/';
8020 }
8021
8022 function isMochaInternal(line) {
8023 return (
8024 ~line.indexOf('node_modules' + slash + 'mocha' + slash) ||
8025 ~line.indexOf(slash + 'mocha.js') ||
8026 ~line.indexOf(slash + 'mocha.min.js')
8027 );
8028 }
8029
8030 function isNodeInternal(line) {
8031 return (
8032 ~line.indexOf('(timers.js:') ||
8033 ~line.indexOf('(events.js:') ||
8034 ~line.indexOf('(node.js:') ||
8035 ~line.indexOf('(module.js:') ||
8036 ~line.indexOf('GeneratorFunctionPrototype.next (native)') ||
8037 false
8038 );
8039 }
8040
8041 return function(stack) {
8042 stack = stack.split('\n');
8043
8044 stack = stack.reduce(function(list, line) {
8045 if (isMochaInternal(line)) {
8046 return list;
8047 }
8048
8049 if (is.node && isNodeInternal(line)) {
8050 return list;
8051 }
8052
8053 // Clean up cwd(absolute)
8054 if (/:\d+:\d+\)?$/.test(line)) {
8055 line = line.replace('(' + cwd, '(');
8056 }
8057
8058 list.push(line);
8059 return list;
8060 }, []);
8061
8062 return stack.join('\n');
8063 };
8064};
8065
8066/**
8067 * Crude, but effective.
8068 * @public
8069 * @param {*} value
8070 * @returns {boolean} Whether or not `value` is a Promise
8071 */
8072exports.isPromise = function isPromise(value) {
8073 return (
8074 typeof value === 'object' &&
8075 value !== null &&
8076 typeof value.then === 'function'
8077 );
8078};
8079
8080/**
8081 * Clamps a numeric value to an inclusive range.
8082 *
8083 * @param {number} value - Value to be clamped.
8084 * @param {numer[]} range - Two element array specifying [min, max] range.
8085 * @returns {number} clamped value
8086 */
8087exports.clamp = function clamp(value, range) {
8088 return Math.min(Math.max(value, range[0]), range[1]);
8089};
8090
8091/**
8092 * Single quote text by combining with undirectional ASCII quotation marks.
8093 *
8094 * @description
8095 * Provides a simple means of markup for quoting text to be used in output.
8096 * Use this to quote names of variables, methods, and packages.
8097 *
8098 * <samp>package 'foo' cannot be found</samp>
8099 *
8100 * @private
8101 * @param {string} str - Value to be quoted.
8102 * @returns {string} quoted value
8103 * @example
8104 * sQuote('n') // => 'n'
8105 */
8106exports.sQuote = function(str) {
8107 return "'" + str + "'";
8108};
8109
8110/**
8111 * Double quote text by combining with undirectional ASCII quotation marks.
8112 *
8113 * @description
8114 * Provides a simple means of markup for quoting text to be used in output.
8115 * Use this to quote names of datatypes, classes, pathnames, and strings.
8116 *
8117 * <samp>argument 'value' must be "string" or "number"</samp>
8118 *
8119 * @private
8120 * @param {string} str - Value to be quoted.
8121 * @returns {string} quoted value
8122 * @example
8123 * dQuote('number') // => "number"
8124 */
8125exports.dQuote = function(str) {
8126 return '"' + str + '"';
8127};
8128
8129/**
8130 * Provides simplistic message translation for dealing with plurality.
8131 *
8132 * @description
8133 * Use this to create messages which need to be singular or plural.
8134 * Some languages have several plural forms, so _complete_ message clauses
8135 * are preferable to generating the message on the fly.
8136 *
8137 * @private
8138 * @param {number} n - Non-negative integer
8139 * @param {string} msg1 - Message to be used in English for `n = 1`
8140 * @param {string} msg2 - Message to be used in English for `n = 0, 2, 3, ...`
8141 * @returns {string} message corresponding to value of `n`
8142 * @example
8143 * var sprintf = require('util').format;
8144 * var pkgs = ['one', 'two'];
8145 * var msg = sprintf(
8146 * ngettext(
8147 * pkgs.length,
8148 * 'cannot load package: %s',
8149 * 'cannot load packages: %s'
8150 * ),
8151 * pkgs.map(sQuote).join(', ')
8152 * );
8153 * console.log(msg); // => cannot load packages: 'one', 'two'
8154 */
8155exports.ngettext = function(n, msg1, msg2) {
8156 if (typeof n === 'number' && n >= 0) {
8157 return n === 1 ? msg1 : msg2;
8158 }
8159};
8160
8161/**
8162 * It's a noop.
8163 * @public
8164 */
8165exports.noop = function() {};
8166
8167/**
8168 * Creates a map-like object.
8169 *
8170 * @description
8171 * A "map" is an object with no prototype, for our purposes. In some cases
8172 * this would be more appropriate than a `Map`, especially if your environment
8173 * doesn't support it. Recommended for use in Mocha's public APIs.
8174 *
8175 * @public
8176 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map|MDN:Map}
8177 * @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}
8178 * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign|MDN:Object.assign}
8179 * @param {...*} [obj] - Arguments to `Object.assign()`.
8180 * @returns {Object} An object with no prototype, having `...obj` properties
8181 */
8182exports.createMap = function(obj) {
8183 return assign.apply(
8184 null,
8185 [Object.create(null)].concat(Array.prototype.slice.call(arguments))
8186 );
8187};
8188
8189/**
8190 * Creates a read-only map-like object.
8191 *
8192 * @description
8193 * This differs from {@link module:utils.createMap createMap} only in that
8194 * the argument must be non-empty, because the result is frozen.
8195 *
8196 * @see {@link module:utils.createMap createMap}
8197 * @param {...*} [obj] - Arguments to `Object.assign()`.
8198 * @returns {Object} A frozen object with no prototype, having `...obj` properties
8199 * @throws {TypeError} if argument is not a non-empty object.
8200 */
8201exports.defineConstants = function(obj) {
8202 if (type(obj) !== 'object' || !Object.keys(obj).length) {
8203 throw new TypeError('Invalid argument; expected a non-empty object');
8204 }
8205 return Object.freeze(exports.createMap(obj));
8206};
8207
8208}).call(this,require('_process'),require("buffer").Buffer)
8209},{"./errors":6,"_process":69,"buffer":43,"debug":45,"fs":42,"glob":42,"he":54,"object.assign":65,"path":42,"util":89}],39:[function(require,module,exports){
8210'use strict'
8211
8212exports.byteLength = byteLength
8213exports.toByteArray = toByteArray
8214exports.fromByteArray = fromByteArray
8215
8216var lookup = []
8217var revLookup = []
8218var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
8219
8220var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
8221for (var i = 0, len = code.length; i < len; ++i) {
8222 lookup[i] = code[i]
8223 revLookup[code.charCodeAt(i)] = i
8224}
8225
8226// Support decoding URL-safe base64 strings, as Node.js does.
8227// See: https://en.wikipedia.org/wiki/Base64#URL_applications
8228revLookup['-'.charCodeAt(0)] = 62
8229revLookup['_'.charCodeAt(0)] = 63
8230
8231function getLens (b64) {
8232 var len = b64.length
8233
8234 if (len % 4 > 0) {
8235 throw new Error('Invalid string. Length must be a multiple of 4')
8236 }
8237
8238 // Trim off extra bytes after placeholder bytes are found
8239 // See: https://github.com/beatgammit/base64-js/issues/42
8240 var validLen = b64.indexOf('=')
8241 if (validLen === -1) validLen = len
8242
8243 var placeHoldersLen = validLen === len
8244 ? 0
8245 : 4 - (validLen % 4)
8246
8247 return [validLen, placeHoldersLen]
8248}
8249
8250// base64 is 4/3 + up to two characters of the original data
8251function byteLength (b64) {
8252 var lens = getLens(b64)
8253 var validLen = lens[0]
8254 var placeHoldersLen = lens[1]
8255 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
8256}
8257
8258function _byteLength (b64, validLen, placeHoldersLen) {
8259 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
8260}
8261
8262function toByteArray (b64) {
8263 var tmp
8264 var lens = getLens(b64)
8265 var validLen = lens[0]
8266 var placeHoldersLen = lens[1]
8267
8268 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
8269
8270 var curByte = 0
8271
8272 // if there are placeholders, only get up to the last complete 4 chars
8273 var len = placeHoldersLen > 0
8274 ? validLen - 4
8275 : validLen
8276
8277 for (var i = 0; i < len; i += 4) {
8278 tmp =
8279 (revLookup[b64.charCodeAt(i)] << 18) |
8280 (revLookup[b64.charCodeAt(i + 1)] << 12) |
8281 (revLookup[b64.charCodeAt(i + 2)] << 6) |
8282 revLookup[b64.charCodeAt(i + 3)]
8283 arr[curByte++] = (tmp >> 16) & 0xFF
8284 arr[curByte++] = (tmp >> 8) & 0xFF
8285 arr[curByte++] = tmp & 0xFF
8286 }
8287
8288 if (placeHoldersLen === 2) {
8289 tmp =
8290 (revLookup[b64.charCodeAt(i)] << 2) |
8291 (revLookup[b64.charCodeAt(i + 1)] >> 4)
8292 arr[curByte++] = tmp & 0xFF
8293 }
8294
8295 if (placeHoldersLen === 1) {
8296 tmp =
8297 (revLookup[b64.charCodeAt(i)] << 10) |
8298 (revLookup[b64.charCodeAt(i + 1)] << 4) |
8299 (revLookup[b64.charCodeAt(i + 2)] >> 2)
8300 arr[curByte++] = (tmp >> 8) & 0xFF
8301 arr[curByte++] = tmp & 0xFF
8302 }
8303
8304 return arr
8305}
8306
8307function tripletToBase64 (num) {
8308 return lookup[num >> 18 & 0x3F] +
8309 lookup[num >> 12 & 0x3F] +
8310 lookup[num >> 6 & 0x3F] +
8311 lookup[num & 0x3F]
8312}
8313
8314function encodeChunk (uint8, start, end) {
8315 var tmp
8316 var output = []
8317 for (var i = start; i < end; i += 3) {
8318 tmp =
8319 ((uint8[i] << 16) & 0xFF0000) +
8320 ((uint8[i + 1] << 8) & 0xFF00) +
8321 (uint8[i + 2] & 0xFF)
8322 output.push(tripletToBase64(tmp))
8323 }
8324 return output.join('')
8325}
8326
8327function fromByteArray (uint8) {
8328 var tmp
8329 var len = uint8.length
8330 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
8331 var parts = []
8332 var maxChunkLength = 16383 // must be multiple of 3
8333
8334 // go through the array every three bytes, we'll deal with trailing stuff later
8335 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
8336 parts.push(encodeChunk(
8337 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
8338 ))
8339 }
8340
8341 // pad the end with zeros, but make sure to not forget the extra bytes
8342 if (extraBytes === 1) {
8343 tmp = uint8[len - 1]
8344 parts.push(
8345 lookup[tmp >> 2] +
8346 lookup[(tmp << 4) & 0x3F] +
8347 '=='
8348 )
8349 } else if (extraBytes === 2) {
8350 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
8351 parts.push(
8352 lookup[tmp >> 10] +
8353 lookup[(tmp >> 4) & 0x3F] +
8354 lookup[(tmp << 2) & 0x3F] +
8355 '='
8356 )
8357 }
8358
8359 return parts.join('')
8360}
8361
8362},{}],40:[function(require,module,exports){
8363
8364},{}],41:[function(require,module,exports){
8365(function (process){
8366var WritableStream = require('stream').Writable
8367var inherits = require('util').inherits
8368
8369module.exports = BrowserStdout
8370
8371
8372inherits(BrowserStdout, WritableStream)
8373
8374function BrowserStdout(opts) {
8375 if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
8376
8377 opts = opts || {}
8378 WritableStream.call(this, opts)
8379 this.label = (opts.label !== undefined) ? opts.label : 'stdout'
8380}
8381
8382BrowserStdout.prototype._write = function(chunks, encoding, cb) {
8383 var output = chunks.toString ? chunks.toString() : chunks
8384 if (this.label === false) {
8385 console.log(output)
8386 } else {
8387 console.log(this.label+':', output)
8388 }
8389 process.nextTick(cb)
8390}
8391
8392}).call(this,require('_process'))
8393},{"_process":69,"stream":84,"util":89}],42:[function(require,module,exports){
8394arguments[4][40][0].apply(exports,arguments)
8395},{"dup":40}],43:[function(require,module,exports){
8396(function (Buffer){
8397/*!
8398 * The buffer module from node.js, for the browser.
8399 *
8400 * @author Feross Aboukhadijeh <https://feross.org>
8401 * @license MIT
8402 */
8403/* eslint-disable no-proto */
8404
8405'use strict'
8406
8407var base64 = require('base64-js')
8408var ieee754 = require('ieee754')
8409
8410exports.Buffer = Buffer
8411exports.SlowBuffer = SlowBuffer
8412exports.INSPECT_MAX_BYTES = 50
8413
8414var K_MAX_LENGTH = 0x7fffffff
8415exports.kMaxLength = K_MAX_LENGTH
8416
8417/**
8418 * If `Buffer.TYPED_ARRAY_SUPPORT`:
8419 * === true Use Uint8Array implementation (fastest)
8420 * === false Print warning and recommend using `buffer` v4.x which has an Object
8421 * implementation (most compatible, even IE6)
8422 *
8423 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
8424 * Opera 11.6+, iOS 4.2+.
8425 *
8426 * We report that the browser does not support typed arrays if the are not subclassable
8427 * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
8428 * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
8429 * for __proto__ and has a buggy typed array implementation.
8430 */
8431Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
8432
8433if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
8434 typeof console.error === 'function') {
8435 console.error(
8436 'This browser lacks typed array (Uint8Array) support which is required by ' +
8437 '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
8438 )
8439}
8440
8441function typedArraySupport () {
8442 // Can typed array instances can be augmented?
8443 try {
8444 var arr = new Uint8Array(1)
8445 arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
8446 return arr.foo() === 42
8447 } catch (e) {
8448 return false
8449 }
8450}
8451
8452Object.defineProperty(Buffer.prototype, 'parent', {
8453 enumerable: true,
8454 get: function () {
8455 if (!Buffer.isBuffer(this)) return undefined
8456 return this.buffer
8457 }
8458})
8459
8460Object.defineProperty(Buffer.prototype, 'offset', {
8461 enumerable: true,
8462 get: function () {
8463 if (!Buffer.isBuffer(this)) return undefined
8464 return this.byteOffset
8465 }
8466})
8467
8468function createBuffer (length) {
8469 if (length > K_MAX_LENGTH) {
8470 throw new RangeError('The value "' + length + '" is invalid for option "size"')
8471 }
8472 // Return an augmented `Uint8Array` instance
8473 var buf = new Uint8Array(length)
8474 buf.__proto__ = Buffer.prototype
8475 return buf
8476}
8477
8478/**
8479 * The Buffer constructor returns instances of `Uint8Array` that have their
8480 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
8481 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
8482 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
8483 * returns a single octet.
8484 *
8485 * The `Uint8Array` prototype remains unmodified.
8486 */
8487
8488function Buffer (arg, encodingOrOffset, length) {
8489 // Common case.
8490 if (typeof arg === 'number') {
8491 if (typeof encodingOrOffset === 'string') {
8492 throw new TypeError(
8493 'The "string" argument must be of type string. Received type number'
8494 )
8495 }
8496 return allocUnsafe(arg)
8497 }
8498 return from(arg, encodingOrOffset, length)
8499}
8500
8501// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
8502if (typeof Symbol !== 'undefined' && Symbol.species != null &&
8503 Buffer[Symbol.species] === Buffer) {
8504 Object.defineProperty(Buffer, Symbol.species, {
8505 value: null,
8506 configurable: true,
8507 enumerable: false,
8508 writable: false
8509 })
8510}
8511
8512Buffer.poolSize = 8192 // not used by this implementation
8513
8514function from (value, encodingOrOffset, length) {
8515 if (typeof value === 'string') {
8516 return fromString(value, encodingOrOffset)
8517 }
8518
8519 if (ArrayBuffer.isView(value)) {
8520 return fromArrayLike(value)
8521 }
8522
8523 if (value == null) {
8524 throw TypeError(
8525 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
8526 'or Array-like Object. Received type ' + (typeof value)
8527 )
8528 }
8529
8530 if (isInstance(value, ArrayBuffer) ||
8531 (value && isInstance(value.buffer, ArrayBuffer))) {
8532 return fromArrayBuffer(value, encodingOrOffset, length)
8533 }
8534
8535 if (typeof value === 'number') {
8536 throw new TypeError(
8537 'The "value" argument must not be of type number. Received type number'
8538 )
8539 }
8540
8541 var valueOf = value.valueOf && value.valueOf()
8542 if (valueOf != null && valueOf !== value) {
8543 return Buffer.from(valueOf, encodingOrOffset, length)
8544 }
8545
8546 var b = fromObject(value)
8547 if (b) return b
8548
8549 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
8550 typeof value[Symbol.toPrimitive] === 'function') {
8551 return Buffer.from(
8552 value[Symbol.toPrimitive]('string'), encodingOrOffset, length
8553 )
8554 }
8555
8556 throw new TypeError(
8557 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
8558 'or Array-like Object. Received type ' + (typeof value)
8559 )
8560}
8561
8562/**
8563 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
8564 * if value is a number.
8565 * Buffer.from(str[, encoding])
8566 * Buffer.from(array)
8567 * Buffer.from(buffer)
8568 * Buffer.from(arrayBuffer[, byteOffset[, length]])
8569 **/
8570Buffer.from = function (value, encodingOrOffset, length) {
8571 return from(value, encodingOrOffset, length)
8572}
8573
8574// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
8575// https://github.com/feross/buffer/pull/148
8576Buffer.prototype.__proto__ = Uint8Array.prototype
8577Buffer.__proto__ = Uint8Array
8578
8579function assertSize (size) {
8580 if (typeof size !== 'number') {
8581 throw new TypeError('"size" argument must be of type number')
8582 } else if (size < 0) {
8583 throw new RangeError('The value "' + size + '" is invalid for option "size"')
8584 }
8585}
8586
8587function alloc (size, fill, encoding) {
8588 assertSize(size)
8589 if (size <= 0) {
8590 return createBuffer(size)
8591 }
8592 if (fill !== undefined) {
8593 // Only pay attention to encoding if it's a string. This
8594 // prevents accidentally sending in a number that would
8595 // be interpretted as a start offset.
8596 return typeof encoding === 'string'
8597 ? createBuffer(size).fill(fill, encoding)
8598 : createBuffer(size).fill(fill)
8599 }
8600 return createBuffer(size)
8601}
8602
8603/**
8604 * Creates a new filled Buffer instance.
8605 * alloc(size[, fill[, encoding]])
8606 **/
8607Buffer.alloc = function (size, fill, encoding) {
8608 return alloc(size, fill, encoding)
8609}
8610
8611function allocUnsafe (size) {
8612 assertSize(size)
8613 return createBuffer(size < 0 ? 0 : checked(size) | 0)
8614}
8615
8616/**
8617 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
8618 * */
8619Buffer.allocUnsafe = function (size) {
8620 return allocUnsafe(size)
8621}
8622/**
8623 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
8624 */
8625Buffer.allocUnsafeSlow = function (size) {
8626 return allocUnsafe(size)
8627}
8628
8629function fromString (string, encoding) {
8630 if (typeof encoding !== 'string' || encoding === '') {
8631 encoding = 'utf8'
8632 }
8633
8634 if (!Buffer.isEncoding(encoding)) {
8635 throw new TypeError('Unknown encoding: ' + encoding)
8636 }
8637
8638 var length = byteLength(string, encoding) | 0
8639 var buf = createBuffer(length)
8640
8641 var actual = buf.write(string, encoding)
8642
8643 if (actual !== length) {
8644 // Writing a hex string, for example, that contains invalid characters will
8645 // cause everything after the first invalid character to be ignored. (e.g.
8646 // 'abxxcd' will be treated as 'ab')
8647 buf = buf.slice(0, actual)
8648 }
8649
8650 return buf
8651}
8652
8653function fromArrayLike (array) {
8654 var length = array.length < 0 ? 0 : checked(array.length) | 0
8655 var buf = createBuffer(length)
8656 for (var i = 0; i < length; i += 1) {
8657 buf[i] = array[i] & 255
8658 }
8659 return buf
8660}
8661
8662function fromArrayBuffer (array, byteOffset, length) {
8663 if (byteOffset < 0 || array.byteLength < byteOffset) {
8664 throw new RangeError('"offset" is outside of buffer bounds')
8665 }
8666
8667 if (array.byteLength < byteOffset + (length || 0)) {
8668 throw new RangeError('"length" is outside of buffer bounds')
8669 }
8670
8671 var buf
8672 if (byteOffset === undefined && length === undefined) {
8673 buf = new Uint8Array(array)
8674 } else if (length === undefined) {
8675 buf = new Uint8Array(array, byteOffset)
8676 } else {
8677 buf = new Uint8Array(array, byteOffset, length)
8678 }
8679
8680 // Return an augmented `Uint8Array` instance
8681 buf.__proto__ = Buffer.prototype
8682 return buf
8683}
8684
8685function fromObject (obj) {
8686 if (Buffer.isBuffer(obj)) {
8687 var len = checked(obj.length) | 0
8688 var buf = createBuffer(len)
8689
8690 if (buf.length === 0) {
8691 return buf
8692 }
8693
8694 obj.copy(buf, 0, 0, len)
8695 return buf
8696 }
8697
8698 if (obj.length !== undefined) {
8699 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
8700 return createBuffer(0)
8701 }
8702 return fromArrayLike(obj)
8703 }
8704
8705 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
8706 return fromArrayLike(obj.data)
8707 }
8708}
8709
8710function checked (length) {
8711 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
8712 // length is NaN (which is otherwise coerced to zero.)
8713 if (length >= K_MAX_LENGTH) {
8714 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
8715 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
8716 }
8717 return length | 0
8718}
8719
8720function SlowBuffer (length) {
8721 if (+length != length) { // eslint-disable-line eqeqeq
8722 length = 0
8723 }
8724 return Buffer.alloc(+length)
8725}
8726
8727Buffer.isBuffer = function isBuffer (b) {
8728 return b != null && b._isBuffer === true &&
8729 b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
8730}
8731
8732Buffer.compare = function compare (a, b) {
8733 if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
8734 if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
8735 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
8736 throw new TypeError(
8737 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
8738 )
8739 }
8740
8741 if (a === b) return 0
8742
8743 var x = a.length
8744 var y = b.length
8745
8746 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
8747 if (a[i] !== b[i]) {
8748 x = a[i]
8749 y = b[i]
8750 break
8751 }
8752 }
8753
8754 if (x < y) return -1
8755 if (y < x) return 1
8756 return 0
8757}
8758
8759Buffer.isEncoding = function isEncoding (encoding) {
8760 switch (String(encoding).toLowerCase()) {
8761 case 'hex':
8762 case 'utf8':
8763 case 'utf-8':
8764 case 'ascii':
8765 case 'latin1':
8766 case 'binary':
8767 case 'base64':
8768 case 'ucs2':
8769 case 'ucs-2':
8770 case 'utf16le':
8771 case 'utf-16le':
8772 return true
8773 default:
8774 return false
8775 }
8776}
8777
8778Buffer.concat = function concat (list, length) {
8779 if (!Array.isArray(list)) {
8780 throw new TypeError('"list" argument must be an Array of Buffers')
8781 }
8782
8783 if (list.length === 0) {
8784 return Buffer.alloc(0)
8785 }
8786
8787 var i
8788 if (length === undefined) {
8789 length = 0
8790 for (i = 0; i < list.length; ++i) {
8791 length += list[i].length
8792 }
8793 }
8794
8795 var buffer = Buffer.allocUnsafe(length)
8796 var pos = 0
8797 for (i = 0; i < list.length; ++i) {
8798 var buf = list[i]
8799 if (isInstance(buf, Uint8Array)) {
8800 buf = Buffer.from(buf)
8801 }
8802 if (!Buffer.isBuffer(buf)) {
8803 throw new TypeError('"list" argument must be an Array of Buffers')
8804 }
8805 buf.copy(buffer, pos)
8806 pos += buf.length
8807 }
8808 return buffer
8809}
8810
8811function byteLength (string, encoding) {
8812 if (Buffer.isBuffer(string)) {
8813 return string.length
8814 }
8815 if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
8816 return string.byteLength
8817 }
8818 if (typeof string !== 'string') {
8819 throw new TypeError(
8820 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
8821 'Received type ' + typeof string
8822 )
8823 }
8824
8825 var len = string.length
8826 var mustMatch = (arguments.length > 2 && arguments[2] === true)
8827 if (!mustMatch && len === 0) return 0
8828
8829 // Use a for loop to avoid recursion
8830 var loweredCase = false
8831 for (;;) {
8832 switch (encoding) {
8833 case 'ascii':
8834 case 'latin1':
8835 case 'binary':
8836 return len
8837 case 'utf8':
8838 case 'utf-8':
8839 return utf8ToBytes(string).length
8840 case 'ucs2':
8841 case 'ucs-2':
8842 case 'utf16le':
8843 case 'utf-16le':
8844 return len * 2
8845 case 'hex':
8846 return len >>> 1
8847 case 'base64':
8848 return base64ToBytes(string).length
8849 default:
8850 if (loweredCase) {
8851 return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
8852 }
8853 encoding = ('' + encoding).toLowerCase()
8854 loweredCase = true
8855 }
8856 }
8857}
8858Buffer.byteLength = byteLength
8859
8860function slowToString (encoding, start, end) {
8861 var loweredCase = false
8862
8863 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
8864 // property of a typed array.
8865
8866 // This behaves neither like String nor Uint8Array in that we set start/end
8867 // to their upper/lower bounds if the value passed is out of range.
8868 // undefined is handled specially as per ECMA-262 6th Edition,
8869 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
8870 if (start === undefined || start < 0) {
8871 start = 0
8872 }
8873 // Return early if start > this.length. Done here to prevent potential uint32
8874 // coercion fail below.
8875 if (start > this.length) {
8876 return ''
8877 }
8878
8879 if (end === undefined || end > this.length) {
8880 end = this.length
8881 }
8882
8883 if (end <= 0) {
8884 return ''
8885 }
8886
8887 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
8888 end >>>= 0
8889 start >>>= 0
8890
8891 if (end <= start) {
8892 return ''
8893 }
8894
8895 if (!encoding) encoding = 'utf8'
8896
8897 while (true) {
8898 switch (encoding) {
8899 case 'hex':
8900 return hexSlice(this, start, end)
8901
8902 case 'utf8':
8903 case 'utf-8':
8904 return utf8Slice(this, start, end)
8905
8906 case 'ascii':
8907 return asciiSlice(this, start, end)
8908
8909 case 'latin1':
8910 case 'binary':
8911 return latin1Slice(this, start, end)
8912
8913 case 'base64':
8914 return base64Slice(this, start, end)
8915
8916 case 'ucs2':
8917 case 'ucs-2':
8918 case 'utf16le':
8919 case 'utf-16le':
8920 return utf16leSlice(this, start, end)
8921
8922 default:
8923 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
8924 encoding = (encoding + '').toLowerCase()
8925 loweredCase = true
8926 }
8927 }
8928}
8929
8930// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
8931// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
8932// reliably in a browserify context because there could be multiple different
8933// copies of the 'buffer' package in use. This method works even for Buffer
8934// instances that were created from another copy of the `buffer` package.
8935// See: https://github.com/feross/buffer/issues/154
8936Buffer.prototype._isBuffer = true
8937
8938function swap (b, n, m) {
8939 var i = b[n]
8940 b[n] = b[m]
8941 b[m] = i
8942}
8943
8944Buffer.prototype.swap16 = function swap16 () {
8945 var len = this.length
8946 if (len % 2 !== 0) {
8947 throw new RangeError('Buffer size must be a multiple of 16-bits')
8948 }
8949 for (var i = 0; i < len; i += 2) {
8950 swap(this, i, i + 1)
8951 }
8952 return this
8953}
8954
8955Buffer.prototype.swap32 = function swap32 () {
8956 var len = this.length
8957 if (len % 4 !== 0) {
8958 throw new RangeError('Buffer size must be a multiple of 32-bits')
8959 }
8960 for (var i = 0; i < len; i += 4) {
8961 swap(this, i, i + 3)
8962 swap(this, i + 1, i + 2)
8963 }
8964 return this
8965}
8966
8967Buffer.prototype.swap64 = function swap64 () {
8968 var len = this.length
8969 if (len % 8 !== 0) {
8970 throw new RangeError('Buffer size must be a multiple of 64-bits')
8971 }
8972 for (var i = 0; i < len; i += 8) {
8973 swap(this, i, i + 7)
8974 swap(this, i + 1, i + 6)
8975 swap(this, i + 2, i + 5)
8976 swap(this, i + 3, i + 4)
8977 }
8978 return this
8979}
8980
8981Buffer.prototype.toString = function toString () {
8982 var length = this.length
8983 if (length === 0) return ''
8984 if (arguments.length === 0) return utf8Slice(this, 0, length)
8985 return slowToString.apply(this, arguments)
8986}
8987
8988Buffer.prototype.toLocaleString = Buffer.prototype.toString
8989
8990Buffer.prototype.equals = function equals (b) {
8991 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
8992 if (this === b) return true
8993 return Buffer.compare(this, b) === 0
8994}
8995
8996Buffer.prototype.inspect = function inspect () {
8997 var str = ''
8998 var max = exports.INSPECT_MAX_BYTES
8999 str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
9000 if (this.length > max) str += ' ... '
9001 return '<Buffer ' + str + '>'
9002}
9003
9004Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
9005 if (isInstance(target, Uint8Array)) {
9006 target = Buffer.from(target, target.offset, target.byteLength)
9007 }
9008 if (!Buffer.isBuffer(target)) {
9009 throw new TypeError(
9010 'The "target" argument must be one of type Buffer or Uint8Array. ' +
9011 'Received type ' + (typeof target)
9012 )
9013 }
9014
9015 if (start === undefined) {
9016 start = 0
9017 }
9018 if (end === undefined) {
9019 end = target ? target.length : 0
9020 }
9021 if (thisStart === undefined) {
9022 thisStart = 0
9023 }
9024 if (thisEnd === undefined) {
9025 thisEnd = this.length
9026 }
9027
9028 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
9029 throw new RangeError('out of range index')
9030 }
9031
9032 if (thisStart >= thisEnd && start >= end) {
9033 return 0
9034 }
9035 if (thisStart >= thisEnd) {
9036 return -1
9037 }
9038 if (start >= end) {
9039 return 1
9040 }
9041
9042 start >>>= 0
9043 end >>>= 0
9044 thisStart >>>= 0
9045 thisEnd >>>= 0
9046
9047 if (this === target) return 0
9048
9049 var x = thisEnd - thisStart
9050 var y = end - start
9051 var len = Math.min(x, y)
9052
9053 var thisCopy = this.slice(thisStart, thisEnd)
9054 var targetCopy = target.slice(start, end)
9055
9056 for (var i = 0; i < len; ++i) {
9057 if (thisCopy[i] !== targetCopy[i]) {
9058 x = thisCopy[i]
9059 y = targetCopy[i]
9060 break
9061 }
9062 }
9063
9064 if (x < y) return -1
9065 if (y < x) return 1
9066 return 0
9067}
9068
9069// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
9070// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
9071//
9072// Arguments:
9073// - buffer - a Buffer to search
9074// - val - a string, Buffer, or number
9075// - byteOffset - an index into `buffer`; will be clamped to an int32
9076// - encoding - an optional encoding, relevant is val is a string
9077// - dir - true for indexOf, false for lastIndexOf
9078function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
9079 // Empty buffer means no match
9080 if (buffer.length === 0) return -1
9081
9082 // Normalize byteOffset
9083 if (typeof byteOffset === 'string') {
9084 encoding = byteOffset
9085 byteOffset = 0
9086 } else if (byteOffset > 0x7fffffff) {
9087 byteOffset = 0x7fffffff
9088 } else if (byteOffset < -0x80000000) {
9089 byteOffset = -0x80000000
9090 }
9091 byteOffset = +byteOffset // Coerce to Number.
9092 if (numberIsNaN(byteOffset)) {
9093 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
9094 byteOffset = dir ? 0 : (buffer.length - 1)
9095 }
9096
9097 // Normalize byteOffset: negative offsets start from the end of the buffer
9098 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
9099 if (byteOffset >= buffer.length) {
9100 if (dir) return -1
9101 else byteOffset = buffer.length - 1
9102 } else if (byteOffset < 0) {
9103 if (dir) byteOffset = 0
9104 else return -1
9105 }
9106
9107 // Normalize val
9108 if (typeof val === 'string') {
9109 val = Buffer.from(val, encoding)
9110 }
9111
9112 // Finally, search either indexOf (if dir is true) or lastIndexOf
9113 if (Buffer.isBuffer(val)) {
9114 // Special case: looking for empty string/buffer always fails
9115 if (val.length === 0) {
9116 return -1
9117 }
9118 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
9119 } else if (typeof val === 'number') {
9120 val = val & 0xFF // Search for a byte value [0-255]
9121 if (typeof Uint8Array.prototype.indexOf === 'function') {
9122 if (dir) {
9123 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
9124 } else {
9125 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
9126 }
9127 }
9128 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
9129 }
9130
9131 throw new TypeError('val must be string, number or Buffer')
9132}
9133
9134function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
9135 var indexSize = 1
9136 var arrLength = arr.length
9137 var valLength = val.length
9138
9139 if (encoding !== undefined) {
9140 encoding = String(encoding).toLowerCase()
9141 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
9142 encoding === 'utf16le' || encoding === 'utf-16le') {
9143 if (arr.length < 2 || val.length < 2) {
9144 return -1
9145 }
9146 indexSize = 2
9147 arrLength /= 2
9148 valLength /= 2
9149 byteOffset /= 2
9150 }
9151 }
9152
9153 function read (buf, i) {
9154 if (indexSize === 1) {
9155 return buf[i]
9156 } else {
9157 return buf.readUInt16BE(i * indexSize)
9158 }
9159 }
9160
9161 var i
9162 if (dir) {
9163 var foundIndex = -1
9164 for (i = byteOffset; i < arrLength; i++) {
9165 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
9166 if (foundIndex === -1) foundIndex = i
9167 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
9168 } else {
9169 if (foundIndex !== -1) i -= i - foundIndex
9170 foundIndex = -1
9171 }
9172 }
9173 } else {
9174 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
9175 for (i = byteOffset; i >= 0; i--) {
9176 var found = true
9177 for (var j = 0; j < valLength; j++) {
9178 if (read(arr, i + j) !== read(val, j)) {
9179 found = false
9180 break
9181 }
9182 }
9183 if (found) return i
9184 }
9185 }
9186
9187 return -1
9188}
9189
9190Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
9191 return this.indexOf(val, byteOffset, encoding) !== -1
9192}
9193
9194Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
9195 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
9196}
9197
9198Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
9199 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
9200}
9201
9202function hexWrite (buf, string, offset, length) {
9203 offset = Number(offset) || 0
9204 var remaining = buf.length - offset
9205 if (!length) {
9206 length = remaining
9207 } else {
9208 length = Number(length)
9209 if (length > remaining) {
9210 length = remaining
9211 }
9212 }
9213
9214 var strLen = string.length
9215
9216 if (length > strLen / 2) {
9217 length = strLen / 2
9218 }
9219 for (var i = 0; i < length; ++i) {
9220 var parsed = parseInt(string.substr(i * 2, 2), 16)
9221 if (numberIsNaN(parsed)) return i
9222 buf[offset + i] = parsed
9223 }
9224 return i
9225}
9226
9227function utf8Write (buf, string, offset, length) {
9228 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
9229}
9230
9231function asciiWrite (buf, string, offset, length) {
9232 return blitBuffer(asciiToBytes(string), buf, offset, length)
9233}
9234
9235function latin1Write (buf, string, offset, length) {
9236 return asciiWrite(buf, string, offset, length)
9237}
9238
9239function base64Write (buf, string, offset, length) {
9240 return blitBuffer(base64ToBytes(string), buf, offset, length)
9241}
9242
9243function ucs2Write (buf, string, offset, length) {
9244 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
9245}
9246
9247Buffer.prototype.write = function write (string, offset, length, encoding) {
9248 // Buffer#write(string)
9249 if (offset === undefined) {
9250 encoding = 'utf8'
9251 length = this.length
9252 offset = 0
9253 // Buffer#write(string, encoding)
9254 } else if (length === undefined && typeof offset === 'string') {
9255 encoding = offset
9256 length = this.length
9257 offset = 0
9258 // Buffer#write(string, offset[, length][, encoding])
9259 } else if (isFinite(offset)) {
9260 offset = offset >>> 0
9261 if (isFinite(length)) {
9262 length = length >>> 0
9263 if (encoding === undefined) encoding = 'utf8'
9264 } else {
9265 encoding = length
9266 length = undefined
9267 }
9268 } else {
9269 throw new Error(
9270 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
9271 )
9272 }
9273
9274 var remaining = this.length - offset
9275 if (length === undefined || length > remaining) length = remaining
9276
9277 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
9278 throw new RangeError('Attempt to write outside buffer bounds')
9279 }
9280
9281 if (!encoding) encoding = 'utf8'
9282
9283 var loweredCase = false
9284 for (;;) {
9285 switch (encoding) {
9286 case 'hex':
9287 return hexWrite(this, string, offset, length)
9288
9289 case 'utf8':
9290 case 'utf-8':
9291 return utf8Write(this, string, offset, length)
9292
9293 case 'ascii':
9294 return asciiWrite(this, string, offset, length)
9295
9296 case 'latin1':
9297 case 'binary':
9298 return latin1Write(this, string, offset, length)
9299
9300 case 'base64':
9301 // Warning: maxLength not taken into account in base64Write
9302 return base64Write(this, string, offset, length)
9303
9304 case 'ucs2':
9305 case 'ucs-2':
9306 case 'utf16le':
9307 case 'utf-16le':
9308 return ucs2Write(this, string, offset, length)
9309
9310 default:
9311 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
9312 encoding = ('' + encoding).toLowerCase()
9313 loweredCase = true
9314 }
9315 }
9316}
9317
9318Buffer.prototype.toJSON = function toJSON () {
9319 return {
9320 type: 'Buffer',
9321 data: Array.prototype.slice.call(this._arr || this, 0)
9322 }
9323}
9324
9325function base64Slice (buf, start, end) {
9326 if (start === 0 && end === buf.length) {
9327 return base64.fromByteArray(buf)
9328 } else {
9329 return base64.fromByteArray(buf.slice(start, end))
9330 }
9331}
9332
9333function utf8Slice (buf, start, end) {
9334 end = Math.min(buf.length, end)
9335 var res = []
9336
9337 var i = start
9338 while (i < end) {
9339 var firstByte = buf[i]
9340 var codePoint = null
9341 var bytesPerSequence = (firstByte > 0xEF) ? 4
9342 : (firstByte > 0xDF) ? 3
9343 : (firstByte > 0xBF) ? 2
9344 : 1
9345
9346 if (i + bytesPerSequence <= end) {
9347 var secondByte, thirdByte, fourthByte, tempCodePoint
9348
9349 switch (bytesPerSequence) {
9350 case 1:
9351 if (firstByte < 0x80) {
9352 codePoint = firstByte
9353 }
9354 break
9355 case 2:
9356 secondByte = buf[i + 1]
9357 if ((secondByte & 0xC0) === 0x80) {
9358 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
9359 if (tempCodePoint > 0x7F) {
9360 codePoint = tempCodePoint
9361 }
9362 }
9363 break
9364 case 3:
9365 secondByte = buf[i + 1]
9366 thirdByte = buf[i + 2]
9367 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
9368 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
9369 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
9370 codePoint = tempCodePoint
9371 }
9372 }
9373 break
9374 case 4:
9375 secondByte = buf[i + 1]
9376 thirdByte = buf[i + 2]
9377 fourthByte = buf[i + 3]
9378 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
9379 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
9380 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
9381 codePoint = tempCodePoint
9382 }
9383 }
9384 }
9385 }
9386
9387 if (codePoint === null) {
9388 // we did not generate a valid codePoint so insert a
9389 // replacement char (U+FFFD) and advance only 1 byte
9390 codePoint = 0xFFFD
9391 bytesPerSequence = 1
9392 } else if (codePoint > 0xFFFF) {
9393 // encode to utf16 (surrogate pair dance)
9394 codePoint -= 0x10000
9395 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
9396 codePoint = 0xDC00 | codePoint & 0x3FF
9397 }
9398
9399 res.push(codePoint)
9400 i += bytesPerSequence
9401 }
9402
9403 return decodeCodePointsArray(res)
9404}
9405
9406// Based on http://stackoverflow.com/a/22747272/680742, the browser with
9407// the lowest limit is Chrome, with 0x10000 args.
9408// We go 1 magnitude less, for safety
9409var MAX_ARGUMENTS_LENGTH = 0x1000
9410
9411function decodeCodePointsArray (codePoints) {
9412 var len = codePoints.length
9413 if (len <= MAX_ARGUMENTS_LENGTH) {
9414 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
9415 }
9416
9417 // Decode in chunks to avoid "call stack size exceeded".
9418 var res = ''
9419 var i = 0
9420 while (i < len) {
9421 res += String.fromCharCode.apply(
9422 String,
9423 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
9424 )
9425 }
9426 return res
9427}
9428
9429function asciiSlice (buf, start, end) {
9430 var ret = ''
9431 end = Math.min(buf.length, end)
9432
9433 for (var i = start; i < end; ++i) {
9434 ret += String.fromCharCode(buf[i] & 0x7F)
9435 }
9436 return ret
9437}
9438
9439function latin1Slice (buf, start, end) {
9440 var ret = ''
9441 end = Math.min(buf.length, end)
9442
9443 for (var i = start; i < end; ++i) {
9444 ret += String.fromCharCode(buf[i])
9445 }
9446 return ret
9447}
9448
9449function hexSlice (buf, start, end) {
9450 var len = buf.length
9451
9452 if (!start || start < 0) start = 0
9453 if (!end || end < 0 || end > len) end = len
9454
9455 var out = ''
9456 for (var i = start; i < end; ++i) {
9457 out += toHex(buf[i])
9458 }
9459 return out
9460}
9461
9462function utf16leSlice (buf, start, end) {
9463 var bytes = buf.slice(start, end)
9464 var res = ''
9465 for (var i = 0; i < bytes.length; i += 2) {
9466 res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
9467 }
9468 return res
9469}
9470
9471Buffer.prototype.slice = function slice (start, end) {
9472 var len = this.length
9473 start = ~~start
9474 end = end === undefined ? len : ~~end
9475
9476 if (start < 0) {
9477 start += len
9478 if (start < 0) start = 0
9479 } else if (start > len) {
9480 start = len
9481 }
9482
9483 if (end < 0) {
9484 end += len
9485 if (end < 0) end = 0
9486 } else if (end > len) {
9487 end = len
9488 }
9489
9490 if (end < start) end = start
9491
9492 var newBuf = this.subarray(start, end)
9493 // Return an augmented `Uint8Array` instance
9494 newBuf.__proto__ = Buffer.prototype
9495 return newBuf
9496}
9497
9498/*
9499 * Need to make sure that buffer isn't trying to write out of bounds.
9500 */
9501function checkOffset (offset, ext, length) {
9502 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
9503 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
9504}
9505
9506Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
9507 offset = offset >>> 0
9508 byteLength = byteLength >>> 0
9509 if (!noAssert) checkOffset(offset, byteLength, this.length)
9510
9511 var val = this[offset]
9512 var mul = 1
9513 var i = 0
9514 while (++i < byteLength && (mul *= 0x100)) {
9515 val += this[offset + i] * mul
9516 }
9517
9518 return val
9519}
9520
9521Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
9522 offset = offset >>> 0
9523 byteLength = byteLength >>> 0
9524 if (!noAssert) {
9525 checkOffset(offset, byteLength, this.length)
9526 }
9527
9528 var val = this[offset + --byteLength]
9529 var mul = 1
9530 while (byteLength > 0 && (mul *= 0x100)) {
9531 val += this[offset + --byteLength] * mul
9532 }
9533
9534 return val
9535}
9536
9537Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
9538 offset = offset >>> 0
9539 if (!noAssert) checkOffset(offset, 1, this.length)
9540 return this[offset]
9541}
9542
9543Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
9544 offset = offset >>> 0
9545 if (!noAssert) checkOffset(offset, 2, this.length)
9546 return this[offset] | (this[offset + 1] << 8)
9547}
9548
9549Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
9550 offset = offset >>> 0
9551 if (!noAssert) checkOffset(offset, 2, this.length)
9552 return (this[offset] << 8) | this[offset + 1]
9553}
9554
9555Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
9556 offset = offset >>> 0
9557 if (!noAssert) checkOffset(offset, 4, this.length)
9558
9559 return ((this[offset]) |
9560 (this[offset + 1] << 8) |
9561 (this[offset + 2] << 16)) +
9562 (this[offset + 3] * 0x1000000)
9563}
9564
9565Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
9566 offset = offset >>> 0
9567 if (!noAssert) checkOffset(offset, 4, this.length)
9568
9569 return (this[offset] * 0x1000000) +
9570 ((this[offset + 1] << 16) |
9571 (this[offset + 2] << 8) |
9572 this[offset + 3])
9573}
9574
9575Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
9576 offset = offset >>> 0
9577 byteLength = byteLength >>> 0
9578 if (!noAssert) checkOffset(offset, byteLength, this.length)
9579
9580 var val = this[offset]
9581 var mul = 1
9582 var i = 0
9583 while (++i < byteLength && (mul *= 0x100)) {
9584 val += this[offset + i] * mul
9585 }
9586 mul *= 0x80
9587
9588 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
9589
9590 return val
9591}
9592
9593Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
9594 offset = offset >>> 0
9595 byteLength = byteLength >>> 0
9596 if (!noAssert) checkOffset(offset, byteLength, this.length)
9597
9598 var i = byteLength
9599 var mul = 1
9600 var val = this[offset + --i]
9601 while (i > 0 && (mul *= 0x100)) {
9602 val += this[offset + --i] * mul
9603 }
9604 mul *= 0x80
9605
9606 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
9607
9608 return val
9609}
9610
9611Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
9612 offset = offset >>> 0
9613 if (!noAssert) checkOffset(offset, 1, this.length)
9614 if (!(this[offset] & 0x80)) return (this[offset])
9615 return ((0xff - this[offset] + 1) * -1)
9616}
9617
9618Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
9619 offset = offset >>> 0
9620 if (!noAssert) checkOffset(offset, 2, this.length)
9621 var val = this[offset] | (this[offset + 1] << 8)
9622 return (val & 0x8000) ? val | 0xFFFF0000 : val
9623}
9624
9625Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
9626 offset = offset >>> 0
9627 if (!noAssert) checkOffset(offset, 2, this.length)
9628 var val = this[offset + 1] | (this[offset] << 8)
9629 return (val & 0x8000) ? val | 0xFFFF0000 : val
9630}
9631
9632Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
9633 offset = offset >>> 0
9634 if (!noAssert) checkOffset(offset, 4, this.length)
9635
9636 return (this[offset]) |
9637 (this[offset + 1] << 8) |
9638 (this[offset + 2] << 16) |
9639 (this[offset + 3] << 24)
9640}
9641
9642Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
9643 offset = offset >>> 0
9644 if (!noAssert) checkOffset(offset, 4, this.length)
9645
9646 return (this[offset] << 24) |
9647 (this[offset + 1] << 16) |
9648 (this[offset + 2] << 8) |
9649 (this[offset + 3])
9650}
9651
9652Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
9653 offset = offset >>> 0
9654 if (!noAssert) checkOffset(offset, 4, this.length)
9655 return ieee754.read(this, offset, true, 23, 4)
9656}
9657
9658Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
9659 offset = offset >>> 0
9660 if (!noAssert) checkOffset(offset, 4, this.length)
9661 return ieee754.read(this, offset, false, 23, 4)
9662}
9663
9664Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
9665 offset = offset >>> 0
9666 if (!noAssert) checkOffset(offset, 8, this.length)
9667 return ieee754.read(this, offset, true, 52, 8)
9668}
9669
9670Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
9671 offset = offset >>> 0
9672 if (!noAssert) checkOffset(offset, 8, this.length)
9673 return ieee754.read(this, offset, false, 52, 8)
9674}
9675
9676function checkInt (buf, value, offset, ext, max, min) {
9677 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
9678 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
9679 if (offset + ext > buf.length) throw new RangeError('Index out of range')
9680}
9681
9682Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
9683 value = +value
9684 offset = offset >>> 0
9685 byteLength = byteLength >>> 0
9686 if (!noAssert) {
9687 var maxBytes = Math.pow(2, 8 * byteLength) - 1
9688 checkInt(this, value, offset, byteLength, maxBytes, 0)
9689 }
9690
9691 var mul = 1
9692 var i = 0
9693 this[offset] = value & 0xFF
9694 while (++i < byteLength && (mul *= 0x100)) {
9695 this[offset + i] = (value / mul) & 0xFF
9696 }
9697
9698 return offset + byteLength
9699}
9700
9701Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
9702 value = +value
9703 offset = offset >>> 0
9704 byteLength = byteLength >>> 0
9705 if (!noAssert) {
9706 var maxBytes = Math.pow(2, 8 * byteLength) - 1
9707 checkInt(this, value, offset, byteLength, maxBytes, 0)
9708 }
9709
9710 var i = byteLength - 1
9711 var mul = 1
9712 this[offset + i] = value & 0xFF
9713 while (--i >= 0 && (mul *= 0x100)) {
9714 this[offset + i] = (value / mul) & 0xFF
9715 }
9716
9717 return offset + byteLength
9718}
9719
9720Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
9721 value = +value
9722 offset = offset >>> 0
9723 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
9724 this[offset] = (value & 0xff)
9725 return offset + 1
9726}
9727
9728Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
9729 value = +value
9730 offset = offset >>> 0
9731 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
9732 this[offset] = (value & 0xff)
9733 this[offset + 1] = (value >>> 8)
9734 return offset + 2
9735}
9736
9737Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
9738 value = +value
9739 offset = offset >>> 0
9740 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
9741 this[offset] = (value >>> 8)
9742 this[offset + 1] = (value & 0xff)
9743 return offset + 2
9744}
9745
9746Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
9747 value = +value
9748 offset = offset >>> 0
9749 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
9750 this[offset + 3] = (value >>> 24)
9751 this[offset + 2] = (value >>> 16)
9752 this[offset + 1] = (value >>> 8)
9753 this[offset] = (value & 0xff)
9754 return offset + 4
9755}
9756
9757Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
9758 value = +value
9759 offset = offset >>> 0
9760 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
9761 this[offset] = (value >>> 24)
9762 this[offset + 1] = (value >>> 16)
9763 this[offset + 2] = (value >>> 8)
9764 this[offset + 3] = (value & 0xff)
9765 return offset + 4
9766}
9767
9768Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
9769 value = +value
9770 offset = offset >>> 0
9771 if (!noAssert) {
9772 var limit = Math.pow(2, (8 * byteLength) - 1)
9773
9774 checkInt(this, value, offset, byteLength, limit - 1, -limit)
9775 }
9776
9777 var i = 0
9778 var mul = 1
9779 var sub = 0
9780 this[offset] = value & 0xFF
9781 while (++i < byteLength && (mul *= 0x100)) {
9782 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
9783 sub = 1
9784 }
9785 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
9786 }
9787
9788 return offset + byteLength
9789}
9790
9791Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
9792 value = +value
9793 offset = offset >>> 0
9794 if (!noAssert) {
9795 var limit = Math.pow(2, (8 * byteLength) - 1)
9796
9797 checkInt(this, value, offset, byteLength, limit - 1, -limit)
9798 }
9799
9800 var i = byteLength - 1
9801 var mul = 1
9802 var sub = 0
9803 this[offset + i] = value & 0xFF
9804 while (--i >= 0 && (mul *= 0x100)) {
9805 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
9806 sub = 1
9807 }
9808 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
9809 }
9810
9811 return offset + byteLength
9812}
9813
9814Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
9815 value = +value
9816 offset = offset >>> 0
9817 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
9818 if (value < 0) value = 0xff + value + 1
9819 this[offset] = (value & 0xff)
9820 return offset + 1
9821}
9822
9823Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
9824 value = +value
9825 offset = offset >>> 0
9826 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
9827 this[offset] = (value & 0xff)
9828 this[offset + 1] = (value >>> 8)
9829 return offset + 2
9830}
9831
9832Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
9833 value = +value
9834 offset = offset >>> 0
9835 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
9836 this[offset] = (value >>> 8)
9837 this[offset + 1] = (value & 0xff)
9838 return offset + 2
9839}
9840
9841Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
9842 value = +value
9843 offset = offset >>> 0
9844 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
9845 this[offset] = (value & 0xff)
9846 this[offset + 1] = (value >>> 8)
9847 this[offset + 2] = (value >>> 16)
9848 this[offset + 3] = (value >>> 24)
9849 return offset + 4
9850}
9851
9852Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
9853 value = +value
9854 offset = offset >>> 0
9855 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
9856 if (value < 0) value = 0xffffffff + value + 1
9857 this[offset] = (value >>> 24)
9858 this[offset + 1] = (value >>> 16)
9859 this[offset + 2] = (value >>> 8)
9860 this[offset + 3] = (value & 0xff)
9861 return offset + 4
9862}
9863
9864function checkIEEE754 (buf, value, offset, ext, max, min) {
9865 if (offset + ext > buf.length) throw new RangeError('Index out of range')
9866 if (offset < 0) throw new RangeError('Index out of range')
9867}
9868
9869function writeFloat (buf, value, offset, littleEndian, noAssert) {
9870 value = +value
9871 offset = offset >>> 0
9872 if (!noAssert) {
9873 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
9874 }
9875 ieee754.write(buf, value, offset, littleEndian, 23, 4)
9876 return offset + 4
9877}
9878
9879Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
9880 return writeFloat(this, value, offset, true, noAssert)
9881}
9882
9883Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
9884 return writeFloat(this, value, offset, false, noAssert)
9885}
9886
9887function writeDouble (buf, value, offset, littleEndian, noAssert) {
9888 value = +value
9889 offset = offset >>> 0
9890 if (!noAssert) {
9891 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
9892 }
9893 ieee754.write(buf, value, offset, littleEndian, 52, 8)
9894 return offset + 8
9895}
9896
9897Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
9898 return writeDouble(this, value, offset, true, noAssert)
9899}
9900
9901Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
9902 return writeDouble(this, value, offset, false, noAssert)
9903}
9904
9905// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
9906Buffer.prototype.copy = function copy (target, targetStart, start, end) {
9907 if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
9908 if (!start) start = 0
9909 if (!end && end !== 0) end = this.length
9910 if (targetStart >= target.length) targetStart = target.length
9911 if (!targetStart) targetStart = 0
9912 if (end > 0 && end < start) end = start
9913
9914 // Copy 0 bytes; we're done
9915 if (end === start) return 0
9916 if (target.length === 0 || this.length === 0) return 0
9917
9918 // Fatal error conditions
9919 if (targetStart < 0) {
9920 throw new RangeError('targetStart out of bounds')
9921 }
9922 if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
9923 if (end < 0) throw new RangeError('sourceEnd out of bounds')
9924
9925 // Are we oob?
9926 if (end > this.length) end = this.length
9927 if (target.length - targetStart < end - start) {
9928 end = target.length - targetStart + start
9929 }
9930
9931 var len = end - start
9932
9933 if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
9934 // Use built-in when available, missing from IE11
9935 this.copyWithin(targetStart, start, end)
9936 } else if (this === target && start < targetStart && targetStart < end) {
9937 // descending copy from end
9938 for (var i = len - 1; i >= 0; --i) {
9939 target[i + targetStart] = this[i + start]
9940 }
9941 } else {
9942 Uint8Array.prototype.set.call(
9943 target,
9944 this.subarray(start, end),
9945 targetStart
9946 )
9947 }
9948
9949 return len
9950}
9951
9952// Usage:
9953// buffer.fill(number[, offset[, end]])
9954// buffer.fill(buffer[, offset[, end]])
9955// buffer.fill(string[, offset[, end]][, encoding])
9956Buffer.prototype.fill = function fill (val, start, end, encoding) {
9957 // Handle string cases:
9958 if (typeof val === 'string') {
9959 if (typeof start === 'string') {
9960 encoding = start
9961 start = 0
9962 end = this.length
9963 } else if (typeof end === 'string') {
9964 encoding = end
9965 end = this.length
9966 }
9967 if (encoding !== undefined && typeof encoding !== 'string') {
9968 throw new TypeError('encoding must be a string')
9969 }
9970 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
9971 throw new TypeError('Unknown encoding: ' + encoding)
9972 }
9973 if (val.length === 1) {
9974 var code = val.charCodeAt(0)
9975 if ((encoding === 'utf8' && code < 128) ||
9976 encoding === 'latin1') {
9977 // Fast path: If `val` fits into a single byte, use that numeric value.
9978 val = code
9979 }
9980 }
9981 } else if (typeof val === 'number') {
9982 val = val & 255
9983 }
9984
9985 // Invalid ranges are not set to a default, so can range check early.
9986 if (start < 0 || this.length < start || this.length < end) {
9987 throw new RangeError('Out of range index')
9988 }
9989
9990 if (end <= start) {
9991 return this
9992 }
9993
9994 start = start >>> 0
9995 end = end === undefined ? this.length : end >>> 0
9996
9997 if (!val) val = 0
9998
9999 var i
10000 if (typeof val === 'number') {
10001 for (i = start; i < end; ++i) {
10002 this[i] = val
10003 }
10004 } else {
10005 var bytes = Buffer.isBuffer(val)
10006 ? val
10007 : Buffer.from(val, encoding)
10008 var len = bytes.length
10009 if (len === 0) {
10010 throw new TypeError('The value "' + val +
10011 '" is invalid for argument "value"')
10012 }
10013 for (i = 0; i < end - start; ++i) {
10014 this[i + start] = bytes[i % len]
10015 }
10016 }
10017
10018 return this
10019}
10020
10021// HELPER FUNCTIONS
10022// ================
10023
10024var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
10025
10026function base64clean (str) {
10027 // Node takes equal signs as end of the Base64 encoding
10028 str = str.split('=')[0]
10029 // Node strips out invalid characters like \n and \t from the string, base64-js does not
10030 str = str.trim().replace(INVALID_BASE64_RE, '')
10031 // Node converts strings with length < 2 to ''
10032 if (str.length < 2) return ''
10033 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
10034 while (str.length % 4 !== 0) {
10035 str = str + '='
10036 }
10037 return str
10038}
10039
10040function toHex (n) {
10041 if (n < 16) return '0' + n.toString(16)
10042 return n.toString(16)
10043}
10044
10045function utf8ToBytes (string, units) {
10046 units = units || Infinity
10047 var codePoint
10048 var length = string.length
10049 var leadSurrogate = null
10050 var bytes = []
10051
10052 for (var i = 0; i < length; ++i) {
10053 codePoint = string.charCodeAt(i)
10054
10055 // is surrogate component
10056 if (codePoint > 0xD7FF && codePoint < 0xE000) {
10057 // last char was a lead
10058 if (!leadSurrogate) {
10059 // no lead yet
10060 if (codePoint > 0xDBFF) {
10061 // unexpected trail
10062 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
10063 continue
10064 } else if (i + 1 === length) {
10065 // unpaired lead
10066 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
10067 continue
10068 }
10069
10070 // valid lead
10071 leadSurrogate = codePoint
10072
10073 continue
10074 }
10075
10076 // 2 leads in a row
10077 if (codePoint < 0xDC00) {
10078 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
10079 leadSurrogate = codePoint
10080 continue
10081 }
10082
10083 // valid surrogate pair
10084 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
10085 } else if (leadSurrogate) {
10086 // valid bmp char, but last char was a lead
10087 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
10088 }
10089
10090 leadSurrogate = null
10091
10092 // encode utf8
10093 if (codePoint < 0x80) {
10094 if ((units -= 1) < 0) break
10095 bytes.push(codePoint)
10096 } else if (codePoint < 0x800) {
10097 if ((units -= 2) < 0) break
10098 bytes.push(
10099 codePoint >> 0x6 | 0xC0,
10100 codePoint & 0x3F | 0x80
10101 )
10102 } else if (codePoint < 0x10000) {
10103 if ((units -= 3) < 0) break
10104 bytes.push(
10105 codePoint >> 0xC | 0xE0,
10106 codePoint >> 0x6 & 0x3F | 0x80,
10107 codePoint & 0x3F | 0x80
10108 )
10109 } else if (codePoint < 0x110000) {
10110 if ((units -= 4) < 0) break
10111 bytes.push(
10112 codePoint >> 0x12 | 0xF0,
10113 codePoint >> 0xC & 0x3F | 0x80,
10114 codePoint >> 0x6 & 0x3F | 0x80,
10115 codePoint & 0x3F | 0x80
10116 )
10117 } else {
10118 throw new Error('Invalid code point')
10119 }
10120 }
10121
10122 return bytes
10123}
10124
10125function asciiToBytes (str) {
10126 var byteArray = []
10127 for (var i = 0; i < str.length; ++i) {
10128 // Node's code seems to be doing this and not & 0x7F..
10129 byteArray.push(str.charCodeAt(i) & 0xFF)
10130 }
10131 return byteArray
10132}
10133
10134function utf16leToBytes (str, units) {
10135 var c, hi, lo
10136 var byteArray = []
10137 for (var i = 0; i < str.length; ++i) {
10138 if ((units -= 2) < 0) break
10139
10140 c = str.charCodeAt(i)
10141 hi = c >> 8
10142 lo = c % 256
10143 byteArray.push(lo)
10144 byteArray.push(hi)
10145 }
10146
10147 return byteArray
10148}
10149
10150function base64ToBytes (str) {
10151 return base64.toByteArray(base64clean(str))
10152}
10153
10154function blitBuffer (src, dst, offset, length) {
10155 for (var i = 0; i < length; ++i) {
10156 if ((i + offset >= dst.length) || (i >= src.length)) break
10157 dst[i + offset] = src[i]
10158 }
10159 return i
10160}
10161
10162// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
10163// the `instanceof` check but they should be treated as of that type.
10164// See: https://github.com/feross/buffer/issues/166
10165function isInstance (obj, type) {
10166 return obj instanceof type ||
10167 (obj != null && obj.constructor != null && obj.constructor.name != null &&
10168 obj.constructor.name === type.name)
10169}
10170function numberIsNaN (obj) {
10171 // For IE11 support
10172 return obj !== obj // eslint-disable-line no-self-compare
10173}
10174
10175}).call(this,require("buffer").Buffer)
10176},{"base64-js":39,"buffer":43,"ieee754":55}],44:[function(require,module,exports){
10177(function (Buffer){
10178// Copyright Joyent, Inc. and other Node contributors.
10179//
10180// Permission is hereby granted, free of charge, to any person obtaining a
10181// copy of this software and associated documentation files (the
10182// "Software"), to deal in the Software without restriction, including
10183// without limitation the rights to use, copy, modify, merge, publish,
10184// distribute, sublicense, and/or sell copies of the Software, and to permit
10185// persons to whom the Software is furnished to do so, subject to the
10186// following conditions:
10187//
10188// The above copyright notice and this permission notice shall be included
10189// in all copies or substantial portions of the Software.
10190//
10191// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10192// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10193// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10194// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10195// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10196// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10197// USE OR OTHER DEALINGS IN THE SOFTWARE.
10198
10199// NOTE: These type checking functions intentionally don't use `instanceof`
10200// because it is fragile and can be easily faked with `Object.create()`.
10201
10202function isArray(arg) {
10203 if (Array.isArray) {
10204 return Array.isArray(arg);
10205 }
10206 return objectToString(arg) === '[object Array]';
10207}
10208exports.isArray = isArray;
10209
10210function isBoolean(arg) {
10211 return typeof arg === 'boolean';
10212}
10213exports.isBoolean = isBoolean;
10214
10215function isNull(arg) {
10216 return arg === null;
10217}
10218exports.isNull = isNull;
10219
10220function isNullOrUndefined(arg) {
10221 return arg == null;
10222}
10223exports.isNullOrUndefined = isNullOrUndefined;
10224
10225function isNumber(arg) {
10226 return typeof arg === 'number';
10227}
10228exports.isNumber = isNumber;
10229
10230function isString(arg) {
10231 return typeof arg === 'string';
10232}
10233exports.isString = isString;
10234
10235function isSymbol(arg) {
10236 return typeof arg === 'symbol';
10237}
10238exports.isSymbol = isSymbol;
10239
10240function isUndefined(arg) {
10241 return arg === void 0;
10242}
10243exports.isUndefined = isUndefined;
10244
10245function isRegExp(re) {
10246 return objectToString(re) === '[object RegExp]';
10247}
10248exports.isRegExp = isRegExp;
10249
10250function isObject(arg) {
10251 return typeof arg === 'object' && arg !== null;
10252}
10253exports.isObject = isObject;
10254
10255function isDate(d) {
10256 return objectToString(d) === '[object Date]';
10257}
10258exports.isDate = isDate;
10259
10260function isError(e) {
10261 return (objectToString(e) === '[object Error]' || e instanceof Error);
10262}
10263exports.isError = isError;
10264
10265function isFunction(arg) {
10266 return typeof arg === 'function';
10267}
10268exports.isFunction = isFunction;
10269
10270function isPrimitive(arg) {
10271 return arg === null ||
10272 typeof arg === 'boolean' ||
10273 typeof arg === 'number' ||
10274 typeof arg === 'string' ||
10275 typeof arg === 'symbol' || // ES6 symbol
10276 typeof arg === 'undefined';
10277}
10278exports.isPrimitive = isPrimitive;
10279
10280exports.isBuffer = Buffer.isBuffer;
10281
10282function objectToString(o) {
10283 return Object.prototype.toString.call(o);
10284}
10285
10286}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
10287},{"../../is-buffer/index.js":57}],45:[function(require,module,exports){
10288(function (process){
10289"use strict";
10290
10291function _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); }
10292
10293/* eslint-env browser */
10294
10295/**
10296 * This is the web browser implementation of `debug()`.
10297 */
10298exports.log = log;
10299exports.formatArgs = formatArgs;
10300exports.save = save;
10301exports.load = load;
10302exports.useColors = useColors;
10303exports.storage = localstorage();
10304/**
10305 * Colors.
10306 */
10307
10308exports.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'];
10309/**
10310 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
10311 * and the Firebug extension (any Firefox version) are known
10312 * to support "%c" CSS customizations.
10313 *
10314 * TODO: add a `localStorage` variable to explicitly enable/disable colors
10315 */
10316// eslint-disable-next-line complexity
10317
10318function useColors() {
10319 // NB: In an Electron preload script, document will be defined but not fully
10320 // initialized. Since we know we're in Chrome, we'll just detect this case
10321 // explicitly
10322 if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
10323 return true;
10324 } // Internet Explorer and Edge do not support colors.
10325
10326
10327 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
10328 return false;
10329 } // Is webkit? http://stackoverflow.com/a/16459606/376773
10330 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
10331
10332
10333 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
10334 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
10335 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
10336 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
10337 typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
10338}
10339/**
10340 * Colorize log arguments if enabled.
10341 *
10342 * @api public
10343 */
10344
10345
10346function formatArgs(args) {
10347 args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
10348
10349 if (!this.useColors) {
10350 return;
10351 }
10352
10353 var c = 'color: ' + this.color;
10354 args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
10355 // arguments passed either before or after the %c, so we need to
10356 // figure out the correct index to insert the CSS into
10357
10358 var index = 0;
10359 var lastC = 0;
10360 args[0].replace(/%[a-zA-Z%]/g, function (match) {
10361 if (match === '%%') {
10362 return;
10363 }
10364
10365 index++;
10366
10367 if (match === '%c') {
10368 // We only are interested in the *last* %c
10369 // (the user may have provided their own)
10370 lastC = index;
10371 }
10372 });
10373 args.splice(lastC, 0, c);
10374}
10375/**
10376 * Invokes `console.log()` when available.
10377 * No-op when `console.log` is not a "function".
10378 *
10379 * @api public
10380 */
10381
10382
10383function log() {
10384 var _console;
10385
10386 // This hackery is required for IE8/9, where
10387 // the `console.log` function doesn't have 'apply'
10388 return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
10389}
10390/**
10391 * Save `namespaces`.
10392 *
10393 * @param {String} namespaces
10394 * @api private
10395 */
10396
10397
10398function save(namespaces) {
10399 try {
10400 if (namespaces) {
10401 exports.storage.setItem('debug', namespaces);
10402 } else {
10403 exports.storage.removeItem('debug');
10404 }
10405 } catch (error) {// Swallow
10406 // XXX (@Qix-) should we be logging these?
10407 }
10408}
10409/**
10410 * Load `namespaces`.
10411 *
10412 * @return {String} returns the previously persisted debug modes
10413 * @api private
10414 */
10415
10416
10417function load() {
10418 var r;
10419
10420 try {
10421 r = exports.storage.getItem('debug');
10422 } catch (error) {} // Swallow
10423 // XXX (@Qix-) should we be logging these?
10424 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
10425
10426
10427 if (!r && typeof process !== 'undefined' && 'env' in process) {
10428 r = process.env.DEBUG;
10429 }
10430
10431 return r;
10432}
10433/**
10434 * Localstorage attempts to return the localstorage.
10435 *
10436 * This is necessary because safari throws
10437 * when a user disables cookies/localstorage
10438 * and you attempt to access it.
10439 *
10440 * @return {LocalStorage}
10441 * @api private
10442 */
10443
10444
10445function localstorage() {
10446 try {
10447 // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
10448 // The Browser also has localStorage in the global context.
10449 return localStorage;
10450 } catch (error) {// Swallow
10451 // XXX (@Qix-) should we be logging these?
10452 }
10453}
10454
10455module.exports = require('./common')(exports);
10456var formatters = module.exports.formatters;
10457/**
10458 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
10459 */
10460
10461formatters.j = function (v) {
10462 try {
10463 return JSON.stringify(v);
10464 } catch (error) {
10465 return '[UnexpectedJSONParseError]: ' + error.message;
10466 }
10467};
10468
10469
10470}).call(this,require('_process'))
10471},{"./common":46,"_process":69}],46:[function(require,module,exports){
10472"use strict";
10473
10474/**
10475 * This is the common logic for both the Node.js and web browser
10476 * implementations of `debug()`.
10477 */
10478function setup(env) {
10479 createDebug.debug = createDebug;
10480 createDebug.default = createDebug;
10481 createDebug.coerce = coerce;
10482 createDebug.disable = disable;
10483 createDebug.enable = enable;
10484 createDebug.enabled = enabled;
10485 createDebug.humanize = require('ms');
10486 Object.keys(env).forEach(function (key) {
10487 createDebug[key] = env[key];
10488 });
10489 /**
10490 * Active `debug` instances.
10491 */
10492
10493 createDebug.instances = [];
10494 /**
10495 * The currently active debug mode names, and names to skip.
10496 */
10497
10498 createDebug.names = [];
10499 createDebug.skips = [];
10500 /**
10501 * Map of special "%n" handling functions, for the debug "format" argument.
10502 *
10503 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
10504 */
10505
10506 createDebug.formatters = {};
10507 /**
10508 * Selects a color for a debug namespace
10509 * @param {String} namespace The namespace string for the for the debug instance to be colored
10510 * @return {Number|String} An ANSI color code for the given namespace
10511 * @api private
10512 */
10513
10514 function selectColor(namespace) {
10515 var hash = 0;
10516
10517 for (var i = 0; i < namespace.length; i++) {
10518 hash = (hash << 5) - hash + namespace.charCodeAt(i);
10519 hash |= 0; // Convert to 32bit integer
10520 }
10521
10522 return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
10523 }
10524
10525 createDebug.selectColor = selectColor;
10526 /**
10527 * Create a debugger with the given `namespace`.
10528 *
10529 * @param {String} namespace
10530 * @return {Function}
10531 * @api public
10532 */
10533
10534 function createDebug(namespace) {
10535 var prevTime;
10536
10537 function debug() {
10538 // Disabled?
10539 if (!debug.enabled) {
10540 return;
10541 }
10542
10543 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10544 args[_key] = arguments[_key];
10545 }
10546
10547 var self = debug; // Set `diff` timestamp
10548
10549 var curr = Number(new Date());
10550 var ms = curr - (prevTime || curr);
10551 self.diff = ms;
10552 self.prev = prevTime;
10553 self.curr = curr;
10554 prevTime = curr;
10555 args[0] = createDebug.coerce(args[0]);
10556
10557 if (typeof args[0] !== 'string') {
10558 // Anything else let's inspect with %O
10559 args.unshift('%O');
10560 } // Apply any `formatters` transformations
10561
10562
10563 var index = 0;
10564 args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
10565 // If we encounter an escaped % then don't increase the array index
10566 if (match === '%%') {
10567 return match;
10568 }
10569
10570 index++;
10571 var formatter = createDebug.formatters[format];
10572
10573 if (typeof formatter === 'function') {
10574 var val = args[index];
10575 match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
10576
10577 args.splice(index, 1);
10578 index--;
10579 }
10580
10581 return match;
10582 }); // Apply env-specific formatting (colors, etc.)
10583
10584 createDebug.formatArgs.call(self, args);
10585 var logFn = self.log || createDebug.log;
10586 logFn.apply(self, args);
10587 }
10588
10589 debug.namespace = namespace;
10590 debug.enabled = createDebug.enabled(namespace);
10591 debug.useColors = createDebug.useColors();
10592 debug.color = selectColor(namespace);
10593 debug.destroy = destroy;
10594 debug.extend = extend; // Debug.formatArgs = formatArgs;
10595 // debug.rawLog = rawLog;
10596 // env-specific initialization logic for debug instances
10597
10598 if (typeof createDebug.init === 'function') {
10599 createDebug.init(debug);
10600 }
10601
10602 createDebug.instances.push(debug);
10603 return debug;
10604 }
10605
10606 function destroy() {
10607 var index = createDebug.instances.indexOf(this);
10608
10609 if (index !== -1) {
10610 createDebug.instances.splice(index, 1);
10611 return true;
10612 }
10613
10614 return false;
10615 }
10616
10617 function extend(namespace, delimiter) {
10618 return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
10619 }
10620 /**
10621 * Enables a debug mode by namespaces. This can include modes
10622 * separated by a colon and wildcards.
10623 *
10624 * @param {String} namespaces
10625 * @api public
10626 */
10627
10628
10629 function enable(namespaces) {
10630 createDebug.save(namespaces);
10631 createDebug.names = [];
10632 createDebug.skips = [];
10633 var i;
10634 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
10635 var len = split.length;
10636
10637 for (i = 0; i < len; i++) {
10638 if (!split[i]) {
10639 // ignore empty strings
10640 continue;
10641 }
10642
10643 namespaces = split[i].replace(/\*/g, '.*?');
10644
10645 if (namespaces[0] === '-') {
10646 createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
10647 } else {
10648 createDebug.names.push(new RegExp('^' + namespaces + '$'));
10649 }
10650 }
10651
10652 for (i = 0; i < createDebug.instances.length; i++) {
10653 var instance = createDebug.instances[i];
10654 instance.enabled = createDebug.enabled(instance.namespace);
10655 }
10656 }
10657 /**
10658 * Disable debug output.
10659 *
10660 * @api public
10661 */
10662
10663
10664 function disable() {
10665 createDebug.enable('');
10666 }
10667 /**
10668 * Returns true if the given mode name is enabled, false otherwise.
10669 *
10670 * @param {String} name
10671 * @return {Boolean}
10672 * @api public
10673 */
10674
10675
10676 function enabled(name) {
10677 if (name[name.length - 1] === '*') {
10678 return true;
10679 }
10680
10681 var i;
10682 var len;
10683
10684 for (i = 0, len = createDebug.skips.length; i < len; i++) {
10685 if (createDebug.skips[i].test(name)) {
10686 return false;
10687 }
10688 }
10689
10690 for (i = 0, len = createDebug.names.length; i < len; i++) {
10691 if (createDebug.names[i].test(name)) {
10692 return true;
10693 }
10694 }
10695
10696 return false;
10697 }
10698 /**
10699 * Coerce `val`.
10700 *
10701 * @param {Mixed} val
10702 * @return {Mixed}
10703 * @api private
10704 */
10705
10706
10707 function coerce(val) {
10708 if (val instanceof Error) {
10709 return val.stack || val.message;
10710 }
10711
10712 return val;
10713 }
10714
10715 createDebug.enable(createDebug.load());
10716 return createDebug;
10717}
10718
10719module.exports = setup;
10720
10721
10722},{"ms":60}],47:[function(require,module,exports){
10723'use strict';
10724
10725var keys = require('object-keys');
10726var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
10727
10728var toStr = Object.prototype.toString;
10729var concat = Array.prototype.concat;
10730var origDefineProperty = Object.defineProperty;
10731
10732var isFunction = function (fn) {
10733 return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
10734};
10735
10736var arePropertyDescriptorsSupported = function () {
10737 var obj = {};
10738 try {
10739 origDefineProperty(obj, 'x', { enumerable: false, value: obj });
10740 // eslint-disable-next-line no-unused-vars, no-restricted-syntax
10741 for (var _ in obj) { // jscs:ignore disallowUnusedVariables
10742 return false;
10743 }
10744 return obj.x === obj;
10745 } catch (e) { /* this is IE 8. */
10746 return false;
10747 }
10748};
10749var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
10750
10751var defineProperty = function (object, name, value, predicate) {
10752 if (name in object && (!isFunction(predicate) || !predicate())) {
10753 return;
10754 }
10755 if (supportsDescriptors) {
10756 origDefineProperty(object, name, {
10757 configurable: true,
10758 enumerable: false,
10759 value: value,
10760 writable: true
10761 });
10762 } else {
10763 object[name] = value;
10764 }
10765};
10766
10767var defineProperties = function (object, map) {
10768 var predicates = arguments.length > 2 ? arguments[2] : {};
10769 var props = keys(map);
10770 if (hasSymbols) {
10771 props = concat.call(props, Object.getOwnPropertySymbols(map));
10772 }
10773 for (var i = 0; i < props.length; i += 1) {
10774 defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
10775 }
10776};
10777
10778defineProperties.supportsDescriptors = !!supportsDescriptors;
10779
10780module.exports = defineProperties;
10781
10782},{"object-keys":62}],48:[function(require,module,exports){
10783/*!
10784
10785 diff v3.5.0
10786
10787Software License Agreement (BSD License)
10788
10789Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
10790
10791All rights reserved.
10792
10793Redistribution and use of this software in source and binary forms, with or without modification,
10794are permitted provided that the following conditions are met:
10795
10796* Redistributions of source code must retain the above
10797 copyright notice, this list of conditions and the
10798 following disclaimer.
10799
10800* Redistributions in binary form must reproduce the above
10801 copyright notice, this list of conditions and the
10802 following disclaimer in the documentation and/or other
10803 materials provided with the distribution.
10804
10805* Neither the name of Kevin Decker nor the names of its
10806 contributors may be used to endorse or promote products
10807 derived from this software without specific prior
10808 written permission.
10809
10810THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
10811IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
10812FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
10813CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
10814DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10815DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
10816IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
10817OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10818@license
10819*/
10820(function webpackUniversalModuleDefinition(root, factory) {
10821 if(typeof exports === 'object' && typeof module === 'object')
10822 module.exports = factory();
10823 else if(false)
10824 define([], factory);
10825 else if(typeof exports === 'object')
10826 exports["JsDiff"] = factory();
10827 else
10828 root["JsDiff"] = factory();
10829})(this, function() {
10830return /******/ (function(modules) { // webpackBootstrap
10831/******/ // The module cache
10832/******/ var installedModules = {};
10833
10834/******/ // The require function
10835/******/ function __webpack_require__(moduleId) {
10836
10837/******/ // Check if module is in cache
10838/******/ if(installedModules[moduleId])
10839/******/ return installedModules[moduleId].exports;
10840
10841/******/ // Create a new module (and put it into the cache)
10842/******/ var module = installedModules[moduleId] = {
10843/******/ exports: {},
10844/******/ id: moduleId,
10845/******/ loaded: false
10846/******/ };
10847
10848/******/ // Execute the module function
10849/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
10850
10851/******/ // Flag the module as loaded
10852/******/ module.loaded = true;
10853
10854/******/ // Return the exports of the module
10855/******/ return module.exports;
10856/******/ }
10857
10858
10859/******/ // expose the modules object (__webpack_modules__)
10860/******/ __webpack_require__.m = modules;
10861
10862/******/ // expose the module cache
10863/******/ __webpack_require__.c = installedModules;
10864
10865/******/ // __webpack_public_path__
10866/******/ __webpack_require__.p = "";
10867
10868/******/ // Load entry module and return exports
10869/******/ return __webpack_require__(0);
10870/******/ })
10871/************************************************************************/
10872/******/ ([
10873/* 0 */
10874/***/ (function(module, exports, __webpack_require__) {
10875
10876 /*istanbul ignore start*/'use strict';
10877
10878 exports.__esModule = true;
10879 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;
10880
10881 /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
10882
10883 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
10884
10885 /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/;
10886
10887 var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/;
10888
10889 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
10890
10891 var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/;
10892
10893 var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/;
10894
10895 var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/;
10896
10897 var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/;
10898
10899 var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/;
10900
10901 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
10902
10903 var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/;
10904
10905 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
10906
10907 var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/;
10908
10909 var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/;
10910
10911 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
10912
10913 /* See LICENSE file for terms of use */
10914
10915 /*
10916 * Text diff implementation.
10917 *
10918 * This library supports the following APIS:
10919 * JsDiff.diffChars: Character by character diff
10920 * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
10921 * JsDiff.diffLines: Line based diff
10922 *
10923 * JsDiff.diffCss: Diff targeted at CSS content
10924 *
10925 * These methods are based on the implementation proposed in
10926 * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
10927 * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
10928 */
10929 exports. /*istanbul ignore end*/Diff = _base2['default'];
10930 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
10931 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
10932 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
10933 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
10934 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
10935 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
10936 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
10937 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
10938 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
10939 /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
10940 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
10941 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
10942 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
10943 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
10944 /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
10945 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge;
10946 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
10947 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
10948 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize;
10949
10950
10951
10952/***/ }),
10953/* 1 */
10954/***/ (function(module, exports) {
10955
10956 /*istanbul ignore start*/'use strict';
10957
10958 exports.__esModule = true;
10959 exports['default'] = /*istanbul ignore end*/Diff;
10960 function Diff() {}
10961
10962 Diff.prototype = {
10963 /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
10964 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
10965
10966 var callback = options.callback;
10967 if (typeof options === 'function') {
10968 callback = options;
10969 options = {};
10970 }
10971 this.options = options;
10972
10973 var self = this;
10974
10975 function done(value) {
10976 if (callback) {
10977 setTimeout(function () {
10978 callback(undefined, value);
10979 }, 0);
10980 return true;
10981 } else {
10982 return value;
10983 }
10984 }
10985
10986 // Allow subclasses to massage the input prior to running
10987 oldString = this.castInput(oldString);
10988 newString = this.castInput(newString);
10989
10990 oldString = this.removeEmpty(this.tokenize(oldString));
10991 newString = this.removeEmpty(this.tokenize(newString));
10992
10993 var newLen = newString.length,
10994 oldLen = oldString.length;
10995 var editLength = 1;
10996 var maxEditLength = newLen + oldLen;
10997 var bestPath = [{ newPos: -1, components: [] }];
10998
10999 // Seed editLength = 0, i.e. the content starts with the same values
11000 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
11001 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
11002 // Identity per the equality and tokenizer
11003 return done([{ value: this.join(newString), count: newString.length }]);
11004 }
11005
11006 // Main worker method. checks all permutations of a given edit length for acceptance.
11007 function execEditLength() {
11008 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
11009 var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11010 var addPath = bestPath[diagonalPath - 1],
11011 removePath = bestPath[diagonalPath + 1],
11012 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
11013 if (addPath) {
11014 // No one else is going to attempt to use this value, clear it
11015 bestPath[diagonalPath - 1] = undefined;
11016 }
11017
11018 var canAdd = addPath && addPath.newPos + 1 < newLen,
11019 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
11020 if (!canAdd && !canRemove) {
11021 // If this path is a terminal then prune
11022 bestPath[diagonalPath] = undefined;
11023 continue;
11024 }
11025
11026 // Select the diagonal that we want to branch from. We select the prior
11027 // path whose position in the new string is the farthest from the origin
11028 // and does not pass the bounds of the diff graph
11029 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
11030 basePath = clonePath(removePath);
11031 self.pushComponent(basePath.components, undefined, true);
11032 } else {
11033 basePath = addPath; // No need to clone, we've pulled it from the list
11034 basePath.newPos++;
11035 self.pushComponent(basePath.components, true, undefined);
11036 }
11037
11038 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
11039
11040 // If we have hit the end of both strings, then we are done
11041 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
11042 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
11043 } else {
11044 // Otherwise track this path as a potential candidate and continue.
11045 bestPath[diagonalPath] = basePath;
11046 }
11047 }
11048
11049 editLength++;
11050 }
11051
11052 // Performs the length of edit iteration. Is a bit fugly as this has to support the
11053 // sync and async mode which is never fun. Loops over execEditLength until a value
11054 // is produced.
11055 if (callback) {
11056 (function exec() {
11057 setTimeout(function () {
11058 // This should not happen, but we want to be safe.
11059 /* istanbul ignore next */
11060 if (editLength > maxEditLength) {
11061 return callback();
11062 }
11063
11064 if (!execEditLength()) {
11065 exec();
11066 }
11067 }, 0);
11068 })();
11069 } else {
11070 while (editLength <= maxEditLength) {
11071 var ret = execEditLength();
11072 if (ret) {
11073 return ret;
11074 }
11075 }
11076 }
11077 },
11078 /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
11079 var last = components[components.length - 1];
11080 if (last && last.added === added && last.removed === removed) {
11081 // We need to clone here as the component clone operation is just
11082 // as shallow array clone
11083 components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
11084 } else {
11085 components.push({ count: 1, added: added, removed: removed });
11086 }
11087 },
11088 /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
11089 var newLen = newString.length,
11090 oldLen = oldString.length,
11091 newPos = basePath.newPos,
11092 oldPos = newPos - diagonalPath,
11093 commonCount = 0;
11094 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
11095 newPos++;
11096 oldPos++;
11097 commonCount++;
11098 }
11099
11100 if (commonCount) {
11101 basePath.components.push({ count: commonCount });
11102 }
11103
11104 basePath.newPos = newPos;
11105 return oldPos;
11106 },
11107 /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
11108 if (this.options.comparator) {
11109 return this.options.comparator(left, right);
11110 } else {
11111 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
11112 }
11113 },
11114 /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
11115 var ret = [];
11116 for (var i = 0; i < array.length; i++) {
11117 if (array[i]) {
11118 ret.push(array[i]);
11119 }
11120 }
11121 return ret;
11122 },
11123 /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
11124 return value;
11125 },
11126 /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
11127 return value.split('');
11128 },
11129 /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
11130 return chars.join('');
11131 }
11132 };
11133
11134 function buildValues(diff, components, newString, oldString, useLongestToken) {
11135 var componentPos = 0,
11136 componentLen = components.length,
11137 newPos = 0,
11138 oldPos = 0;
11139
11140 for (; componentPos < componentLen; componentPos++) {
11141 var component = components[componentPos];
11142 if (!component.removed) {
11143 if (!component.added && useLongestToken) {
11144 var value = newString.slice(newPos, newPos + component.count);
11145 value = value.map(function (value, i) {
11146 var oldValue = oldString[oldPos + i];
11147 return oldValue.length > value.length ? oldValue : value;
11148 });
11149
11150 component.value = diff.join(value);
11151 } else {
11152 component.value = diff.join(newString.slice(newPos, newPos + component.count));
11153 }
11154 newPos += component.count;
11155
11156 // Common case
11157 if (!component.added) {
11158 oldPos += component.count;
11159 }
11160 } else {
11161 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
11162 oldPos += component.count;
11163
11164 // Reverse add and remove so removes are output first to match common convention
11165 // The diffing algorithm is tied to add then remove output and this is the simplest
11166 // route to get the desired output with minimal overhead.
11167 if (componentPos && components[componentPos - 1].added) {
11168 var tmp = components[componentPos - 1];
11169 components[componentPos - 1] = components[componentPos];
11170 components[componentPos] = tmp;
11171 }
11172 }
11173 }
11174
11175 // Special case handle for when one terminal is ignored (i.e. whitespace).
11176 // For this case we merge the terminal into the prior string and drop the change.
11177 // This is only available for string mode.
11178 var lastComponent = components[componentLen - 1];
11179 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
11180 components[componentLen - 2].value += lastComponent.value;
11181 components.pop();
11182 }
11183
11184 return components;
11185 }
11186
11187 function clonePath(path) {
11188 return { newPos: path.newPos, components: path.components.slice(0) };
11189 }
11190
11191
11192
11193/***/ }),
11194/* 2 */
11195/***/ (function(module, exports, __webpack_require__) {
11196
11197 /*istanbul ignore start*/'use strict';
11198
11199 exports.__esModule = true;
11200 exports.characterDiff = undefined;
11201 exports. /*istanbul ignore end*/diffChars = diffChars;
11202
11203 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11204
11205 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11206
11207 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11208
11209 /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11210 function diffChars(oldStr, newStr, options) {
11211 return characterDiff.diff(oldStr, newStr, options);
11212 }
11213
11214
11215
11216/***/ }),
11217/* 3 */
11218/***/ (function(module, exports, __webpack_require__) {
11219
11220 /*istanbul ignore start*/'use strict';
11221
11222 exports.__esModule = true;
11223 exports.wordDiff = undefined;
11224 exports. /*istanbul ignore end*/diffWords = diffWords;
11225 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
11226
11227 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11228
11229 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11230
11231 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
11232
11233 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11234
11235 /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
11236 //
11237 // Ranges and exceptions:
11238 // Latin-1 Supplement, 0080–00FF
11239 // - U+00D7 × Multiplication sign
11240 // - U+00F7 ÷ Division sign
11241 // Latin Extended-A, 0100–017F
11242 // Latin Extended-B, 0180–024F
11243 // IPA Extensions, 0250–02AF
11244 // Spacing Modifier Letters, 02B0–02FF
11245 // - U+02C7 ˇ &#711; Caron
11246 // - U+02D8 ˘ &#728; Breve
11247 // - U+02D9 ˙ &#729; Dot Above
11248 // - U+02DA ˚ &#730; Ring Above
11249 // - U+02DB ˛ &#731; Ogonek
11250 // - U+02DC ˜ &#732; Small Tilde
11251 // - U+02DD ˝ &#733; Double Acute Accent
11252 // Latin Extended Additional, 1E00–1EFF
11253 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
11254
11255 var reWhitespace = /\S/;
11256
11257 var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11258 wordDiff.equals = function (left, right) {
11259 if (this.options.ignoreCase) {
11260 left = left.toLowerCase();
11261 right = right.toLowerCase();
11262 }
11263 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
11264 };
11265 wordDiff.tokenize = function (value) {
11266 var tokens = value.split(/(\s+|\b)/);
11267
11268 // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
11269 for (var i = 0; i < tokens.length - 1; i++) {
11270 // If we have an empty string in the next field and we have only word chars before and after, merge
11271 if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
11272 tokens[i] += tokens[i + 2];
11273 tokens.splice(i + 1, 2);
11274 i--;
11275 }
11276 }
11277
11278 return tokens;
11279 };
11280
11281 function diffWords(oldStr, newStr, options) {
11282 options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
11283 return wordDiff.diff(oldStr, newStr, options);
11284 }
11285
11286 function diffWordsWithSpace(oldStr, newStr, options) {
11287 return wordDiff.diff(oldStr, newStr, options);
11288 }
11289
11290
11291
11292/***/ }),
11293/* 4 */
11294/***/ (function(module, exports) {
11295
11296 /*istanbul ignore start*/'use strict';
11297
11298 exports.__esModule = true;
11299 exports. /*istanbul ignore end*/generateOptions = generateOptions;
11300 function generateOptions(options, defaults) {
11301 if (typeof options === 'function') {
11302 defaults.callback = options;
11303 } else if (options) {
11304 for (var name in options) {
11305 /* istanbul ignore else */
11306 if (options.hasOwnProperty(name)) {
11307 defaults[name] = options[name];
11308 }
11309 }
11310 }
11311 return defaults;
11312 }
11313
11314
11315
11316/***/ }),
11317/* 5 */
11318/***/ (function(module, exports, __webpack_require__) {
11319
11320 /*istanbul ignore start*/'use strict';
11321
11322 exports.__esModule = true;
11323 exports.lineDiff = undefined;
11324 exports. /*istanbul ignore end*/diffLines = diffLines;
11325 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
11326
11327 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11328
11329 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11330
11331 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
11332
11333 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11334
11335 /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11336 lineDiff.tokenize = function (value) {
11337 var retLines = [],
11338 linesAndNewlines = value.split(/(\n|\r\n)/);
11339
11340 // Ignore the final empty token that occurs if the string ends with a new line
11341 if (!linesAndNewlines[linesAndNewlines.length - 1]) {
11342 linesAndNewlines.pop();
11343 }
11344
11345 // Merge the content and line separators into single tokens
11346 for (var i = 0; i < linesAndNewlines.length; i++) {
11347 var line = linesAndNewlines[i];
11348
11349 if (i % 2 && !this.options.newlineIsToken) {
11350 retLines[retLines.length - 1] += line;
11351 } else {
11352 if (this.options.ignoreWhitespace) {
11353 line = line.trim();
11354 }
11355 retLines.push(line);
11356 }
11357 }
11358
11359 return retLines;
11360 };
11361
11362 function diffLines(oldStr, newStr, callback) {
11363 return lineDiff.diff(oldStr, newStr, callback);
11364 }
11365 function diffTrimmedLines(oldStr, newStr, callback) {
11366 var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
11367 return lineDiff.diff(oldStr, newStr, options);
11368 }
11369
11370
11371
11372/***/ }),
11373/* 6 */
11374/***/ (function(module, exports, __webpack_require__) {
11375
11376 /*istanbul ignore start*/'use strict';
11377
11378 exports.__esModule = true;
11379 exports.sentenceDiff = undefined;
11380 exports. /*istanbul ignore end*/diffSentences = diffSentences;
11381
11382 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11383
11384 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11385
11386 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11387
11388 /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11389 sentenceDiff.tokenize = function (value) {
11390 return value.split(/(\S.+?[.!?])(?=\s+|$)/);
11391 };
11392
11393 function diffSentences(oldStr, newStr, callback) {
11394 return sentenceDiff.diff(oldStr, newStr, callback);
11395 }
11396
11397
11398
11399/***/ }),
11400/* 7 */
11401/***/ (function(module, exports, __webpack_require__) {
11402
11403 /*istanbul ignore start*/'use strict';
11404
11405 exports.__esModule = true;
11406 exports.cssDiff = undefined;
11407 exports. /*istanbul ignore end*/diffCss = diffCss;
11408
11409 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11410
11411 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11412
11413 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11414
11415 /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11416 cssDiff.tokenize = function (value) {
11417 return value.split(/([{}:;,]|\s+)/);
11418 };
11419
11420 function diffCss(oldStr, newStr, callback) {
11421 return cssDiff.diff(oldStr, newStr, callback);
11422 }
11423
11424
11425
11426/***/ }),
11427/* 8 */
11428/***/ (function(module, exports, __webpack_require__) {
11429
11430 /*istanbul ignore start*/'use strict';
11431
11432 exports.__esModule = true;
11433 exports.jsonDiff = undefined;
11434
11435 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; };
11436
11437 exports. /*istanbul ignore end*/diffJson = diffJson;
11438 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
11439
11440 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11441
11442 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11443
11444 /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
11445
11446 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11447
11448 /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
11449
11450 var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11451 // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
11452 // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
11453 jsonDiff.useLongestToken = true;
11454
11455 jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
11456 jsonDiff.castInput = function (value) {
11457 /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
11458 undefinedReplacement = _options.undefinedReplacement,
11459 _options$stringifyRep = _options.stringifyReplacer,
11460 stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
11461 return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
11462 );
11463 } : _options$stringifyRep;
11464
11465
11466 return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
11467 };
11468 jsonDiff.equals = function (left, right) {
11469 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'))
11470 );
11471 };
11472
11473 function diffJson(oldObj, newObj, options) {
11474 return jsonDiff.diff(oldObj, newObj, options);
11475 }
11476
11477 // This function handles the presence of circular references by bailing out when encountering an
11478 // object that is already on the "stack" of items being processed. Accepts an optional replacer
11479 function canonicalize(obj, stack, replacementStack, replacer, key) {
11480 stack = stack || [];
11481 replacementStack = replacementStack || [];
11482
11483 if (replacer) {
11484 obj = replacer(key, obj);
11485 }
11486
11487 var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11488
11489 for (i = 0; i < stack.length; i += 1) {
11490 if (stack[i] === obj) {
11491 return replacementStack[i];
11492 }
11493 }
11494
11495 var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11496
11497 if ('[object Array]' === objectPrototypeToString.call(obj)) {
11498 stack.push(obj);
11499 canonicalizedObj = new Array(obj.length);
11500 replacementStack.push(canonicalizedObj);
11501 for (i = 0; i < obj.length; i += 1) {
11502 canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
11503 }
11504 stack.pop();
11505 replacementStack.pop();
11506 return canonicalizedObj;
11507 }
11508
11509 if (obj && obj.toJSON) {
11510 obj = obj.toJSON();
11511 }
11512
11513 if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
11514 stack.push(obj);
11515 canonicalizedObj = {};
11516 replacementStack.push(canonicalizedObj);
11517 var sortedKeys = [],
11518 _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11519 for (_key in obj) {
11520 /* istanbul ignore else */
11521 if (obj.hasOwnProperty(_key)) {
11522 sortedKeys.push(_key);
11523 }
11524 }
11525 sortedKeys.sort();
11526 for (i = 0; i < sortedKeys.length; i += 1) {
11527 _key = sortedKeys[i];
11528 canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
11529 }
11530 stack.pop();
11531 replacementStack.pop();
11532 } else {
11533 canonicalizedObj = obj;
11534 }
11535 return canonicalizedObj;
11536 }
11537
11538
11539
11540/***/ }),
11541/* 9 */
11542/***/ (function(module, exports, __webpack_require__) {
11543
11544 /*istanbul ignore start*/'use strict';
11545
11546 exports.__esModule = true;
11547 exports.arrayDiff = undefined;
11548 exports. /*istanbul ignore end*/diffArrays = diffArrays;
11549
11550 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
11551
11552 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
11553
11554 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11555
11556 /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
11557 arrayDiff.tokenize = function (value) {
11558 return value.slice();
11559 };
11560 arrayDiff.join = arrayDiff.removeEmpty = function (value) {
11561 return value;
11562 };
11563
11564 function diffArrays(oldArr, newArr, callback) {
11565 return arrayDiff.diff(oldArr, newArr, callback);
11566 }
11567
11568
11569
11570/***/ }),
11571/* 10 */
11572/***/ (function(module, exports, __webpack_require__) {
11573
11574 /*istanbul ignore start*/'use strict';
11575
11576 exports.__esModule = true;
11577 exports. /*istanbul ignore end*/applyPatch = applyPatch;
11578 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
11579
11580 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
11581
11582 var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/;
11583
11584 /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
11585
11586 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
11587
11588 /*istanbul ignore end*/function applyPatch(source, uniDiff) {
11589 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11590
11591 if (typeof uniDiff === 'string') {
11592 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
11593 }
11594
11595 if (Array.isArray(uniDiff)) {
11596 if (uniDiff.length > 1) {
11597 throw new Error('applyPatch only works with a single input.');
11598 }
11599
11600 uniDiff = uniDiff[0];
11601 }
11602
11603 // Apply the diff to the input
11604 var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
11605 delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
11606 hunks = uniDiff.hunks,
11607 compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
11608 return (/*istanbul ignore end*/line === patchContent
11609 );
11610 },
11611 errorCount = 0,
11612 fuzzFactor = options.fuzzFactor || 0,
11613 minLine = 0,
11614 offset = 0,
11615 removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
11616 addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
11617
11618 /**
11619 * Checks if the hunk exactly fits on the provided location
11620 */
11621 function hunkFits(hunk, toPos) {
11622 for (var j = 0; j < hunk.lines.length; j++) {
11623 var line = hunk.lines[j],
11624 operation = line.length > 0 ? line[0] : ' ',
11625 content = line.length > 0 ? line.substr(1) : line;
11626
11627 if (operation === ' ' || operation === '-') {
11628 // Context sanity check
11629 if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
11630 errorCount++;
11631
11632 if (errorCount > fuzzFactor) {
11633 return false;
11634 }
11635 }
11636 toPos++;
11637 }
11638 }
11639
11640 return true;
11641 }
11642
11643 // Search best fit offsets for each hunk based on the previous ones
11644 for (var i = 0; i < hunks.length; i++) {
11645 var hunk = hunks[i],
11646 maxLine = lines.length - hunk.oldLines,
11647 localOffset = 0,
11648 toPos = offset + hunk.oldStart - 1;
11649
11650 var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
11651
11652 for (; localOffset !== undefined; localOffset = iterator()) {
11653 if (hunkFits(hunk, toPos + localOffset)) {
11654 hunk.offset = offset += localOffset;
11655 break;
11656 }
11657 }
11658
11659 if (localOffset === undefined) {
11660 return false;
11661 }
11662
11663 // Set lower text limit to end of the current hunk, so next ones don't try
11664 // to fit over already patched text
11665 minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
11666 }
11667
11668 // Apply patch hunks
11669 var diffOffset = 0;
11670 for (var _i = 0; _i < hunks.length; _i++) {
11671 var _hunk = hunks[_i],
11672 _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
11673 diffOffset += _hunk.newLines - _hunk.oldLines;
11674
11675 if (_toPos < 0) {
11676 // Creating a new file
11677 _toPos = 0;
11678 }
11679
11680 for (var j = 0; j < _hunk.lines.length; j++) {
11681 var line = _hunk.lines[j],
11682 operation = line.length > 0 ? line[0] : ' ',
11683 content = line.length > 0 ? line.substr(1) : line,
11684 delimiter = _hunk.linedelimiters[j];
11685
11686 if (operation === ' ') {
11687 _toPos++;
11688 } else if (operation === '-') {
11689 lines.splice(_toPos, 1);
11690 delimiters.splice(_toPos, 1);
11691 /* istanbul ignore else */
11692 } else if (operation === '+') {
11693 lines.splice(_toPos, 0, content);
11694 delimiters.splice(_toPos, 0, delimiter);
11695 _toPos++;
11696 } else if (operation === '\\') {
11697 var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
11698 if (previousOperation === '+') {
11699 removeEOFNL = true;
11700 } else if (previousOperation === '-') {
11701 addEOFNL = true;
11702 }
11703 }
11704 }
11705 }
11706
11707 // Handle EOFNL insertion/removal
11708 if (removeEOFNL) {
11709 while (!lines[lines.length - 1]) {
11710 lines.pop();
11711 delimiters.pop();
11712 }
11713 } else if (addEOFNL) {
11714 lines.push('');
11715 delimiters.push('\n');
11716 }
11717 for (var _k = 0; _k < lines.length - 1; _k++) {
11718 lines[_k] = lines[_k] + delimiters[_k];
11719 }
11720 return lines.join('');
11721 }
11722
11723 // Wrapper that supports multiple file patches via callbacks.
11724 function applyPatches(uniDiff, options) {
11725 if (typeof uniDiff === 'string') {
11726 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
11727 }
11728
11729 var currentIndex = 0;
11730 function processIndex() {
11731 var index = uniDiff[currentIndex++];
11732 if (!index) {
11733 return options.complete();
11734 }
11735
11736 options.loadFile(index, function (err, data) {
11737 if (err) {
11738 return options.complete(err);
11739 }
11740
11741 var updatedContent = applyPatch(data, index, options);
11742 options.patched(index, updatedContent, function (err) {
11743 if (err) {
11744 return options.complete(err);
11745 }
11746
11747 processIndex();
11748 });
11749 });
11750 }
11751 processIndex();
11752 }
11753
11754
11755
11756/***/ }),
11757/* 11 */
11758/***/ (function(module, exports) {
11759
11760 /*istanbul ignore start*/'use strict';
11761
11762 exports.__esModule = true;
11763 exports. /*istanbul ignore end*/parsePatch = parsePatch;
11764 function parsePatch(uniDiff) {
11765 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
11766
11767 var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
11768 delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
11769 list = [],
11770 i = 0;
11771
11772 function parseIndex() {
11773 var index = {};
11774 list.push(index);
11775
11776 // Parse diff metadata
11777 while (i < diffstr.length) {
11778 var line = diffstr[i];
11779
11780 // File header found, end parsing diff metadata
11781 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
11782 break;
11783 }
11784
11785 // Diff index
11786 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
11787 if (header) {
11788 index.index = header[1];
11789 }
11790
11791 i++;
11792 }
11793
11794 // Parse file headers if they are defined. Unified diff requires them, but
11795 // there's no technical issues to have an isolated hunk without file header
11796 parseFileHeader(index);
11797 parseFileHeader(index);
11798
11799 // Parse hunks
11800 index.hunks = [];
11801
11802 while (i < diffstr.length) {
11803 var _line = diffstr[i];
11804
11805 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
11806 break;
11807 } else if (/^@@/.test(_line)) {
11808 index.hunks.push(parseHunk());
11809 } else if (_line && options.strict) {
11810 // Ignore unexpected content unless in strict mode
11811 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
11812 } else {
11813 i++;
11814 }
11815 }
11816 }
11817
11818 // Parses the --- and +++ headers, if none are found, no lines
11819 // are consumed.
11820 function parseFileHeader(index) {
11821 var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
11822 if (fileHeader) {
11823 var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
11824 var data = fileHeader[2].split('\t', 2);
11825 var fileName = data[0].replace(/\\\\/g, '\\');
11826 if (/^".*"$/.test(fileName)) {
11827 fileName = fileName.substr(1, fileName.length - 2);
11828 }
11829 index[keyPrefix + 'FileName'] = fileName;
11830 index[keyPrefix + 'Header'] = (data[1] || '').trim();
11831
11832 i++;
11833 }
11834 }
11835
11836 // Parses a hunk
11837 // This assumes that we are at the start of a hunk.
11838 function parseHunk() {
11839 var chunkHeaderIndex = i,
11840 chunkHeaderLine = diffstr[i++],
11841 chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
11842
11843 var hunk = {
11844 oldStart: +chunkHeader[1],
11845 oldLines: +chunkHeader[2] || 1,
11846 newStart: +chunkHeader[3],
11847 newLines: +chunkHeader[4] || 1,
11848 lines: [],
11849 linedelimiters: []
11850 };
11851
11852 var addCount = 0,
11853 removeCount = 0;
11854 for (; i < diffstr.length; i++) {
11855 // Lines starting with '---' could be mistaken for the "remove line" operation
11856 // But they could be the header for the next file. Therefore prune such cases out.
11857 if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
11858 break;
11859 }
11860 var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
11861
11862 if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
11863 hunk.lines.push(diffstr[i]);
11864 hunk.linedelimiters.push(delimiters[i] || '\n');
11865
11866 if (operation === '+') {
11867 addCount++;
11868 } else if (operation === '-') {
11869 removeCount++;
11870 } else if (operation === ' ') {
11871 addCount++;
11872 removeCount++;
11873 }
11874 } else {
11875 break;
11876 }
11877 }
11878
11879 // Handle the empty block count case
11880 if (!addCount && hunk.newLines === 1) {
11881 hunk.newLines = 0;
11882 }
11883 if (!removeCount && hunk.oldLines === 1) {
11884 hunk.oldLines = 0;
11885 }
11886
11887 // Perform optional sanity checking
11888 if (options.strict) {
11889 if (addCount !== hunk.newLines) {
11890 throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
11891 }
11892 if (removeCount !== hunk.oldLines) {
11893 throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
11894 }
11895 }
11896
11897 return hunk;
11898 }
11899
11900 while (i < diffstr.length) {
11901 parseIndex();
11902 }
11903
11904 return list;
11905 }
11906
11907
11908
11909/***/ }),
11910/* 12 */
11911/***/ (function(module, exports) {
11912
11913 /*istanbul ignore start*/"use strict";
11914
11915 exports.__esModule = true;
11916
11917 exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
11918 var wantForward = true,
11919 backwardExhausted = false,
11920 forwardExhausted = false,
11921 localOffset = 1;
11922
11923 return function iterator() {
11924 if (wantForward && !forwardExhausted) {
11925 if (backwardExhausted) {
11926 localOffset++;
11927 } else {
11928 wantForward = false;
11929 }
11930
11931 // Check if trying to fit beyond text length, and if not, check it fits
11932 // after offset location (or desired location on first iteration)
11933 if (start + localOffset <= maxLine) {
11934 return localOffset;
11935 }
11936
11937 forwardExhausted = true;
11938 }
11939
11940 if (!backwardExhausted) {
11941 if (!forwardExhausted) {
11942 wantForward = true;
11943 }
11944
11945 // Check if trying to fit before text beginning, and if not, check it fits
11946 // before offset location
11947 if (minLine <= start - localOffset) {
11948 return -localOffset++;
11949 }
11950
11951 backwardExhausted = true;
11952 return iterator();
11953 }
11954
11955 // We tried to fit hunk before text beginning and beyond text length, then
11956 // hunk can't fit on the text. Return undefined
11957 };
11958 };
11959
11960
11961
11962/***/ }),
11963/* 13 */
11964/***/ (function(module, exports, __webpack_require__) {
11965
11966 /*istanbul ignore start*/'use strict';
11967
11968 exports.__esModule = true;
11969 exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
11970 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
11971
11972 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
11973
11974 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
11975
11976 var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/;
11977
11978 /*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); } }
11979
11980 /*istanbul ignore end*/function calcLineCount(hunk) {
11981 /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
11982 oldLines = _calcOldNewLineCount.oldLines,
11983 newLines = _calcOldNewLineCount.newLines;
11984
11985 if (oldLines !== undefined) {
11986 hunk.oldLines = oldLines;
11987 } else {
11988 delete hunk.oldLines;
11989 }
11990
11991 if (newLines !== undefined) {
11992 hunk.newLines = newLines;
11993 } else {
11994 delete hunk.newLines;
11995 }
11996 }
11997
11998 function merge(mine, theirs, base) {
11999 mine = loadPatch(mine, base);
12000 theirs = loadPatch(theirs, base);
12001
12002 var ret = {};
12003
12004 // For index we just let it pass through as it doesn't have any necessary meaning.
12005 // Leaving sanity checks on this to the API consumer that may know more about the
12006 // meaning in their own context.
12007 if (mine.index || theirs.index) {
12008 ret.index = mine.index || theirs.index;
12009 }
12010
12011 if (mine.newFileName || theirs.newFileName) {
12012 if (!fileNameChanged(mine)) {
12013 // No header or no change in ours, use theirs (and ours if theirs does not exist)
12014 ret.oldFileName = theirs.oldFileName || mine.oldFileName;
12015 ret.newFileName = theirs.newFileName || mine.newFileName;
12016 ret.oldHeader = theirs.oldHeader || mine.oldHeader;
12017 ret.newHeader = theirs.newHeader || mine.newHeader;
12018 } else if (!fileNameChanged(theirs)) {
12019 // No header or no change in theirs, use ours
12020 ret.oldFileName = mine.oldFileName;
12021 ret.newFileName = mine.newFileName;
12022 ret.oldHeader = mine.oldHeader;
12023 ret.newHeader = mine.newHeader;
12024 } else {
12025 // Both changed... figure it out
12026 ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
12027 ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
12028 ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
12029 ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
12030 }
12031 }
12032
12033 ret.hunks = [];
12034
12035 var mineIndex = 0,
12036 theirsIndex = 0,
12037 mineOffset = 0,
12038 theirsOffset = 0;
12039
12040 while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
12041 var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
12042 theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
12043
12044 if (hunkBefore(mineCurrent, theirsCurrent)) {
12045 // This patch does not overlap with any of the others, yay.
12046 ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
12047 mineIndex++;
12048 theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
12049 } else if (hunkBefore(theirsCurrent, mineCurrent)) {
12050 // This patch does not overlap with any of the others, yay.
12051 ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
12052 theirsIndex++;
12053 mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
12054 } else {
12055 // Overlap, merge as best we can
12056 var mergedHunk = {
12057 oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
12058 oldLines: 0,
12059 newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
12060 newLines: 0,
12061 lines: []
12062 };
12063 mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
12064 theirsIndex++;
12065 mineIndex++;
12066
12067 ret.hunks.push(mergedHunk);
12068 }
12069 }
12070
12071 return ret;
12072 }
12073
12074 function loadPatch(param, base) {
12075 if (typeof param === 'string') {
12076 if (/^@@/m.test(param) || /^Index:/m.test(param)) {
12077 return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0]
12078 );
12079 }
12080
12081 if (!base) {
12082 throw new Error('Must provide a base reference or pass in a patch');
12083 }
12084 return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
12085 );
12086 }
12087
12088 return param;
12089 }
12090
12091 function fileNameChanged(patch) {
12092 return patch.newFileName && patch.newFileName !== patch.oldFileName;
12093 }
12094
12095 function selectField(index, mine, theirs) {
12096 if (mine === theirs) {
12097 return mine;
12098 } else {
12099 index.conflict = true;
12100 return { mine: mine, theirs: theirs };
12101 }
12102 }
12103
12104 function hunkBefore(test, check) {
12105 return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
12106 }
12107
12108 function cloneHunk(hunk, offset) {
12109 return {
12110 oldStart: hunk.oldStart, oldLines: hunk.oldLines,
12111 newStart: hunk.newStart + offset, newLines: hunk.newLines,
12112 lines: hunk.lines
12113 };
12114 }
12115
12116 function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
12117 // This will generally result in a conflicted hunk, but there are cases where the context
12118 // is the only overlap where we can successfully merge the content here.
12119 var mine = { offset: mineOffset, lines: mineLines, index: 0 },
12120 their = { offset: theirOffset, lines: theirLines, index: 0 };
12121
12122 // Handle any leading content
12123 insertLeading(hunk, mine, their);
12124 insertLeading(hunk, their, mine);
12125
12126 // Now in the overlap content. Scan through and select the best changes from each.
12127 while (mine.index < mine.lines.length && their.index < their.lines.length) {
12128 var mineCurrent = mine.lines[mine.index],
12129 theirCurrent = their.lines[their.index];
12130
12131 if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
12132 // Both modified ...
12133 mutualChange(hunk, mine, their);
12134 } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
12135 /*istanbul ignore start*/var _hunk$lines;
12136
12137 /*istanbul ignore end*/ // Mine inserted
12138 /*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)));
12139 } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
12140 /*istanbul ignore start*/var _hunk$lines2;
12141
12142 /*istanbul ignore end*/ // Theirs inserted
12143 /*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)));
12144 } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
12145 // Mine removed or edited
12146 removal(hunk, mine, their);
12147 } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
12148 // Their removed or edited
12149 removal(hunk, their, mine, true);
12150 } else if (mineCurrent === theirCurrent) {
12151 // Context identity
12152 hunk.lines.push(mineCurrent);
12153 mine.index++;
12154 their.index++;
12155 } else {
12156 // Context mismatch
12157 conflict(hunk, collectChange(mine), collectChange(their));
12158 }
12159 }
12160
12161 // Now push anything that may be remaining
12162 insertTrailing(hunk, mine);
12163 insertTrailing(hunk, their);
12164
12165 calcLineCount(hunk);
12166 }
12167
12168 function mutualChange(hunk, mine, their) {
12169 var myChanges = collectChange(mine),
12170 theirChanges = collectChange(their);
12171
12172 if (allRemoves(myChanges) && allRemoves(theirChanges)) {
12173 // Special case for remove changes that are supersets of one another
12174 if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
12175 /*istanbul ignore start*/var _hunk$lines3;
12176
12177 /*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));
12178 return;
12179 } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
12180 /*istanbul ignore start*/var _hunk$lines4;
12181
12182 /*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));
12183 return;
12184 }
12185 } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
12186 /*istanbul ignore start*/var _hunk$lines5;
12187
12188 /*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));
12189 return;
12190 }
12191
12192 conflict(hunk, myChanges, theirChanges);
12193 }
12194
12195 function removal(hunk, mine, their, swap) {
12196 var myChanges = collectChange(mine),
12197 theirChanges = collectContext(their, myChanges);
12198 if (theirChanges.merged) {
12199 /*istanbul ignore start*/var _hunk$lines6;
12200
12201 /*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));
12202 } else {
12203 conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
12204 }
12205 }
12206
12207 function conflict(hunk, mine, their) {
12208 hunk.conflict = true;
12209 hunk.lines.push({
12210 conflict: true,
12211 mine: mine,
12212 theirs: their
12213 });
12214 }
12215
12216 function insertLeading(hunk, insert, their) {
12217 while (insert.offset < their.offset && insert.index < insert.lines.length) {
12218 var line = insert.lines[insert.index++];
12219 hunk.lines.push(line);
12220 insert.offset++;
12221 }
12222 }
12223 function insertTrailing(hunk, insert) {
12224 while (insert.index < insert.lines.length) {
12225 var line = insert.lines[insert.index++];
12226 hunk.lines.push(line);
12227 }
12228 }
12229
12230 function collectChange(state) {
12231 var ret = [],
12232 operation = state.lines[state.index][0];
12233 while (state.index < state.lines.length) {
12234 var line = state.lines[state.index];
12235
12236 // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
12237 if (operation === '-' && line[0] === '+') {
12238 operation = '+';
12239 }
12240
12241 if (operation === line[0]) {
12242 ret.push(line);
12243 state.index++;
12244 } else {
12245 break;
12246 }
12247 }
12248
12249 return ret;
12250 }
12251 function collectContext(state, matchChanges) {
12252 var changes = [],
12253 merged = [],
12254 matchIndex = 0,
12255 contextChanges = false,
12256 conflicted = false;
12257 while (matchIndex < matchChanges.length && state.index < state.lines.length) {
12258 var change = state.lines[state.index],
12259 match = matchChanges[matchIndex];
12260
12261 // Once we've hit our add, then we are done
12262 if (match[0] === '+') {
12263 break;
12264 }
12265
12266 contextChanges = contextChanges || change[0] !== ' ';
12267
12268 merged.push(match);
12269 matchIndex++;
12270
12271 // Consume any additions in the other block as a conflict to attempt
12272 // to pull in the remaining context after this
12273 if (change[0] === '+') {
12274 conflicted = true;
12275
12276 while (change[0] === '+') {
12277 changes.push(change);
12278 change = state.lines[++state.index];
12279 }
12280 }
12281
12282 if (match.substr(1) === change.substr(1)) {
12283 changes.push(change);
12284 state.index++;
12285 } else {
12286 conflicted = true;
12287 }
12288 }
12289
12290 if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
12291 conflicted = true;
12292 }
12293
12294 if (conflicted) {
12295 return changes;
12296 }
12297
12298 while (matchIndex < matchChanges.length) {
12299 merged.push(matchChanges[matchIndex++]);
12300 }
12301
12302 return {
12303 merged: merged,
12304 changes: changes
12305 };
12306 }
12307
12308 function allRemoves(changes) {
12309 return changes.reduce(function (prev, change) {
12310 return prev && change[0] === '-';
12311 }, true);
12312 }
12313 function skipRemoveSuperset(state, removeChanges, delta) {
12314 for (var i = 0; i < delta; i++) {
12315 var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
12316 if (state.lines[state.index + i] !== ' ' + changeContent) {
12317 return false;
12318 }
12319 }
12320
12321 state.index += delta;
12322 return true;
12323 }
12324
12325 function calcOldNewLineCount(lines) {
12326 var oldLines = 0;
12327 var newLines = 0;
12328
12329 lines.forEach(function (line) {
12330 if (typeof line !== 'string') {
12331 var myCount = calcOldNewLineCount(line.mine);
12332 var theirCount = calcOldNewLineCount(line.theirs);
12333
12334 if (oldLines !== undefined) {
12335 if (myCount.oldLines === theirCount.oldLines) {
12336 oldLines += myCount.oldLines;
12337 } else {
12338 oldLines = undefined;
12339 }
12340 }
12341
12342 if (newLines !== undefined) {
12343 if (myCount.newLines === theirCount.newLines) {
12344 newLines += myCount.newLines;
12345 } else {
12346 newLines = undefined;
12347 }
12348 }
12349 } else {
12350 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
12351 newLines++;
12352 }
12353 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
12354 oldLines++;
12355 }
12356 }
12357 });
12358
12359 return { oldLines: oldLines, newLines: newLines };
12360 }
12361
12362
12363
12364/***/ }),
12365/* 14 */
12366/***/ (function(module, exports, __webpack_require__) {
12367
12368 /*istanbul ignore start*/'use strict';
12369
12370 exports.__esModule = true;
12371 exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
12372 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
12373 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
12374
12375 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
12376
12377 /*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); } }
12378
12379 /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
12380 if (!options) {
12381 options = {};
12382 }
12383 if (typeof options.context === 'undefined') {
12384 options.context = 4;
12385 }
12386
12387 var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
12388 diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
12389
12390 function contextLines(lines) {
12391 return lines.map(function (entry) {
12392 return ' ' + entry;
12393 });
12394 }
12395
12396 var hunks = [];
12397 var oldRangeStart = 0,
12398 newRangeStart = 0,
12399 curRange = [],
12400 oldLine = 1,
12401 newLine = 1;
12402
12403 /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
12404 var current = diff[i],
12405 lines = current.lines || current.value.replace(/\n$/, '').split('\n');
12406 current.lines = lines;
12407
12408 if (current.added || current.removed) {
12409 /*istanbul ignore start*/var _curRange;
12410
12411 /*istanbul ignore end*/ // If we have previous context, start with that
12412 if (!oldRangeStart) {
12413 var prev = diff[i - 1];
12414 oldRangeStart = oldLine;
12415 newRangeStart = newLine;
12416
12417 if (prev) {
12418 curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
12419 oldRangeStart -= curRange.length;
12420 newRangeStart -= curRange.length;
12421 }
12422 }
12423
12424 // Output our changes
12425 /*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) {
12426 return (current.added ? '+' : '-') + entry;
12427 })));
12428
12429 // Track the updated file position
12430 if (current.added) {
12431 newLine += lines.length;
12432 } else {
12433 oldLine += lines.length;
12434 }
12435 } else {
12436 // Identical context lines. Track line changes
12437 if (oldRangeStart) {
12438 // Close out any changes that have been output (or join overlapping)
12439 if (lines.length <= options.context * 2 && i < diff.length - 2) {
12440 /*istanbul ignore start*/var _curRange2;
12441
12442 /*istanbul ignore end*/ // Overlapping
12443 /*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)));
12444 } else {
12445 /*istanbul ignore start*/var _curRange3;
12446
12447 /*istanbul ignore end*/ // end the range and output
12448 var contextSize = Math.min(lines.length, options.context);
12449 /*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))));
12450
12451 var hunk = {
12452 oldStart: oldRangeStart,
12453 oldLines: oldLine - oldRangeStart + contextSize,
12454 newStart: newRangeStart,
12455 newLines: newLine - newRangeStart + contextSize,
12456 lines: curRange
12457 };
12458 if (i >= diff.length - 2 && lines.length <= options.context) {
12459 // EOF is inside this hunk
12460 var oldEOFNewline = /\n$/.test(oldStr);
12461 var newEOFNewline = /\n$/.test(newStr);
12462 if (lines.length == 0 && !oldEOFNewline) {
12463 // special case: old has no eol and no trailing context; no-nl can end up before adds
12464 curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
12465 } else if (!oldEOFNewline || !newEOFNewline) {
12466 curRange.push('\\ No newline at end of file');
12467 }
12468 }
12469 hunks.push(hunk);
12470
12471 oldRangeStart = 0;
12472 newRangeStart = 0;
12473 curRange = [];
12474 }
12475 }
12476 oldLine += lines.length;
12477 newLine += lines.length;
12478 }
12479 };
12480
12481 for (var i = 0; i < diff.length; i++) {
12482 /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
12483 }
12484
12485 return {
12486 oldFileName: oldFileName, newFileName: newFileName,
12487 oldHeader: oldHeader, newHeader: newHeader,
12488 hunks: hunks
12489 };
12490 }
12491
12492 function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
12493 var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
12494
12495 var ret = [];
12496 if (oldFileName == newFileName) {
12497 ret.push('Index: ' + oldFileName);
12498 }
12499 ret.push('===================================================================');
12500 ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
12501 ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
12502
12503 for (var i = 0; i < diff.hunks.length; i++) {
12504 var hunk = diff.hunks[i];
12505 ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
12506 ret.push.apply(ret, hunk.lines);
12507 }
12508
12509 return ret.join('\n') + '\n';
12510 }
12511
12512 function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
12513 return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
12514 }
12515
12516
12517
12518/***/ }),
12519/* 15 */
12520/***/ (function(module, exports) {
12521
12522 /*istanbul ignore start*/"use strict";
12523
12524 exports.__esModule = true;
12525 exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
12526 /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
12527 function arrayEqual(a, b) {
12528 if (a.length !== b.length) {
12529 return false;
12530 }
12531
12532 return arrayStartsWith(a, b);
12533 }
12534
12535 function arrayStartsWith(array, start) {
12536 if (start.length > array.length) {
12537 return false;
12538 }
12539
12540 for (var i = 0; i < start.length; i++) {
12541 if (start[i] !== array[i]) {
12542 return false;
12543 }
12544 }
12545
12546 return true;
12547 }
12548
12549
12550
12551/***/ }),
12552/* 16 */
12553/***/ (function(module, exports) {
12554
12555 /*istanbul ignore start*/"use strict";
12556
12557 exports.__esModule = true;
12558 exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
12559 // See: http://code.google.com/p/google-diff-match-patch/wiki/API
12560 function convertChangesToDMP(changes) {
12561 var ret = [],
12562 change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
12563 operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
12564 for (var i = 0; i < changes.length; i++) {
12565 change = changes[i];
12566 if (change.added) {
12567 operation = 1;
12568 } else if (change.removed) {
12569 operation = -1;
12570 } else {
12571 operation = 0;
12572 }
12573
12574 ret.push([operation, change.value]);
12575 }
12576 return ret;
12577 }
12578
12579
12580
12581/***/ }),
12582/* 17 */
12583/***/ (function(module, exports) {
12584
12585 /*istanbul ignore start*/'use strict';
12586
12587 exports.__esModule = true;
12588 exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
12589 function convertChangesToXML(changes) {
12590 var ret = [];
12591 for (var i = 0; i < changes.length; i++) {
12592 var change = changes[i];
12593 if (change.added) {
12594 ret.push('<ins>');
12595 } else if (change.removed) {
12596 ret.push('<del>');
12597 }
12598
12599 ret.push(escapeHTML(change.value));
12600
12601 if (change.added) {
12602 ret.push('</ins>');
12603 } else if (change.removed) {
12604 ret.push('</del>');
12605 }
12606 }
12607 return ret.join('');
12608 }
12609
12610 function escapeHTML(s) {
12611 var n = s;
12612 n = n.replace(/&/g, '&amp;');
12613 n = n.replace(/</g, '&lt;');
12614 n = n.replace(/>/g, '&gt;');
12615 n = n.replace(/"/g, '&quot;');
12616
12617 return n;
12618 }
12619
12620
12621
12622/***/ })
12623/******/ ])
12624});
12625;
12626},{}],49:[function(require,module,exports){
12627'use strict';
12628
12629var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
12630
12631module.exports = function (str) {
12632 if (typeof str !== 'string') {
12633 throw new TypeError('Expected a string');
12634 }
12635
12636 return str.replace(matchOperatorsRe, '\\$&');
12637};
12638
12639},{}],50:[function(require,module,exports){
12640// Copyright Joyent, Inc. and other Node contributors.
12641//
12642// Permission is hereby granted, free of charge, to any person obtaining a
12643// copy of this software and associated documentation files (the
12644// "Software"), to deal in the Software without restriction, including
12645// without limitation the rights to use, copy, modify, merge, publish,
12646// distribute, sublicense, and/or sell copies of the Software, and to permit
12647// persons to whom the Software is furnished to do so, subject to the
12648// following conditions:
12649//
12650// The above copyright notice and this permission notice shall be included
12651// in all copies or substantial portions of the Software.
12652//
12653// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12654// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12655// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12656// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12657// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12658// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12659// USE OR OTHER DEALINGS IN THE SOFTWARE.
12660
12661var objectCreate = Object.create || objectCreatePolyfill
12662var objectKeys = Object.keys || objectKeysPolyfill
12663var bind = Function.prototype.bind || functionBindPolyfill
12664
12665function EventEmitter() {
12666 if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
12667 this._events = objectCreate(null);
12668 this._eventsCount = 0;
12669 }
12670
12671 this._maxListeners = this._maxListeners || undefined;
12672}
12673module.exports = EventEmitter;
12674
12675// Backwards-compat with node 0.10.x
12676EventEmitter.EventEmitter = EventEmitter;
12677
12678EventEmitter.prototype._events = undefined;
12679EventEmitter.prototype._maxListeners = undefined;
12680
12681// By default EventEmitters will print a warning if more than 10 listeners are
12682// added to it. This is a useful default which helps finding memory leaks.
12683var defaultMaxListeners = 10;
12684
12685var hasDefineProperty;
12686try {
12687 var o = {};
12688 if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
12689 hasDefineProperty = o.x === 0;
12690} catch (err) { hasDefineProperty = false }
12691if (hasDefineProperty) {
12692 Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
12693 enumerable: true,
12694 get: function() {
12695 return defaultMaxListeners;
12696 },
12697 set: function(arg) {
12698 // check whether the input is a positive number (whose value is zero or
12699 // greater and not a NaN).
12700 if (typeof arg !== 'number' || arg < 0 || arg !== arg)
12701 throw new TypeError('"defaultMaxListeners" must be a positive number');
12702 defaultMaxListeners = arg;
12703 }
12704 });
12705} else {
12706 EventEmitter.defaultMaxListeners = defaultMaxListeners;
12707}
12708
12709// Obviously not all Emitters should be limited to 10. This function allows
12710// that to be increased. Set to zero for unlimited.
12711EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
12712 if (typeof n !== 'number' || n < 0 || isNaN(n))
12713 throw new TypeError('"n" argument must be a positive number');
12714 this._maxListeners = n;
12715 return this;
12716};
12717
12718function $getMaxListeners(that) {
12719 if (that._maxListeners === undefined)
12720 return EventEmitter.defaultMaxListeners;
12721 return that._maxListeners;
12722}
12723
12724EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
12725 return $getMaxListeners(this);
12726};
12727
12728// These standalone emit* functions are used to optimize calling of event
12729// handlers for fast cases because emit() itself often has a variable number of
12730// arguments and can be deoptimized because of that. These functions always have
12731// the same number of arguments and thus do not get deoptimized, so the code
12732// inside them can execute faster.
12733function emitNone(handler, isFn, self) {
12734 if (isFn)
12735 handler.call(self);
12736 else {
12737 var len = handler.length;
12738 var listeners = arrayClone(handler, len);
12739 for (var i = 0; i < len; ++i)
12740 listeners[i].call(self);
12741 }
12742}
12743function emitOne(handler, isFn, self, arg1) {
12744 if (isFn)
12745 handler.call(self, arg1);
12746 else {
12747 var len = handler.length;
12748 var listeners = arrayClone(handler, len);
12749 for (var i = 0; i < len; ++i)
12750 listeners[i].call(self, arg1);
12751 }
12752}
12753function emitTwo(handler, isFn, self, arg1, arg2) {
12754 if (isFn)
12755 handler.call(self, arg1, arg2);
12756 else {
12757 var len = handler.length;
12758 var listeners = arrayClone(handler, len);
12759 for (var i = 0; i < len; ++i)
12760 listeners[i].call(self, arg1, arg2);
12761 }
12762}
12763function emitThree(handler, isFn, self, arg1, arg2, arg3) {
12764 if (isFn)
12765 handler.call(self, arg1, arg2, arg3);
12766 else {
12767 var len = handler.length;
12768 var listeners = arrayClone(handler, len);
12769 for (var i = 0; i < len; ++i)
12770 listeners[i].call(self, arg1, arg2, arg3);
12771 }
12772}
12773
12774function emitMany(handler, isFn, self, args) {
12775 if (isFn)
12776 handler.apply(self, args);
12777 else {
12778 var len = handler.length;
12779 var listeners = arrayClone(handler, len);
12780 for (var i = 0; i < len; ++i)
12781 listeners[i].apply(self, args);
12782 }
12783}
12784
12785EventEmitter.prototype.emit = function emit(type) {
12786 var er, handler, len, args, i, events;
12787 var doError = (type === 'error');
12788
12789 events = this._events;
12790 if (events)
12791 doError = (doError && events.error == null);
12792 else if (!doError)
12793 return false;
12794
12795 // If there is no 'error' event listener then throw.
12796 if (doError) {
12797 if (arguments.length > 1)
12798 er = arguments[1];
12799 if (er instanceof Error) {
12800 throw er; // Unhandled 'error' event
12801 } else {
12802 // At least give some kind of context to the user
12803 var err = new Error('Unhandled "error" event. (' + er + ')');
12804 err.context = er;
12805 throw err;
12806 }
12807 return false;
12808 }
12809
12810 handler = events[type];
12811
12812 if (!handler)
12813 return false;
12814
12815 var isFn = typeof handler === 'function';
12816 len = arguments.length;
12817 switch (len) {
12818 // fast cases
12819 case 1:
12820 emitNone(handler, isFn, this);
12821 break;
12822 case 2:
12823 emitOne(handler, isFn, this, arguments[1]);
12824 break;
12825 case 3:
12826 emitTwo(handler, isFn, this, arguments[1], arguments[2]);
12827 break;
12828 case 4:
12829 emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
12830 break;
12831 // slower
12832 default:
12833 args = new Array(len - 1);
12834 for (i = 1; i < len; i++)
12835 args[i - 1] = arguments[i];
12836 emitMany(handler, isFn, this, args);
12837 }
12838
12839 return true;
12840};
12841
12842function _addListener(target, type, listener, prepend) {
12843 var m;
12844 var events;
12845 var existing;
12846
12847 if (typeof listener !== 'function')
12848 throw new TypeError('"listener" argument must be a function');
12849
12850 events = target._events;
12851 if (!events) {
12852 events = target._events = objectCreate(null);
12853 target._eventsCount = 0;
12854 } else {
12855 // To avoid recursion in the case that type === "newListener"! Before
12856 // adding it to the listeners, first emit "newListener".
12857 if (events.newListener) {
12858 target.emit('newListener', type,
12859 listener.listener ? listener.listener : listener);
12860
12861 // Re-assign `events` because a newListener handler could have caused the
12862 // this._events to be assigned to a new object
12863 events = target._events;
12864 }
12865 existing = events[type];
12866 }
12867
12868 if (!existing) {
12869 // Optimize the case of one listener. Don't need the extra array object.
12870 existing = events[type] = listener;
12871 ++target._eventsCount;
12872 } else {
12873 if (typeof existing === 'function') {
12874 // Adding the second element, need to change to array.
12875 existing = events[type] =
12876 prepend ? [listener, existing] : [existing, listener];
12877 } else {
12878 // If we've already got an array, just append.
12879 if (prepend) {
12880 existing.unshift(listener);
12881 } else {
12882 existing.push(listener);
12883 }
12884 }
12885
12886 // Check for listener leak
12887 if (!existing.warned) {
12888 m = $getMaxListeners(target);
12889 if (m && m > 0 && existing.length > m) {
12890 existing.warned = true;
12891 var w = new Error('Possible EventEmitter memory leak detected. ' +
12892 existing.length + ' "' + String(type) + '" listeners ' +
12893 'added. Use emitter.setMaxListeners() to ' +
12894 'increase limit.');
12895 w.name = 'MaxListenersExceededWarning';
12896 w.emitter = target;
12897 w.type = type;
12898 w.count = existing.length;
12899 if (typeof console === 'object' && console.warn) {
12900 console.warn('%s: %s', w.name, w.message);
12901 }
12902 }
12903 }
12904 }
12905
12906 return target;
12907}
12908
12909EventEmitter.prototype.addListener = function addListener(type, listener) {
12910 return _addListener(this, type, listener, false);
12911};
12912
12913EventEmitter.prototype.on = EventEmitter.prototype.addListener;
12914
12915EventEmitter.prototype.prependListener =
12916 function prependListener(type, listener) {
12917 return _addListener(this, type, listener, true);
12918 };
12919
12920function onceWrapper() {
12921 if (!this.fired) {
12922 this.target.removeListener(this.type, this.wrapFn);
12923 this.fired = true;
12924 switch (arguments.length) {
12925 case 0:
12926 return this.listener.call(this.target);
12927 case 1:
12928 return this.listener.call(this.target, arguments[0]);
12929 case 2:
12930 return this.listener.call(this.target, arguments[0], arguments[1]);
12931 case 3:
12932 return this.listener.call(this.target, arguments[0], arguments[1],
12933 arguments[2]);
12934 default:
12935 var args = new Array(arguments.length);
12936 for (var i = 0; i < args.length; ++i)
12937 args[i] = arguments[i];
12938 this.listener.apply(this.target, args);
12939 }
12940 }
12941}
12942
12943function _onceWrap(target, type, listener) {
12944 var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
12945 var wrapped = bind.call(onceWrapper, state);
12946 wrapped.listener = listener;
12947 state.wrapFn = wrapped;
12948 return wrapped;
12949}
12950
12951EventEmitter.prototype.once = function once(type, listener) {
12952 if (typeof listener !== 'function')
12953 throw new TypeError('"listener" argument must be a function');
12954 this.on(type, _onceWrap(this, type, listener));
12955 return this;
12956};
12957
12958EventEmitter.prototype.prependOnceListener =
12959 function prependOnceListener(type, listener) {
12960 if (typeof listener !== 'function')
12961 throw new TypeError('"listener" argument must be a function');
12962 this.prependListener(type, _onceWrap(this, type, listener));
12963 return this;
12964 };
12965
12966// Emits a 'removeListener' event if and only if the listener was removed.
12967EventEmitter.prototype.removeListener =
12968 function removeListener(type, listener) {
12969 var list, events, position, i, originalListener;
12970
12971 if (typeof listener !== 'function')
12972 throw new TypeError('"listener" argument must be a function');
12973
12974 events = this._events;
12975 if (!events)
12976 return this;
12977
12978 list = events[type];
12979 if (!list)
12980 return this;
12981
12982 if (list === listener || list.listener === listener) {
12983 if (--this._eventsCount === 0)
12984 this._events = objectCreate(null);
12985 else {
12986 delete events[type];
12987 if (events.removeListener)
12988 this.emit('removeListener', type, list.listener || listener);
12989 }
12990 } else if (typeof list !== 'function') {
12991 position = -1;
12992
12993 for (i = list.length - 1; i >= 0; i--) {
12994 if (list[i] === listener || list[i].listener === listener) {
12995 originalListener = list[i].listener;
12996 position = i;
12997 break;
12998 }
12999 }
13000
13001 if (position < 0)
13002 return this;
13003
13004 if (position === 0)
13005 list.shift();
13006 else
13007 spliceOne(list, position);
13008
13009 if (list.length === 1)
13010 events[type] = list[0];
13011
13012 if (events.removeListener)
13013 this.emit('removeListener', type, originalListener || listener);
13014 }
13015
13016 return this;
13017 };
13018
13019EventEmitter.prototype.removeAllListeners =
13020 function removeAllListeners(type) {
13021 var listeners, events, i;
13022
13023 events = this._events;
13024 if (!events)
13025 return this;
13026
13027 // not listening for removeListener, no need to emit
13028 if (!events.removeListener) {
13029 if (arguments.length === 0) {
13030 this._events = objectCreate(null);
13031 this._eventsCount = 0;
13032 } else if (events[type]) {
13033 if (--this._eventsCount === 0)
13034 this._events = objectCreate(null);
13035 else
13036 delete events[type];
13037 }
13038 return this;
13039 }
13040
13041 // emit removeListener for all listeners on all events
13042 if (arguments.length === 0) {
13043 var keys = objectKeys(events);
13044 var key;
13045 for (i = 0; i < keys.length; ++i) {
13046 key = keys[i];
13047 if (key === 'removeListener') continue;
13048 this.removeAllListeners(key);
13049 }
13050 this.removeAllListeners('removeListener');
13051 this._events = objectCreate(null);
13052 this._eventsCount = 0;
13053 return this;
13054 }
13055
13056 listeners = events[type];
13057
13058 if (typeof listeners === 'function') {
13059 this.removeListener(type, listeners);
13060 } else if (listeners) {
13061 // LIFO order
13062 for (i = listeners.length - 1; i >= 0; i--) {
13063 this.removeListener(type, listeners[i]);
13064 }
13065 }
13066
13067 return this;
13068 };
13069
13070function _listeners(target, type, unwrap) {
13071 var events = target._events;
13072
13073 if (!events)
13074 return [];
13075
13076 var evlistener = events[type];
13077 if (!evlistener)
13078 return [];
13079
13080 if (typeof evlistener === 'function')
13081 return unwrap ? [evlistener.listener || evlistener] : [evlistener];
13082
13083 return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
13084}
13085
13086EventEmitter.prototype.listeners = function listeners(type) {
13087 return _listeners(this, type, true);
13088};
13089
13090EventEmitter.prototype.rawListeners = function rawListeners(type) {
13091 return _listeners(this, type, false);
13092};
13093
13094EventEmitter.listenerCount = function(emitter, type) {
13095 if (typeof emitter.listenerCount === 'function') {
13096 return emitter.listenerCount(type);
13097 } else {
13098 return listenerCount.call(emitter, type);
13099 }
13100};
13101
13102EventEmitter.prototype.listenerCount = listenerCount;
13103function listenerCount(type) {
13104 var events = this._events;
13105
13106 if (events) {
13107 var evlistener = events[type];
13108
13109 if (typeof evlistener === 'function') {
13110 return 1;
13111 } else if (evlistener) {
13112 return evlistener.length;
13113 }
13114 }
13115
13116 return 0;
13117}
13118
13119EventEmitter.prototype.eventNames = function eventNames() {
13120 return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
13121};
13122
13123// About 1.5x faster than the two-arg version of Array#splice().
13124function spliceOne(list, index) {
13125 for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
13126 list[i] = list[k];
13127 list.pop();
13128}
13129
13130function arrayClone(arr, n) {
13131 var copy = new Array(n);
13132 for (var i = 0; i < n; ++i)
13133 copy[i] = arr[i];
13134 return copy;
13135}
13136
13137function unwrapListeners(arr) {
13138 var ret = new Array(arr.length);
13139 for (var i = 0; i < ret.length; ++i) {
13140 ret[i] = arr[i].listener || arr[i];
13141 }
13142 return ret;
13143}
13144
13145function objectCreatePolyfill(proto) {
13146 var F = function() {};
13147 F.prototype = proto;
13148 return new F;
13149}
13150function objectKeysPolyfill(obj) {
13151 var keys = [];
13152 for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
13153 keys.push(k);
13154 }
13155 return k;
13156}
13157function functionBindPolyfill(context) {
13158 var fn = this;
13159 return function () {
13160 return fn.apply(context, arguments);
13161 };
13162}
13163
13164},{}],51:[function(require,module,exports){
13165'use strict';
13166
13167/* eslint no-invalid-this: 1 */
13168
13169var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
13170var slice = Array.prototype.slice;
13171var toStr = Object.prototype.toString;
13172var funcType = '[object Function]';
13173
13174module.exports = function bind(that) {
13175 var target = this;
13176 if (typeof target !== 'function' || toStr.call(target) !== funcType) {
13177 throw new TypeError(ERROR_MESSAGE + target);
13178 }
13179 var args = slice.call(arguments, 1);
13180
13181 var bound;
13182 var binder = function () {
13183 if (this instanceof bound) {
13184 var result = target.apply(
13185 this,
13186 args.concat(slice.call(arguments))
13187 );
13188 if (Object(result) === result) {
13189 return result;
13190 }
13191 return this;
13192 } else {
13193 return target.apply(
13194 that,
13195 args.concat(slice.call(arguments))
13196 );
13197 }
13198 };
13199
13200 var boundLength = Math.max(0, target.length - args.length);
13201 var boundArgs = [];
13202 for (var i = 0; i < boundLength; i++) {
13203 boundArgs.push('$' + i);
13204 }
13205
13206 bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
13207
13208 if (target.prototype) {
13209 var Empty = function Empty() {};
13210 Empty.prototype = target.prototype;
13211 bound.prototype = new Empty();
13212 Empty.prototype = null;
13213 }
13214
13215 return bound;
13216};
13217
13218},{}],52:[function(require,module,exports){
13219'use strict';
13220
13221var implementation = require('./implementation');
13222
13223module.exports = Function.prototype.bind || implementation;
13224
13225},{"./implementation":51}],53:[function(require,module,exports){
13226'use strict';
13227
13228/* eslint complexity: [2, 17], max-statements: [2, 33] */
13229module.exports = function hasSymbols() {
13230 if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
13231 if (typeof Symbol.iterator === 'symbol') { return true; }
13232
13233 var obj = {};
13234 var sym = Symbol('test');
13235 var symObj = Object(sym);
13236 if (typeof sym === 'string') { return false; }
13237
13238 if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
13239 if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
13240
13241 // temp disabled per https://github.com/ljharb/object.assign/issues/17
13242 // if (sym instanceof Symbol) { return false; }
13243 // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
13244 // if (!(symObj instanceof Symbol)) { return false; }
13245
13246 // if (typeof Symbol.prototype.toString !== 'function') { return false; }
13247 // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
13248
13249 var symVal = 42;
13250 obj[sym] = symVal;
13251 for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
13252 if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
13253
13254 if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
13255
13256 var syms = Object.getOwnPropertySymbols(obj);
13257 if (syms.length !== 1 || syms[0] !== sym) { return false; }
13258
13259 if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
13260
13261 if (typeof Object.getOwnPropertyDescriptor === 'function') {
13262 var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
13263 if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
13264 }
13265
13266 return true;
13267};
13268
13269},{}],54:[function(require,module,exports){
13270(function (global){
13271/*! https://mths.be/he v1.2.0 by @mathias | MIT license */
13272;(function(root) {
13273
13274 // Detect free variables `exports`.
13275 var freeExports = typeof exports == 'object' && exports;
13276
13277 // Detect free variable `module`.
13278 var freeModule = typeof module == 'object' && module &&
13279 module.exports == freeExports && module;
13280
13281 // Detect free variable `global`, from Node.js or Browserified code,
13282 // and use it as `root`.
13283 var freeGlobal = typeof global == 'object' && global;
13284 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
13285 root = freeGlobal;
13286 }
13287
13288 /*--------------------------------------------------------------------------*/
13289
13290 // All astral symbols.
13291 var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
13292 // All ASCII symbols (not just printable ASCII) except those listed in the
13293 // first column of the overrides table.
13294 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
13295 var regexAsciiWhitelist = /[\x01-\x7F]/g;
13296 // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
13297 // code points listed in the first column of the overrides table on
13298 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
13299 var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
13300
13301 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;
13302 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'};
13303
13304 var regexEscape = /["&'<>`]/g;
13305 var escapeMap = {
13306 '"': '&quot;',
13307 '&': '&amp;',
13308 '\'': '&#x27;',
13309 '<': '&lt;',
13310 // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
13311 // following is not strictly necessary unless it’s part of a tag or an
13312 // unquoted attribute value. We’re only escaping it to support those
13313 // situations, and for XML support.
13314 '>': '&gt;',
13315 // In Internet Explorer ≤ 8, the backtick character can be used
13316 // to break out of (un)quoted attribute values or HTML comments.
13317 // See http://html5sec.org/#102, http://html5sec.org/#108, and
13318 // http://html5sec.org/#133.
13319 '`': '&#x60;'
13320 };
13321
13322 var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
13323 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]/;
13324 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;
13325 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'};
13326 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'};
13327 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'};
13328 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];
13329
13330 /*--------------------------------------------------------------------------*/
13331
13332 var stringFromCharCode = String.fromCharCode;
13333
13334 var object = {};
13335 var hasOwnProperty = object.hasOwnProperty;
13336 var has = function(object, propertyName) {
13337 return hasOwnProperty.call(object, propertyName);
13338 };
13339
13340 var contains = function(array, value) {
13341 var index = -1;
13342 var length = array.length;
13343 while (++index < length) {
13344 if (array[index] == value) {
13345 return true;
13346 }
13347 }
13348 return false;
13349 };
13350
13351 var merge = function(options, defaults) {
13352 if (!options) {
13353 return defaults;
13354 }
13355 var result = {};
13356 var key;
13357 for (key in defaults) {
13358 // A `hasOwnProperty` check is not needed here, since only recognized
13359 // option names are used anyway. Any others are ignored.
13360 result[key] = has(options, key) ? options[key] : defaults[key];
13361 }
13362 return result;
13363 };
13364
13365 // Modified version of `ucs2encode`; see https://mths.be/punycode.
13366 var codePointToSymbol = function(codePoint, strict) {
13367 var output = '';
13368 if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
13369 // See issue #4:
13370 // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
13371 // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
13372 // REPLACEMENT CHARACTER.”
13373 if (strict) {
13374 parseError('character reference outside the permissible Unicode range');
13375 }
13376 return '\uFFFD';
13377 }
13378 if (has(decodeMapNumeric, codePoint)) {
13379 if (strict) {
13380 parseError('disallowed character reference');
13381 }
13382 return decodeMapNumeric[codePoint];
13383 }
13384 if (strict && contains(invalidReferenceCodePoints, codePoint)) {
13385 parseError('disallowed character reference');
13386 }
13387 if (codePoint > 0xFFFF) {
13388 codePoint -= 0x10000;
13389 output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
13390 codePoint = 0xDC00 | codePoint & 0x3FF;
13391 }
13392 output += stringFromCharCode(codePoint);
13393 return output;
13394 };
13395
13396 var hexEscape = function(codePoint) {
13397 return '&#x' + codePoint.toString(16).toUpperCase() + ';';
13398 };
13399
13400 var decEscape = function(codePoint) {
13401 return '&#' + codePoint + ';';
13402 };
13403
13404 var parseError = function(message) {
13405 throw Error('Parse error: ' + message);
13406 };
13407
13408 /*--------------------------------------------------------------------------*/
13409
13410 var encode = function(string, options) {
13411 options = merge(options, encode.options);
13412 var strict = options.strict;
13413 if (strict && regexInvalidRawCodePoint.test(string)) {
13414 parseError('forbidden code point');
13415 }
13416 var encodeEverything = options.encodeEverything;
13417 var useNamedReferences = options.useNamedReferences;
13418 var allowUnsafeSymbols = options.allowUnsafeSymbols;
13419 var escapeCodePoint = options.decimal ? decEscape : hexEscape;
13420
13421 var escapeBmpSymbol = function(symbol) {
13422 return escapeCodePoint(symbol.charCodeAt(0));
13423 };
13424
13425 if (encodeEverything) {
13426 // Encode ASCII symbols.
13427 string = string.replace(regexAsciiWhitelist, function(symbol) {
13428 // Use named references if requested & possible.
13429 if (useNamedReferences && has(encodeMap, symbol)) {
13430 return '&' + encodeMap[symbol] + ';';
13431 }
13432 return escapeBmpSymbol(symbol);
13433 });
13434 // Shorten a few escapes that represent two symbols, of which at least one
13435 // is within the ASCII range.
13436 if (useNamedReferences) {
13437 string = string
13438 .replace(/&gt;\u20D2/g, '&nvgt;')
13439 .replace(/&lt;\u20D2/g, '&nvlt;')
13440 .replace(/&#x66;&#x6A;/g, '&fjlig;');
13441 }
13442 // Encode non-ASCII symbols.
13443 if (useNamedReferences) {
13444 // Encode non-ASCII symbols that can be replaced with a named reference.
13445 string = string.replace(regexEncodeNonAscii, function(string) {
13446 // Note: there is no need to check `has(encodeMap, string)` here.
13447 return '&' + encodeMap[string] + ';';
13448 });
13449 }
13450 // Note: any remaining non-ASCII symbols are handled outside of the `if`.
13451 } else if (useNamedReferences) {
13452 // Apply named character references.
13453 // Encode `<>"'&` using named character references.
13454 if (!allowUnsafeSymbols) {
13455 string = string.replace(regexEscape, function(string) {
13456 return '&' + encodeMap[string] + ';'; // no need to check `has()` here
13457 });
13458 }
13459 // Shorten escapes that represent two symbols, of which at least one is
13460 // `<>"'&`.
13461 string = string
13462 .replace(/&gt;\u20D2/g, '&nvgt;')
13463 .replace(/&lt;\u20D2/g, '&nvlt;');
13464 // Encode non-ASCII symbols that can be replaced with a named reference.
13465 string = string.replace(regexEncodeNonAscii, function(string) {
13466 // Note: there is no need to check `has(encodeMap, string)` here.
13467 return '&' + encodeMap[string] + ';';
13468 });
13469 } else if (!allowUnsafeSymbols) {
13470 // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
13471 // using named character references.
13472 string = string.replace(regexEscape, escapeBmpSymbol);
13473 }
13474 return string
13475 // Encode astral symbols.
13476 .replace(regexAstralSymbols, function($0) {
13477 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
13478 var high = $0.charCodeAt(0);
13479 var low = $0.charCodeAt(1);
13480 var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
13481 return escapeCodePoint(codePoint);
13482 })
13483 // Encode any remaining BMP symbols that are not printable ASCII symbols
13484 // using a hexadecimal escape.
13485 .replace(regexBmpWhitelist, escapeBmpSymbol);
13486 };
13487 // Expose default options (so they can be overridden globally).
13488 encode.options = {
13489 'allowUnsafeSymbols': false,
13490 'encodeEverything': false,
13491 'strict': false,
13492 'useNamedReferences': false,
13493 'decimal' : false
13494 };
13495
13496 var decode = function(html, options) {
13497 options = merge(options, decode.options);
13498 var strict = options.strict;
13499 if (strict && regexInvalidEntity.test(html)) {
13500 parseError('malformed character reference');
13501 }
13502 return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7, $8) {
13503 var codePoint;
13504 var semicolon;
13505 var decDigits;
13506 var hexDigits;
13507 var reference;
13508 var next;
13509
13510 if ($1) {
13511 reference = $1;
13512 // Note: there is no need to check `has(decodeMap, reference)`.
13513 return decodeMap[reference];
13514 }
13515
13516 if ($2) {
13517 // Decode named character references without trailing `;`, e.g. `&amp`.
13518 // This is only a parse error if it gets converted to `&`, or if it is
13519 // followed by `=` in an attribute context.
13520 reference = $2;
13521 next = $3;
13522 if (next && options.isAttributeValue) {
13523 if (strict && next == '=') {
13524 parseError('`&` did not start a character reference');
13525 }
13526 return $0;
13527 } else {
13528 if (strict) {
13529 parseError(
13530 'named character reference was not terminated by a semicolon'
13531 );
13532 }
13533 // Note: there is no need to check `has(decodeMapLegacy, reference)`.
13534 return decodeMapLegacy[reference] + (next || '');
13535 }
13536 }
13537
13538 if ($4) {
13539 // Decode decimal escapes, e.g. `&#119558;`.
13540 decDigits = $4;
13541 semicolon = $5;
13542 if (strict && !semicolon) {
13543 parseError('character reference was not terminated by a semicolon');
13544 }
13545 codePoint = parseInt(decDigits, 10);
13546 return codePointToSymbol(codePoint, strict);
13547 }
13548
13549 if ($6) {
13550 // Decode hexadecimal escapes, e.g. `&#x1D306;`.
13551 hexDigits = $6;
13552 semicolon = $7;
13553 if (strict && !semicolon) {
13554 parseError('character reference was not terminated by a semicolon');
13555 }
13556 codePoint = parseInt(hexDigits, 16);
13557 return codePointToSymbol(codePoint, strict);
13558 }
13559
13560 // If we’re still here, `if ($7)` is implied; it’s an ambiguous
13561 // ampersand for sure. https://mths.be/notes/ambiguous-ampersands
13562 if (strict) {
13563 parseError(
13564 'named character reference was not terminated by a semicolon'
13565 );
13566 }
13567 return $0;
13568 });
13569 };
13570 // Expose default options (so they can be overridden globally).
13571 decode.options = {
13572 'isAttributeValue': false,
13573 'strict': false
13574 };
13575
13576 var escape = function(string) {
13577 return string.replace(regexEscape, function($0) {
13578 // Note: there is no need to check `has(escapeMap, $0)` here.
13579 return escapeMap[$0];
13580 });
13581 };
13582
13583 /*--------------------------------------------------------------------------*/
13584
13585 var he = {
13586 'version': '1.2.0',
13587 'encode': encode,
13588 'decode': decode,
13589 'escape': escape,
13590 'unescape': decode
13591 };
13592
13593 // Some AMD build optimizers, like r.js, check for specific condition patterns
13594 // like the following:
13595 if (
13596 false
13597 ) {
13598 define(function() {
13599 return he;
13600 });
13601 } else if (freeExports && !freeExports.nodeType) {
13602 if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
13603 freeModule.exports = he;
13604 } else { // in Narwhal or RingoJS v0.7.0-
13605 for (var key in he) {
13606 has(he, key) && (freeExports[key] = he[key]);
13607 }
13608 }
13609 } else { // in Rhino or a web browser
13610 root.he = he;
13611 }
13612
13613}(this));
13614
13615}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
13616},{}],55:[function(require,module,exports){
13617exports.read = function (buffer, offset, isLE, mLen, nBytes) {
13618 var e, m
13619 var eLen = (nBytes * 8) - mLen - 1
13620 var eMax = (1 << eLen) - 1
13621 var eBias = eMax >> 1
13622 var nBits = -7
13623 var i = isLE ? (nBytes - 1) : 0
13624 var d = isLE ? -1 : 1
13625 var s = buffer[offset + i]
13626
13627 i += d
13628
13629 e = s & ((1 << (-nBits)) - 1)
13630 s >>= (-nBits)
13631 nBits += eLen
13632 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13633
13634 m = e & ((1 << (-nBits)) - 1)
13635 e >>= (-nBits)
13636 nBits += mLen
13637 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
13638
13639 if (e === 0) {
13640 e = 1 - eBias
13641 } else if (e === eMax) {
13642 return m ? NaN : ((s ? -1 : 1) * Infinity)
13643 } else {
13644 m = m + Math.pow(2, mLen)
13645 e = e - eBias
13646 }
13647 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
13648}
13649
13650exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
13651 var e, m, c
13652 var eLen = (nBytes * 8) - mLen - 1
13653 var eMax = (1 << eLen) - 1
13654 var eBias = eMax >> 1
13655 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
13656 var i = isLE ? 0 : (nBytes - 1)
13657 var d = isLE ? 1 : -1
13658 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
13659
13660 value = Math.abs(value)
13661
13662 if (isNaN(value) || value === Infinity) {
13663 m = isNaN(value) ? 1 : 0
13664 e = eMax
13665 } else {
13666 e = Math.floor(Math.log(value) / Math.LN2)
13667 if (value * (c = Math.pow(2, -e)) < 1) {
13668 e--
13669 c *= 2
13670 }
13671 if (e + eBias >= 1) {
13672 value += rt / c
13673 } else {
13674 value += rt * Math.pow(2, 1 - eBias)
13675 }
13676 if (value * c >= 2) {
13677 e++
13678 c /= 2
13679 }
13680
13681 if (e + eBias >= eMax) {
13682 m = 0
13683 e = eMax
13684 } else if (e + eBias >= 1) {
13685 m = ((value * c) - 1) * Math.pow(2, mLen)
13686 e = e + eBias
13687 } else {
13688 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
13689 e = 0
13690 }
13691 }
13692
13693 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
13694
13695 e = (e << mLen) | m
13696 eLen += mLen
13697 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
13698
13699 buffer[offset + i - d] |= s * 128
13700}
13701
13702},{}],56:[function(require,module,exports){
13703if (typeof Object.create === 'function') {
13704 // implementation from standard node.js 'util' module
13705 module.exports = function inherits(ctor, superCtor) {
13706 ctor.super_ = superCtor
13707 ctor.prototype = Object.create(superCtor.prototype, {
13708 constructor: {
13709 value: ctor,
13710 enumerable: false,
13711 writable: true,
13712 configurable: true
13713 }
13714 });
13715 };
13716} else {
13717 // old school shim for old browsers
13718 module.exports = function inherits(ctor, superCtor) {
13719 ctor.super_ = superCtor
13720 var TempCtor = function () {}
13721 TempCtor.prototype = superCtor.prototype
13722 ctor.prototype = new TempCtor()
13723 ctor.prototype.constructor = ctor
13724 }
13725}
13726
13727},{}],57:[function(require,module,exports){
13728/*!
13729 * Determine if an object is a Buffer
13730 *
13731 * @author Feross Aboukhadijeh <https://feross.org>
13732 * @license MIT
13733 */
13734
13735// The _isBuffer check is for Safari 5-7 support, because it's missing
13736// Object.prototype.constructor. Remove this eventually
13737module.exports = function (obj) {
13738 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
13739}
13740
13741function isBuffer (obj) {
13742 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
13743}
13744
13745// For Node v0.10 support. Remove this eventually.
13746function isSlowBuffer (obj) {
13747 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
13748}
13749
13750},{}],58:[function(require,module,exports){
13751var toString = {}.toString;
13752
13753module.exports = Array.isArray || function (arr) {
13754 return toString.call(arr) == '[object Array]';
13755};
13756
13757},{}],59:[function(require,module,exports){
13758(function (process){
13759var path = require('path');
13760var fs = require('fs');
13761var _0777 = parseInt('0777', 8);
13762
13763module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
13764
13765function mkdirP (p, opts, f, made) {
13766 if (typeof opts === 'function') {
13767 f = opts;
13768 opts = {};
13769 }
13770 else if (!opts || typeof opts !== 'object') {
13771 opts = { mode: opts };
13772 }
13773
13774 var mode = opts.mode;
13775 var xfs = opts.fs || fs;
13776
13777 if (mode === undefined) {
13778 mode = _0777 & (~process.umask());
13779 }
13780 if (!made) made = null;
13781
13782 var cb = f || function () {};
13783 p = path.resolve(p);
13784
13785 xfs.mkdir(p, mode, function (er) {
13786 if (!er) {
13787 made = made || p;
13788 return cb(null, made);
13789 }
13790 switch (er.code) {
13791 case 'ENOENT':
13792 mkdirP(path.dirname(p), opts, function (er, made) {
13793 if (er) cb(er, made);
13794 else mkdirP(p, opts, cb, made);
13795 });
13796 break;
13797
13798 // In the case of any other error, just see if there's a dir
13799 // there already. If so, then hooray! If not, then something
13800 // is borked.
13801 default:
13802 xfs.stat(p, function (er2, stat) {
13803 // if the stat fails, then that's super weird.
13804 // let the original error be the failure reason.
13805 if (er2 || !stat.isDirectory()) cb(er, made)
13806 else cb(null, made);
13807 });
13808 break;
13809 }
13810 });
13811}
13812
13813mkdirP.sync = function sync (p, opts, made) {
13814 if (!opts || typeof opts !== 'object') {
13815 opts = { mode: opts };
13816 }
13817
13818 var mode = opts.mode;
13819 var xfs = opts.fs || fs;
13820
13821 if (mode === undefined) {
13822 mode = _0777 & (~process.umask());
13823 }
13824 if (!made) made = null;
13825
13826 p = path.resolve(p);
13827
13828 try {
13829 xfs.mkdirSync(p, mode);
13830 made = made || p;
13831 }
13832 catch (err0) {
13833 switch (err0.code) {
13834 case 'ENOENT' :
13835 made = sync(path.dirname(p), opts, made);
13836 sync(p, opts, made);
13837 break;
13838
13839 // In the case of any other error, just see if there's a dir
13840 // there already. If so, then hooray! If not, then something
13841 // is borked.
13842 default:
13843 var stat;
13844 try {
13845 stat = xfs.statSync(p);
13846 }
13847 catch (err1) {
13848 throw err0;
13849 }
13850 if (!stat.isDirectory()) throw err0;
13851 break;
13852 }
13853 }
13854
13855 return made;
13856};
13857
13858}).call(this,require('_process'))
13859},{"_process":69,"fs":42,"path":42}],60:[function(require,module,exports){
13860/**
13861 * Helpers.
13862 */
13863
13864var s = 1000;
13865var m = s * 60;
13866var h = m * 60;
13867var d = h * 24;
13868var w = d * 7;
13869var y = d * 365.25;
13870
13871/**
13872 * Parse or format the given `val`.
13873 *
13874 * Options:
13875 *
13876 * - `long` verbose formatting [false]
13877 *
13878 * @param {String|Number} val
13879 * @param {Object} [options]
13880 * @throws {Error} throw an error if val is not a non-empty string or a number
13881 * @return {String|Number}
13882 * @api public
13883 */
13884
13885module.exports = function(val, options) {
13886 options = options || {};
13887 var type = typeof val;
13888 if (type === 'string' && val.length > 0) {
13889 return parse(val);
13890 } else if (type === 'number' && isNaN(val) === false) {
13891 return options.long ? fmtLong(val) : fmtShort(val);
13892 }
13893 throw new Error(
13894 'val is not a non-empty string or a valid number. val=' +
13895 JSON.stringify(val)
13896 );
13897};
13898
13899/**
13900 * Parse the given `str` and return milliseconds.
13901 *
13902 * @param {String} str
13903 * @return {Number}
13904 * @api private
13905 */
13906
13907function parse(str) {
13908 str = String(str);
13909 if (str.length > 100) {
13910 return;
13911 }
13912 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(
13913 str
13914 );
13915 if (!match) {
13916 return;
13917 }
13918 var n = parseFloat(match[1]);
13919 var type = (match[2] || 'ms').toLowerCase();
13920 switch (type) {
13921 case 'years':
13922 case 'year':
13923 case 'yrs':
13924 case 'yr':
13925 case 'y':
13926 return n * y;
13927 case 'weeks':
13928 case 'week':
13929 case 'w':
13930 return n * w;
13931 case 'days':
13932 case 'day':
13933 case 'd':
13934 return n * d;
13935 case 'hours':
13936 case 'hour':
13937 case 'hrs':
13938 case 'hr':
13939 case 'h':
13940 return n * h;
13941 case 'minutes':
13942 case 'minute':
13943 case 'mins':
13944 case 'min':
13945 case 'm':
13946 return n * m;
13947 case 'seconds':
13948 case 'second':
13949 case 'secs':
13950 case 'sec':
13951 case 's':
13952 return n * s;
13953 case 'milliseconds':
13954 case 'millisecond':
13955 case 'msecs':
13956 case 'msec':
13957 case 'ms':
13958 return n;
13959 default:
13960 return undefined;
13961 }
13962}
13963
13964/**
13965 * Short format for `ms`.
13966 *
13967 * @param {Number} ms
13968 * @return {String}
13969 * @api private
13970 */
13971
13972function fmtShort(ms) {
13973 var msAbs = Math.abs(ms);
13974 if (msAbs >= d) {
13975 return Math.round(ms / d) + 'd';
13976 }
13977 if (msAbs >= h) {
13978 return Math.round(ms / h) + 'h';
13979 }
13980 if (msAbs >= m) {
13981 return Math.round(ms / m) + 'm';
13982 }
13983 if (msAbs >= s) {
13984 return Math.round(ms / s) + 's';
13985 }
13986 return ms + 'ms';
13987}
13988
13989/**
13990 * Long format for `ms`.
13991 *
13992 * @param {Number} ms
13993 * @return {String}
13994 * @api private
13995 */
13996
13997function fmtLong(ms) {
13998 var msAbs = Math.abs(ms);
13999 if (msAbs >= d) {
14000 return plural(ms, msAbs, d, 'day');
14001 }
14002 if (msAbs >= h) {
14003 return plural(ms, msAbs, h, 'hour');
14004 }
14005 if (msAbs >= m) {
14006 return plural(ms, msAbs, m, 'minute');
14007 }
14008 if (msAbs >= s) {
14009 return plural(ms, msAbs, s, 'second');
14010 }
14011 return ms + ' ms';
14012}
14013
14014/**
14015 * Pluralization helper.
14016 */
14017
14018function plural(ms, msAbs, n, name) {
14019 var isPlural = msAbs >= n * 1.5;
14020 return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
14021}
14022
14023},{}],61:[function(require,module,exports){
14024'use strict';
14025
14026var keysShim;
14027if (!Object.keys) {
14028 // modified from https://github.com/es-shims/es5-shim
14029 var has = Object.prototype.hasOwnProperty;
14030 var toStr = Object.prototype.toString;
14031 var isArgs = require('./isArguments'); // eslint-disable-line global-require
14032 var isEnumerable = Object.prototype.propertyIsEnumerable;
14033 var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
14034 var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
14035 var dontEnums = [
14036 'toString',
14037 'toLocaleString',
14038 'valueOf',
14039 'hasOwnProperty',
14040 'isPrototypeOf',
14041 'propertyIsEnumerable',
14042 'constructor'
14043 ];
14044 var equalsConstructorPrototype = function (o) {
14045 var ctor = o.constructor;
14046 return ctor && ctor.prototype === o;
14047 };
14048 var excludedKeys = {
14049 $applicationCache: true,
14050 $console: true,
14051 $external: true,
14052 $frame: true,
14053 $frameElement: true,
14054 $frames: true,
14055 $innerHeight: true,
14056 $innerWidth: true,
14057 $outerHeight: true,
14058 $outerWidth: true,
14059 $pageXOffset: true,
14060 $pageYOffset: true,
14061 $parent: true,
14062 $scrollLeft: true,
14063 $scrollTop: true,
14064 $scrollX: true,
14065 $scrollY: true,
14066 $self: true,
14067 $webkitIndexedDB: true,
14068 $webkitStorageInfo: true,
14069 $window: true
14070 };
14071 var hasAutomationEqualityBug = (function () {
14072 /* global window */
14073 if (typeof window === 'undefined') { return false; }
14074 for (var k in window) {
14075 try {
14076 if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
14077 try {
14078 equalsConstructorPrototype(window[k]);
14079 } catch (e) {
14080 return true;
14081 }
14082 }
14083 } catch (e) {
14084 return true;
14085 }
14086 }
14087 return false;
14088 }());
14089 var equalsConstructorPrototypeIfNotBuggy = function (o) {
14090 /* global window */
14091 if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
14092 return equalsConstructorPrototype(o);
14093 }
14094 try {
14095 return equalsConstructorPrototype(o);
14096 } catch (e) {
14097 return false;
14098 }
14099 };
14100
14101 keysShim = function keys(object) {
14102 var isObject = object !== null && typeof object === 'object';
14103 var isFunction = toStr.call(object) === '[object Function]';
14104 var isArguments = isArgs(object);
14105 var isString = isObject && toStr.call(object) === '[object String]';
14106 var theKeys = [];
14107
14108 if (!isObject && !isFunction && !isArguments) {
14109 throw new TypeError('Object.keys called on a non-object');
14110 }
14111
14112 var skipProto = hasProtoEnumBug && isFunction;
14113 if (isString && object.length > 0 && !has.call(object, 0)) {
14114 for (var i = 0; i < object.length; ++i) {
14115 theKeys.push(String(i));
14116 }
14117 }
14118
14119 if (isArguments && object.length > 0) {
14120 for (var j = 0; j < object.length; ++j) {
14121 theKeys.push(String(j));
14122 }
14123 } else {
14124 for (var name in object) {
14125 if (!(skipProto && name === 'prototype') && has.call(object, name)) {
14126 theKeys.push(String(name));
14127 }
14128 }
14129 }
14130
14131 if (hasDontEnumBug) {
14132 var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
14133
14134 for (var k = 0; k < dontEnums.length; ++k) {
14135 if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
14136 theKeys.push(dontEnums[k]);
14137 }
14138 }
14139 }
14140 return theKeys;
14141 };
14142}
14143module.exports = keysShim;
14144
14145},{"./isArguments":63}],62:[function(require,module,exports){
14146'use strict';
14147
14148var slice = Array.prototype.slice;
14149var isArgs = require('./isArguments');
14150
14151var origKeys = Object.keys;
14152var keysShim = origKeys ? function keys(o) { return origKeys(o); } : require('./implementation');
14153
14154var originalKeys = Object.keys;
14155
14156keysShim.shim = function shimObjectKeys() {
14157 if (Object.keys) {
14158 var keysWorksWithArguments = (function () {
14159 // Safari 5.0 bug
14160 var args = Object.keys(arguments);
14161 return args && args.length === arguments.length;
14162 }(1, 2));
14163 if (!keysWorksWithArguments) {
14164 Object.keys = function keys(object) { // eslint-disable-line func-name-matching
14165 if (isArgs(object)) {
14166 return originalKeys(slice.call(object));
14167 }
14168 return originalKeys(object);
14169 };
14170 }
14171 } else {
14172 Object.keys = keysShim;
14173 }
14174 return Object.keys || keysShim;
14175};
14176
14177module.exports = keysShim;
14178
14179},{"./implementation":61,"./isArguments":63}],63:[function(require,module,exports){
14180'use strict';
14181
14182var toStr = Object.prototype.toString;
14183
14184module.exports = function isArguments(value) {
14185 var str = toStr.call(value);
14186 var isArgs = str === '[object Arguments]';
14187 if (!isArgs) {
14188 isArgs = str !== '[object Array]' &&
14189 value !== null &&
14190 typeof value === 'object' &&
14191 typeof value.length === 'number' &&
14192 value.length >= 0 &&
14193 toStr.call(value.callee) === '[object Function]';
14194 }
14195 return isArgs;
14196};
14197
14198},{}],64:[function(require,module,exports){
14199'use strict';
14200
14201// modified from https://github.com/es-shims/es6-shim
14202var keys = require('object-keys');
14203var bind = require('function-bind');
14204var canBeObject = function (obj) {
14205 return typeof obj !== 'undefined' && obj !== null;
14206};
14207var hasSymbols = require('has-symbols/shams')();
14208var toObject = Object;
14209var push = bind.call(Function.call, Array.prototype.push);
14210var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
14211var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
14212
14213module.exports = function assign(target, source1) {
14214 if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
14215 var objTarget = toObject(target);
14216 var s, source, i, props, syms, value, key;
14217 for (s = 1; s < arguments.length; ++s) {
14218 source = toObject(arguments[s]);
14219 props = keys(source);
14220 var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
14221 if (getSymbols) {
14222 syms = getSymbols(source);
14223 for (i = 0; i < syms.length; ++i) {
14224 key = syms[i];
14225 if (propIsEnumerable(source, key)) {
14226 push(props, key);
14227 }
14228 }
14229 }
14230 for (i = 0; i < props.length; ++i) {
14231 key = props[i];
14232 value = source[key];
14233 if (propIsEnumerable(source, key)) {
14234 objTarget[key] = value;
14235 }
14236 }
14237 }
14238 return objTarget;
14239};
14240
14241},{"function-bind":52,"has-symbols/shams":53,"object-keys":62}],65:[function(require,module,exports){
14242'use strict';
14243
14244var defineProperties = require('define-properties');
14245
14246var implementation = require('./implementation');
14247var getPolyfill = require('./polyfill');
14248var shim = require('./shim');
14249
14250var polyfill = getPolyfill();
14251
14252defineProperties(polyfill, {
14253 getPolyfill: getPolyfill,
14254 implementation: implementation,
14255 shim: shim
14256});
14257
14258module.exports = polyfill;
14259
14260},{"./implementation":64,"./polyfill":66,"./shim":67,"define-properties":47}],66:[function(require,module,exports){
14261'use strict';
14262
14263var implementation = require('./implementation');
14264
14265var lacksProperEnumerationOrder = function () {
14266 if (!Object.assign) {
14267 return false;
14268 }
14269 // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
14270 // note: this does not detect the bug unless there's 20 characters
14271 var str = 'abcdefghijklmnopqrst';
14272 var letters = str.split('');
14273 var map = {};
14274 for (var i = 0; i < letters.length; ++i) {
14275 map[letters[i]] = letters[i];
14276 }
14277 var obj = Object.assign({}, map);
14278 var actual = '';
14279 for (var k in obj) {
14280 actual += k;
14281 }
14282 return str !== actual;
14283};
14284
14285var assignHasPendingExceptions = function () {
14286 if (!Object.assign || !Object.preventExtensions) {
14287 return false;
14288 }
14289 // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
14290 // which is 72% slower than our shim, and Firefox 40's native implementation.
14291 var thrower = Object.preventExtensions({ 1: 2 });
14292 try {
14293 Object.assign(thrower, 'xy');
14294 } catch (e) {
14295 return thrower[1] === 'y';
14296 }
14297 return false;
14298};
14299
14300module.exports = function getPolyfill() {
14301 if (!Object.assign) {
14302 return implementation;
14303 }
14304 if (lacksProperEnumerationOrder()) {
14305 return implementation;
14306 }
14307 if (assignHasPendingExceptions()) {
14308 return implementation;
14309 }
14310 return Object.assign;
14311};
14312
14313},{"./implementation":64}],67:[function(require,module,exports){
14314'use strict';
14315
14316var define = require('define-properties');
14317var getPolyfill = require('./polyfill');
14318
14319module.exports = function shimAssign() {
14320 var polyfill = getPolyfill();
14321 define(
14322 Object,
14323 { assign: polyfill },
14324 { assign: function () { return Object.assign !== polyfill; } }
14325 );
14326 return polyfill;
14327};
14328
14329},{"./polyfill":66,"define-properties":47}],68:[function(require,module,exports){
14330(function (process){
14331'use strict';
14332
14333if (!process.version ||
14334 process.version.indexOf('v0.') === 0 ||
14335 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
14336 module.exports = { nextTick: nextTick };
14337} else {
14338 module.exports = process
14339}
14340
14341function nextTick(fn, arg1, arg2, arg3) {
14342 if (typeof fn !== 'function') {
14343 throw new TypeError('"callback" argument must be a function');
14344 }
14345 var len = arguments.length;
14346 var args, i;
14347 switch (len) {
14348 case 0:
14349 case 1:
14350 return process.nextTick(fn);
14351 case 2:
14352 return process.nextTick(function afterTickOne() {
14353 fn.call(null, arg1);
14354 });
14355 case 3:
14356 return process.nextTick(function afterTickTwo() {
14357 fn.call(null, arg1, arg2);
14358 });
14359 case 4:
14360 return process.nextTick(function afterTickThree() {
14361 fn.call(null, arg1, arg2, arg3);
14362 });
14363 default:
14364 args = new Array(len - 1);
14365 i = 0;
14366 while (i < args.length) {
14367 args[i++] = arguments[i];
14368 }
14369 return process.nextTick(function afterTick() {
14370 fn.apply(null, args);
14371 });
14372 }
14373}
14374
14375
14376}).call(this,require('_process'))
14377},{"_process":69}],69:[function(require,module,exports){
14378// shim for using process in browser
14379var process = module.exports = {};
14380
14381// cached from whatever global is present so that test runners that stub it
14382// don't break things. But we need to wrap it in a try catch in case it is
14383// wrapped in strict mode code which doesn't define any globals. It's inside a
14384// function because try/catches deoptimize in certain engines.
14385
14386var cachedSetTimeout;
14387var cachedClearTimeout;
14388
14389function defaultSetTimout() {
14390 throw new Error('setTimeout has not been defined');
14391}
14392function defaultClearTimeout () {
14393 throw new Error('clearTimeout has not been defined');
14394}
14395(function () {
14396 try {
14397 if (typeof setTimeout === 'function') {
14398 cachedSetTimeout = setTimeout;
14399 } else {
14400 cachedSetTimeout = defaultSetTimout;
14401 }
14402 } catch (e) {
14403 cachedSetTimeout = defaultSetTimout;
14404 }
14405 try {
14406 if (typeof clearTimeout === 'function') {
14407 cachedClearTimeout = clearTimeout;
14408 } else {
14409 cachedClearTimeout = defaultClearTimeout;
14410 }
14411 } catch (e) {
14412 cachedClearTimeout = defaultClearTimeout;
14413 }
14414} ())
14415function runTimeout(fun) {
14416 if (cachedSetTimeout === setTimeout) {
14417 //normal enviroments in sane situations
14418 return setTimeout(fun, 0);
14419 }
14420 // if setTimeout wasn't available but was latter defined
14421 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
14422 cachedSetTimeout = setTimeout;
14423 return setTimeout(fun, 0);
14424 }
14425 try {
14426 // when when somebody has screwed with setTimeout but no I.E. maddness
14427 return cachedSetTimeout(fun, 0);
14428 } catch(e){
14429 try {
14430 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14431 return cachedSetTimeout.call(null, fun, 0);
14432 } catch(e){
14433 // 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
14434 return cachedSetTimeout.call(this, fun, 0);
14435 }
14436 }
14437
14438
14439}
14440function runClearTimeout(marker) {
14441 if (cachedClearTimeout === clearTimeout) {
14442 //normal enviroments in sane situations
14443 return clearTimeout(marker);
14444 }
14445 // if clearTimeout wasn't available but was latter defined
14446 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
14447 cachedClearTimeout = clearTimeout;
14448 return clearTimeout(marker);
14449 }
14450 try {
14451 // when when somebody has screwed with setTimeout but no I.E. maddness
14452 return cachedClearTimeout(marker);
14453 } catch (e){
14454 try {
14455 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
14456 return cachedClearTimeout.call(null, marker);
14457 } catch (e){
14458 // 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.
14459 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
14460 return cachedClearTimeout.call(this, marker);
14461 }
14462 }
14463
14464
14465
14466}
14467var queue = [];
14468var draining = false;
14469var currentQueue;
14470var queueIndex = -1;
14471
14472function cleanUpNextTick() {
14473 if (!draining || !currentQueue) {
14474 return;
14475 }
14476 draining = false;
14477 if (currentQueue.length) {
14478 queue = currentQueue.concat(queue);
14479 } else {
14480 queueIndex = -1;
14481 }
14482 if (queue.length) {
14483 drainQueue();
14484 }
14485}
14486
14487function drainQueue() {
14488 if (draining) {
14489 return;
14490 }
14491 var timeout = runTimeout(cleanUpNextTick);
14492 draining = true;
14493
14494 var len = queue.length;
14495 while(len) {
14496 currentQueue = queue;
14497 queue = [];
14498 while (++queueIndex < len) {
14499 if (currentQueue) {
14500 currentQueue[queueIndex].run();
14501 }
14502 }
14503 queueIndex = -1;
14504 len = queue.length;
14505 }
14506 currentQueue = null;
14507 draining = false;
14508 runClearTimeout(timeout);
14509}
14510
14511process.nextTick = function (fun) {
14512 var args = new Array(arguments.length - 1);
14513 if (arguments.length > 1) {
14514 for (var i = 1; i < arguments.length; i++) {
14515 args[i - 1] = arguments[i];
14516 }
14517 }
14518 queue.push(new Item(fun, args));
14519 if (queue.length === 1 && !draining) {
14520 runTimeout(drainQueue);
14521 }
14522};
14523
14524// v8 likes predictible objects
14525function Item(fun, array) {
14526 this.fun = fun;
14527 this.array = array;
14528}
14529Item.prototype.run = function () {
14530 this.fun.apply(null, this.array);
14531};
14532process.title = 'browser';
14533process.browser = true;
14534process.env = {};
14535process.argv = [];
14536process.version = ''; // empty string to avoid regexp issues
14537process.versions = {};
14538
14539function noop() {}
14540
14541process.on = noop;
14542process.addListener = noop;
14543process.once = noop;
14544process.off = noop;
14545process.removeListener = noop;
14546process.removeAllListeners = noop;
14547process.emit = noop;
14548process.prependListener = noop;
14549process.prependOnceListener = noop;
14550
14551process.listeners = function (name) { return [] }
14552
14553process.binding = function (name) {
14554 throw new Error('process.binding is not supported');
14555};
14556
14557process.cwd = function () { return '/' };
14558process.chdir = function (dir) {
14559 throw new Error('process.chdir is not supported');
14560};
14561process.umask = function() { return 0; };
14562
14563},{}],70:[function(require,module,exports){
14564module.exports = require('./lib/_stream_duplex.js');
14565
14566},{"./lib/_stream_duplex.js":71}],71:[function(require,module,exports){
14567// Copyright Joyent, Inc. and other Node contributors.
14568//
14569// Permission is hereby granted, free of charge, to any person obtaining a
14570// copy of this software and associated documentation files (the
14571// "Software"), to deal in the Software without restriction, including
14572// without limitation the rights to use, copy, modify, merge, publish,
14573// distribute, sublicense, and/or sell copies of the Software, and to permit
14574// persons to whom the Software is furnished to do so, subject to the
14575// following conditions:
14576//
14577// The above copyright notice and this permission notice shall be included
14578// in all copies or substantial portions of the Software.
14579//
14580// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14581// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14582// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14583// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14584// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14585// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14586// USE OR OTHER DEALINGS IN THE SOFTWARE.
14587
14588// a duplex stream is just a stream that is both readable and writable.
14589// Since JS doesn't have multiple prototypal inheritance, this class
14590// prototypally inherits from Readable, and then parasitically from
14591// Writable.
14592
14593'use strict';
14594
14595/*<replacement>*/
14596
14597var pna = require('process-nextick-args');
14598/*</replacement>*/
14599
14600/*<replacement>*/
14601var objectKeys = Object.keys || function (obj) {
14602 var keys = [];
14603 for (var key in obj) {
14604 keys.push(key);
14605 }return keys;
14606};
14607/*</replacement>*/
14608
14609module.exports = Duplex;
14610
14611/*<replacement>*/
14612var util = require('core-util-is');
14613util.inherits = require('inherits');
14614/*</replacement>*/
14615
14616var Readable = require('./_stream_readable');
14617var Writable = require('./_stream_writable');
14618
14619util.inherits(Duplex, Readable);
14620
14621{
14622 // avoid scope creep, the keys array can then be collected
14623 var keys = objectKeys(Writable.prototype);
14624 for (var v = 0; v < keys.length; v++) {
14625 var method = keys[v];
14626 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
14627 }
14628}
14629
14630function Duplex(options) {
14631 if (!(this instanceof Duplex)) return new Duplex(options);
14632
14633 Readable.call(this, options);
14634 Writable.call(this, options);
14635
14636 if (options && options.readable === false) this.readable = false;
14637
14638 if (options && options.writable === false) this.writable = false;
14639
14640 this.allowHalfOpen = true;
14641 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
14642
14643 this.once('end', onend);
14644}
14645
14646Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
14647 // making it explicit this property is not enumerable
14648 // because otherwise some prototype manipulation in
14649 // userland will fail
14650 enumerable: false,
14651 get: function () {
14652 return this._writableState.highWaterMark;
14653 }
14654});
14655
14656// the no-half-open enforcer
14657function onend() {
14658 // if we allow half-open state, or if the writable side ended,
14659 // then we're ok.
14660 if (this.allowHalfOpen || this._writableState.ended) return;
14661
14662 // no more data can be written.
14663 // But allow more writes to happen in this tick.
14664 pna.nextTick(onEndNT, this);
14665}
14666
14667function onEndNT(self) {
14668 self.end();
14669}
14670
14671Object.defineProperty(Duplex.prototype, 'destroyed', {
14672 get: function () {
14673 if (this._readableState === undefined || this._writableState === undefined) {
14674 return false;
14675 }
14676 return this._readableState.destroyed && this._writableState.destroyed;
14677 },
14678 set: function (value) {
14679 // we ignore the value if the stream
14680 // has not been initialized yet
14681 if (this._readableState === undefined || this._writableState === undefined) {
14682 return;
14683 }
14684
14685 // backward compatibility, the user is explicitly
14686 // managing destroyed
14687 this._readableState.destroyed = value;
14688 this._writableState.destroyed = value;
14689 }
14690});
14691
14692Duplex.prototype._destroy = function (err, cb) {
14693 this.push(null);
14694 this.end();
14695
14696 pna.nextTick(cb, err);
14697};
14698},{"./_stream_readable":73,"./_stream_writable":75,"core-util-is":44,"inherits":56,"process-nextick-args":68}],72:[function(require,module,exports){
14699// Copyright Joyent, Inc. and other Node contributors.
14700//
14701// Permission is hereby granted, free of charge, to any person obtaining a
14702// copy of this software and associated documentation files (the
14703// "Software"), to deal in the Software without restriction, including
14704// without limitation the rights to use, copy, modify, merge, publish,
14705// distribute, sublicense, and/or sell copies of the Software, and to permit
14706// persons to whom the Software is furnished to do so, subject to the
14707// following conditions:
14708//
14709// The above copyright notice and this permission notice shall be included
14710// in all copies or substantial portions of the Software.
14711//
14712// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14713// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14714// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14715// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14716// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14717// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14718// USE OR OTHER DEALINGS IN THE SOFTWARE.
14719
14720// a passthrough stream.
14721// basically just the most minimal sort of Transform stream.
14722// Every written chunk gets output as-is.
14723
14724'use strict';
14725
14726module.exports = PassThrough;
14727
14728var Transform = require('./_stream_transform');
14729
14730/*<replacement>*/
14731var util = require('core-util-is');
14732util.inherits = require('inherits');
14733/*</replacement>*/
14734
14735util.inherits(PassThrough, Transform);
14736
14737function PassThrough(options) {
14738 if (!(this instanceof PassThrough)) return new PassThrough(options);
14739
14740 Transform.call(this, options);
14741}
14742
14743PassThrough.prototype._transform = function (chunk, encoding, cb) {
14744 cb(null, chunk);
14745};
14746},{"./_stream_transform":74,"core-util-is":44,"inherits":56}],73:[function(require,module,exports){
14747(function (process,global){
14748// Copyright Joyent, Inc. and other Node contributors.
14749//
14750// Permission is hereby granted, free of charge, to any person obtaining a
14751// copy of this software and associated documentation files (the
14752// "Software"), to deal in the Software without restriction, including
14753// without limitation the rights to use, copy, modify, merge, publish,
14754// distribute, sublicense, and/or sell copies of the Software, and to permit
14755// persons to whom the Software is furnished to do so, subject to the
14756// following conditions:
14757//
14758// The above copyright notice and this permission notice shall be included
14759// in all copies or substantial portions of the Software.
14760//
14761// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14762// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14763// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14764// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14765// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14766// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14767// USE OR OTHER DEALINGS IN THE SOFTWARE.
14768
14769'use strict';
14770
14771/*<replacement>*/
14772
14773var pna = require('process-nextick-args');
14774/*</replacement>*/
14775
14776module.exports = Readable;
14777
14778/*<replacement>*/
14779var isArray = require('isarray');
14780/*</replacement>*/
14781
14782/*<replacement>*/
14783var Duplex;
14784/*</replacement>*/
14785
14786Readable.ReadableState = ReadableState;
14787
14788/*<replacement>*/
14789var EE = require('events').EventEmitter;
14790
14791var EElistenerCount = function (emitter, type) {
14792 return emitter.listeners(type).length;
14793};
14794/*</replacement>*/
14795
14796/*<replacement>*/
14797var Stream = require('./internal/streams/stream');
14798/*</replacement>*/
14799
14800/*<replacement>*/
14801
14802var Buffer = require('safe-buffer').Buffer;
14803var OurUint8Array = global.Uint8Array || function () {};
14804function _uint8ArrayToBuffer(chunk) {
14805 return Buffer.from(chunk);
14806}
14807function _isUint8Array(obj) {
14808 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
14809}
14810
14811/*</replacement>*/
14812
14813/*<replacement>*/
14814var util = require('core-util-is');
14815util.inherits = require('inherits');
14816/*</replacement>*/
14817
14818/*<replacement>*/
14819var debugUtil = require('util');
14820var debug = void 0;
14821if (debugUtil && debugUtil.debuglog) {
14822 debug = debugUtil.debuglog('stream');
14823} else {
14824 debug = function () {};
14825}
14826/*</replacement>*/
14827
14828var BufferList = require('./internal/streams/BufferList');
14829var destroyImpl = require('./internal/streams/destroy');
14830var StringDecoder;
14831
14832util.inherits(Readable, Stream);
14833
14834var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
14835
14836function prependListener(emitter, event, fn) {
14837 // Sadly this is not cacheable as some libraries bundle their own
14838 // event emitter implementation with them.
14839 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
14840
14841 // This is a hack to make sure that our error handler is attached before any
14842 // userland ones. NEVER DO THIS. This is here only because this code needs
14843 // to continue to work with older versions of Node.js that do not include
14844 // the prependListener() method. The goal is to eventually remove this hack.
14845 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]];
14846}
14847
14848function ReadableState(options, stream) {
14849 Duplex = Duplex || require('./_stream_duplex');
14850
14851 options = options || {};
14852
14853 // Duplex streams are both readable and writable, but share
14854 // the same options object.
14855 // However, some cases require setting options to different
14856 // values for the readable and the writable sides of the duplex stream.
14857 // These options can be provided separately as readableXXX and writableXXX.
14858 var isDuplex = stream instanceof Duplex;
14859
14860 // object stream flag. Used to make read(n) ignore n and to
14861 // make all the buffer merging and length checks go away
14862 this.objectMode = !!options.objectMode;
14863
14864 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
14865
14866 // the point at which it stops calling _read() to fill the buffer
14867 // Note: 0 is a valid value, means "don't call _read preemptively ever"
14868 var hwm = options.highWaterMark;
14869 var readableHwm = options.readableHighWaterMark;
14870 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
14871
14872 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
14873
14874 // cast to ints.
14875 this.highWaterMark = Math.floor(this.highWaterMark);
14876
14877 // A linked list is used to store data chunks instead of an array because the
14878 // linked list can remove elements from the beginning faster than
14879 // array.shift()
14880 this.buffer = new BufferList();
14881 this.length = 0;
14882 this.pipes = null;
14883 this.pipesCount = 0;
14884 this.flowing = null;
14885 this.ended = false;
14886 this.endEmitted = false;
14887 this.reading = false;
14888
14889 // a flag to be able to tell if the event 'readable'/'data' is emitted
14890 // immediately, or on a later tick. We set this to true at first, because
14891 // any actions that shouldn't happen until "later" should generally also
14892 // not happen before the first read call.
14893 this.sync = true;
14894
14895 // whenever we return null, then we set a flag to say
14896 // that we're awaiting a 'readable' event emission.
14897 this.needReadable = false;
14898 this.emittedReadable = false;
14899 this.readableListening = false;
14900 this.resumeScheduled = false;
14901
14902 // has it been destroyed
14903 this.destroyed = false;
14904
14905 // Crypto is kind of old and crusty. Historically, its default string
14906 // encoding is 'binary' so we have to make this configurable.
14907 // Everything else in the universe uses 'utf8', though.
14908 this.defaultEncoding = options.defaultEncoding || 'utf8';
14909
14910 // the number of writers that are awaiting a drain event in .pipe()s
14911 this.awaitDrain = 0;
14912
14913 // if true, a maybeReadMore has been scheduled
14914 this.readingMore = false;
14915
14916 this.decoder = null;
14917 this.encoding = null;
14918 if (options.encoding) {
14919 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
14920 this.decoder = new StringDecoder(options.encoding);
14921 this.encoding = options.encoding;
14922 }
14923}
14924
14925function Readable(options) {
14926 Duplex = Duplex || require('./_stream_duplex');
14927
14928 if (!(this instanceof Readable)) return new Readable(options);
14929
14930 this._readableState = new ReadableState(options, this);
14931
14932 // legacy
14933 this.readable = true;
14934
14935 if (options) {
14936 if (typeof options.read === 'function') this._read = options.read;
14937
14938 if (typeof options.destroy === 'function') this._destroy = options.destroy;
14939 }
14940
14941 Stream.call(this);
14942}
14943
14944Object.defineProperty(Readable.prototype, 'destroyed', {
14945 get: function () {
14946 if (this._readableState === undefined) {
14947 return false;
14948 }
14949 return this._readableState.destroyed;
14950 },
14951 set: function (value) {
14952 // we ignore the value if the stream
14953 // has not been initialized yet
14954 if (!this._readableState) {
14955 return;
14956 }
14957
14958 // backward compatibility, the user is explicitly
14959 // managing destroyed
14960 this._readableState.destroyed = value;
14961 }
14962});
14963
14964Readable.prototype.destroy = destroyImpl.destroy;
14965Readable.prototype._undestroy = destroyImpl.undestroy;
14966Readable.prototype._destroy = function (err, cb) {
14967 this.push(null);
14968 cb(err);
14969};
14970
14971// Manually shove something into the read() buffer.
14972// This returns true if the highWaterMark has not been hit yet,
14973// similar to how Writable.write() returns true if you should
14974// write() some more.
14975Readable.prototype.push = function (chunk, encoding) {
14976 var state = this._readableState;
14977 var skipChunkCheck;
14978
14979 if (!state.objectMode) {
14980 if (typeof chunk === 'string') {
14981 encoding = encoding || state.defaultEncoding;
14982 if (encoding !== state.encoding) {
14983 chunk = Buffer.from(chunk, encoding);
14984 encoding = '';
14985 }
14986 skipChunkCheck = true;
14987 }
14988 } else {
14989 skipChunkCheck = true;
14990 }
14991
14992 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
14993};
14994
14995// Unshift should *always* be something directly out of read()
14996Readable.prototype.unshift = function (chunk) {
14997 return readableAddChunk(this, chunk, null, true, false);
14998};
14999
15000function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
15001 var state = stream._readableState;
15002 if (chunk === null) {
15003 state.reading = false;
15004 onEofChunk(stream, state);
15005 } else {
15006 var er;
15007 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
15008 if (er) {
15009 stream.emit('error', er);
15010 } else if (state.objectMode || chunk && chunk.length > 0) {
15011 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
15012 chunk = _uint8ArrayToBuffer(chunk);
15013 }
15014
15015 if (addToFront) {
15016 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
15017 } else if (state.ended) {
15018 stream.emit('error', new Error('stream.push() after EOF'));
15019 } else {
15020 state.reading = false;
15021 if (state.decoder && !encoding) {
15022 chunk = state.decoder.write(chunk);
15023 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
15024 } else {
15025 addChunk(stream, state, chunk, false);
15026 }
15027 }
15028 } else if (!addToFront) {
15029 state.reading = false;
15030 }
15031 }
15032
15033 return needMoreData(state);
15034}
15035
15036function addChunk(stream, state, chunk, addToFront) {
15037 if (state.flowing && state.length === 0 && !state.sync) {
15038 stream.emit('data', chunk);
15039 stream.read(0);
15040 } else {
15041 // update the buffer info.
15042 state.length += state.objectMode ? 1 : chunk.length;
15043 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
15044
15045 if (state.needReadable) emitReadable(stream);
15046 }
15047 maybeReadMore(stream, state);
15048}
15049
15050function chunkInvalid(state, chunk) {
15051 var er;
15052 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
15053 er = new TypeError('Invalid non-string/buffer chunk');
15054 }
15055 return er;
15056}
15057
15058// if it's past the high water mark, we can push in some more.
15059// Also, if we have no data yet, we can stand some
15060// more bytes. This is to work around cases where hwm=0,
15061// such as the repl. Also, if the push() triggered a
15062// readable event, and the user called read(largeNumber) such that
15063// needReadable was set, then we ought to push more, so that another
15064// 'readable' event will be triggered.
15065function needMoreData(state) {
15066 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
15067}
15068
15069Readable.prototype.isPaused = function () {
15070 return this._readableState.flowing === false;
15071};
15072
15073// backwards compatibility.
15074Readable.prototype.setEncoding = function (enc) {
15075 if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
15076 this._readableState.decoder = new StringDecoder(enc);
15077 this._readableState.encoding = enc;
15078 return this;
15079};
15080
15081// Don't raise the hwm > 8MB
15082var MAX_HWM = 0x800000;
15083function computeNewHighWaterMark(n) {
15084 if (n >= MAX_HWM) {
15085 n = MAX_HWM;
15086 } else {
15087 // Get the next highest power of 2 to prevent increasing hwm excessively in
15088 // tiny amounts
15089 n--;
15090 n |= n >>> 1;
15091 n |= n >>> 2;
15092 n |= n >>> 4;
15093 n |= n >>> 8;
15094 n |= n >>> 16;
15095 n++;
15096 }
15097 return n;
15098}
15099
15100// This function is designed to be inlinable, so please take care when making
15101// changes to the function body.
15102function howMuchToRead(n, state) {
15103 if (n <= 0 || state.length === 0 && state.ended) return 0;
15104 if (state.objectMode) return 1;
15105 if (n !== n) {
15106 // Only flow one buffer at a time
15107 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
15108 }
15109 // If we're asking for more than the current hwm, then raise the hwm.
15110 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
15111 if (n <= state.length) return n;
15112 // Don't have enough
15113 if (!state.ended) {
15114 state.needReadable = true;
15115 return 0;
15116 }
15117 return state.length;
15118}
15119
15120// you can override either this method, or the async _read(n) below.
15121Readable.prototype.read = function (n) {
15122 debug('read', n);
15123 n = parseInt(n, 10);
15124 var state = this._readableState;
15125 var nOrig = n;
15126
15127 if (n !== 0) state.emittedReadable = false;
15128
15129 // if we're doing read(0) to trigger a readable event, but we
15130 // already have a bunch of data in the buffer, then just trigger
15131 // the 'readable' event and move on.
15132 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
15133 debug('read: emitReadable', state.length, state.ended);
15134 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
15135 return null;
15136 }
15137
15138 n = howMuchToRead(n, state);
15139
15140 // if we've ended, and we're now clear, then finish it up.
15141 if (n === 0 && state.ended) {
15142 if (state.length === 0) endReadable(this);
15143 return null;
15144 }
15145
15146 // All the actual chunk generation logic needs to be
15147 // *below* the call to _read. The reason is that in certain
15148 // synthetic stream cases, such as passthrough streams, _read
15149 // may be a completely synchronous operation which may change
15150 // the state of the read buffer, providing enough data when
15151 // before there was *not* enough.
15152 //
15153 // So, the steps are:
15154 // 1. Figure out what the state of things will be after we do
15155 // a read from the buffer.
15156 //
15157 // 2. If that resulting state will trigger a _read, then call _read.
15158 // Note that this may be asynchronous, or synchronous. Yes, it is
15159 // deeply ugly to write APIs this way, but that still doesn't mean
15160 // that the Readable class should behave improperly, as streams are
15161 // designed to be sync/async agnostic.
15162 // Take note if the _read call is sync or async (ie, if the read call
15163 // has returned yet), so that we know whether or not it's safe to emit
15164 // 'readable' etc.
15165 //
15166 // 3. Actually pull the requested chunks out of the buffer and return.
15167
15168 // if we need a readable event, then we need to do some reading.
15169 var doRead = state.needReadable;
15170 debug('need readable', doRead);
15171
15172 // if we currently have less than the highWaterMark, then also read some
15173 if (state.length === 0 || state.length - n < state.highWaterMark) {
15174 doRead = true;
15175 debug('length less than watermark', doRead);
15176 }
15177
15178 // however, if we've ended, then there's no point, and if we're already
15179 // reading, then it's unnecessary.
15180 if (state.ended || state.reading) {
15181 doRead = false;
15182 debug('reading or ended', doRead);
15183 } else if (doRead) {
15184 debug('do read');
15185 state.reading = true;
15186 state.sync = true;
15187 // if the length is currently zero, then we *need* a readable event.
15188 if (state.length === 0) state.needReadable = true;
15189 // call internal read method
15190 this._read(state.highWaterMark);
15191 state.sync = false;
15192 // If _read pushed data synchronously, then `reading` will be false,
15193 // and we need to re-evaluate how much data we can return to the user.
15194 if (!state.reading) n = howMuchToRead(nOrig, state);
15195 }
15196
15197 var ret;
15198 if (n > 0) ret = fromList(n, state);else ret = null;
15199
15200 if (ret === null) {
15201 state.needReadable = true;
15202 n = 0;
15203 } else {
15204 state.length -= n;
15205 }
15206
15207 if (state.length === 0) {
15208 // If we have nothing in the buffer, then we want to know
15209 // as soon as we *do* get something into the buffer.
15210 if (!state.ended) state.needReadable = true;
15211
15212 // If we tried to read() past the EOF, then emit end on the next tick.
15213 if (nOrig !== n && state.ended) endReadable(this);
15214 }
15215
15216 if (ret !== null) this.emit('data', ret);
15217
15218 return ret;
15219};
15220
15221function onEofChunk(stream, state) {
15222 if (state.ended) return;
15223 if (state.decoder) {
15224 var chunk = state.decoder.end();
15225 if (chunk && chunk.length) {
15226 state.buffer.push(chunk);
15227 state.length += state.objectMode ? 1 : chunk.length;
15228 }
15229 }
15230 state.ended = true;
15231
15232 // emit 'readable' now to make sure it gets picked up.
15233 emitReadable(stream);
15234}
15235
15236// Don't emit readable right away in sync mode, because this can trigger
15237// another read() call => stack overflow. This way, it might trigger
15238// a nextTick recursion warning, but that's not so bad.
15239function emitReadable(stream) {
15240 var state = stream._readableState;
15241 state.needReadable = false;
15242 if (!state.emittedReadable) {
15243 debug('emitReadable', state.flowing);
15244 state.emittedReadable = true;
15245 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
15246 }
15247}
15248
15249function emitReadable_(stream) {
15250 debug('emit readable');
15251 stream.emit('readable');
15252 flow(stream);
15253}
15254
15255// at this point, the user has presumably seen the 'readable' event,
15256// and called read() to consume some data. that may have triggered
15257// in turn another _read(n) call, in which case reading = true if
15258// it's in progress.
15259// However, if we're not ended, or reading, and the length < hwm,
15260// then go ahead and try to read some more preemptively.
15261function maybeReadMore(stream, state) {
15262 if (!state.readingMore) {
15263 state.readingMore = true;
15264 pna.nextTick(maybeReadMore_, stream, state);
15265 }
15266}
15267
15268function maybeReadMore_(stream, state) {
15269 var len = state.length;
15270 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
15271 debug('maybeReadMore read 0');
15272 stream.read(0);
15273 if (len === state.length)
15274 // didn't get any data, stop spinning.
15275 break;else len = state.length;
15276 }
15277 state.readingMore = false;
15278}
15279
15280// abstract method. to be overridden in specific implementation classes.
15281// call cb(er, data) where data is <= n in length.
15282// for virtual (non-string, non-buffer) streams, "length" is somewhat
15283// arbitrary, and perhaps not very meaningful.
15284Readable.prototype._read = function (n) {
15285 this.emit('error', new Error('_read() is not implemented'));
15286};
15287
15288Readable.prototype.pipe = function (dest, pipeOpts) {
15289 var src = this;
15290 var state = this._readableState;
15291
15292 switch (state.pipesCount) {
15293 case 0:
15294 state.pipes = dest;
15295 break;
15296 case 1:
15297 state.pipes = [state.pipes, dest];
15298 break;
15299 default:
15300 state.pipes.push(dest);
15301 break;
15302 }
15303 state.pipesCount += 1;
15304 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
15305
15306 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
15307
15308 var endFn = doEnd ? onend : unpipe;
15309 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
15310
15311 dest.on('unpipe', onunpipe);
15312 function onunpipe(readable, unpipeInfo) {
15313 debug('onunpipe');
15314 if (readable === src) {
15315 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
15316 unpipeInfo.hasUnpiped = true;
15317 cleanup();
15318 }
15319 }
15320 }
15321
15322 function onend() {
15323 debug('onend');
15324 dest.end();
15325 }
15326
15327 // when the dest drains, it reduces the awaitDrain counter
15328 // on the source. This would be more elegant with a .once()
15329 // handler in flow(), but adding and removing repeatedly is
15330 // too slow.
15331 var ondrain = pipeOnDrain(src);
15332 dest.on('drain', ondrain);
15333
15334 var cleanedUp = false;
15335 function cleanup() {
15336 debug('cleanup');
15337 // cleanup event handlers once the pipe is broken
15338 dest.removeListener('close', onclose);
15339 dest.removeListener('finish', onfinish);
15340 dest.removeListener('drain', ondrain);
15341 dest.removeListener('error', onerror);
15342 dest.removeListener('unpipe', onunpipe);
15343 src.removeListener('end', onend);
15344 src.removeListener('end', unpipe);
15345 src.removeListener('data', ondata);
15346
15347 cleanedUp = true;
15348
15349 // if the reader is waiting for a drain event from this
15350 // specific writer, then it would cause it to never start
15351 // flowing again.
15352 // So, if this is awaiting a drain, then we just call it now.
15353 // If we don't know, then assume that we are waiting for one.
15354 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
15355 }
15356
15357 // If the user pushes more data while we're writing to dest then we'll end up
15358 // in ondata again. However, we only want to increase awaitDrain once because
15359 // dest will only emit one 'drain' event for the multiple writes.
15360 // => Introduce a guard on increasing awaitDrain.
15361 var increasedAwaitDrain = false;
15362 src.on('data', ondata);
15363 function ondata(chunk) {
15364 debug('ondata');
15365 increasedAwaitDrain = false;
15366 var ret = dest.write(chunk);
15367 if (false === ret && !increasedAwaitDrain) {
15368 // If the user unpiped during `dest.write()`, it is possible
15369 // to get stuck in a permanently paused state if that write
15370 // also returned false.
15371 // => Check whether `dest` is still a piping destination.
15372 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
15373 debug('false write response, pause', src._readableState.awaitDrain);
15374 src._readableState.awaitDrain++;
15375 increasedAwaitDrain = true;
15376 }
15377 src.pause();
15378 }
15379 }
15380
15381 // if the dest has an error, then stop piping into it.
15382 // however, don't suppress the throwing behavior for this.
15383 function onerror(er) {
15384 debug('onerror', er);
15385 unpipe();
15386 dest.removeListener('error', onerror);
15387 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
15388 }
15389
15390 // Make sure our error handler is attached before userland ones.
15391 prependListener(dest, 'error', onerror);
15392
15393 // Both close and finish should trigger unpipe, but only once.
15394 function onclose() {
15395 dest.removeListener('finish', onfinish);
15396 unpipe();
15397 }
15398 dest.once('close', onclose);
15399 function onfinish() {
15400 debug('onfinish');
15401 dest.removeListener('close', onclose);
15402 unpipe();
15403 }
15404 dest.once('finish', onfinish);
15405
15406 function unpipe() {
15407 debug('unpipe');
15408 src.unpipe(dest);
15409 }
15410
15411 // tell the dest that it's being piped to
15412 dest.emit('pipe', src);
15413
15414 // start the flow if it hasn't been started already.
15415 if (!state.flowing) {
15416 debug('pipe resume');
15417 src.resume();
15418 }
15419
15420 return dest;
15421};
15422
15423function pipeOnDrain(src) {
15424 return function () {
15425 var state = src._readableState;
15426 debug('pipeOnDrain', state.awaitDrain);
15427 if (state.awaitDrain) state.awaitDrain--;
15428 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
15429 state.flowing = true;
15430 flow(src);
15431 }
15432 };
15433}
15434
15435Readable.prototype.unpipe = function (dest) {
15436 var state = this._readableState;
15437 var unpipeInfo = { hasUnpiped: false };
15438
15439 // if we're not piping anywhere, then do nothing.
15440 if (state.pipesCount === 0) return this;
15441
15442 // just one destination. most common case.
15443 if (state.pipesCount === 1) {
15444 // passed in one, but it's not the right one.
15445 if (dest && dest !== state.pipes) return this;
15446
15447 if (!dest) dest = state.pipes;
15448
15449 // got a match.
15450 state.pipes = null;
15451 state.pipesCount = 0;
15452 state.flowing = false;
15453 if (dest) dest.emit('unpipe', this, unpipeInfo);
15454 return this;
15455 }
15456
15457 // slow case. multiple pipe destinations.
15458
15459 if (!dest) {
15460 // remove all.
15461 var dests = state.pipes;
15462 var len = state.pipesCount;
15463 state.pipes = null;
15464 state.pipesCount = 0;
15465 state.flowing = false;
15466
15467 for (var i = 0; i < len; i++) {
15468 dests[i].emit('unpipe', this, unpipeInfo);
15469 }return this;
15470 }
15471
15472 // try to find the right one.
15473 var index = indexOf(state.pipes, dest);
15474 if (index === -1) return this;
15475
15476 state.pipes.splice(index, 1);
15477 state.pipesCount -= 1;
15478 if (state.pipesCount === 1) state.pipes = state.pipes[0];
15479
15480 dest.emit('unpipe', this, unpipeInfo);
15481
15482 return this;
15483};
15484
15485// set up data events if they are asked for
15486// Ensure readable listeners eventually get something
15487Readable.prototype.on = function (ev, fn) {
15488 var res = Stream.prototype.on.call(this, ev, fn);
15489
15490 if (ev === 'data') {
15491 // Start flowing on next tick if stream isn't explicitly paused
15492 if (this._readableState.flowing !== false) this.resume();
15493 } else if (ev === 'readable') {
15494 var state = this._readableState;
15495 if (!state.endEmitted && !state.readableListening) {
15496 state.readableListening = state.needReadable = true;
15497 state.emittedReadable = false;
15498 if (!state.reading) {
15499 pna.nextTick(nReadingNextTick, this);
15500 } else if (state.length) {
15501 emitReadable(this);
15502 }
15503 }
15504 }
15505
15506 return res;
15507};
15508Readable.prototype.addListener = Readable.prototype.on;
15509
15510function nReadingNextTick(self) {
15511 debug('readable nexttick read 0');
15512 self.read(0);
15513}
15514
15515// pause() and resume() are remnants of the legacy readable stream API
15516// If the user uses them, then switch into old mode.
15517Readable.prototype.resume = function () {
15518 var state = this._readableState;
15519 if (!state.flowing) {
15520 debug('resume');
15521 state.flowing = true;
15522 resume(this, state);
15523 }
15524 return this;
15525};
15526
15527function resume(stream, state) {
15528 if (!state.resumeScheduled) {
15529 state.resumeScheduled = true;
15530 pna.nextTick(resume_, stream, state);
15531 }
15532}
15533
15534function resume_(stream, state) {
15535 if (!state.reading) {
15536 debug('resume read 0');
15537 stream.read(0);
15538 }
15539
15540 state.resumeScheduled = false;
15541 state.awaitDrain = 0;
15542 stream.emit('resume');
15543 flow(stream);
15544 if (state.flowing && !state.reading) stream.read(0);
15545}
15546
15547Readable.prototype.pause = function () {
15548 debug('call pause flowing=%j', this._readableState.flowing);
15549 if (false !== this._readableState.flowing) {
15550 debug('pause');
15551 this._readableState.flowing = false;
15552 this.emit('pause');
15553 }
15554 return this;
15555};
15556
15557function flow(stream) {
15558 var state = stream._readableState;
15559 debug('flow', state.flowing);
15560 while (state.flowing && stream.read() !== null) {}
15561}
15562
15563// wrap an old-style stream as the async data source.
15564// This is *not* part of the readable stream interface.
15565// It is an ugly unfortunate mess of history.
15566Readable.prototype.wrap = function (stream) {
15567 var _this = this;
15568
15569 var state = this._readableState;
15570 var paused = false;
15571
15572 stream.on('end', function () {
15573 debug('wrapped end');
15574 if (state.decoder && !state.ended) {
15575 var chunk = state.decoder.end();
15576 if (chunk && chunk.length) _this.push(chunk);
15577 }
15578
15579 _this.push(null);
15580 });
15581
15582 stream.on('data', function (chunk) {
15583 debug('wrapped data');
15584 if (state.decoder) chunk = state.decoder.write(chunk);
15585
15586 // don't skip over falsy values in objectMode
15587 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
15588
15589 var ret = _this.push(chunk);
15590 if (!ret) {
15591 paused = true;
15592 stream.pause();
15593 }
15594 });
15595
15596 // proxy all the other methods.
15597 // important when wrapping filters and duplexes.
15598 for (var i in stream) {
15599 if (this[i] === undefined && typeof stream[i] === 'function') {
15600 this[i] = function (method) {
15601 return function () {
15602 return stream[method].apply(stream, arguments);
15603 };
15604 }(i);
15605 }
15606 }
15607
15608 // proxy certain important events.
15609 for (var n = 0; n < kProxyEvents.length; n++) {
15610 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
15611 }
15612
15613 // when we try to consume some more bytes, simply unpause the
15614 // underlying stream.
15615 this._read = function (n) {
15616 debug('wrapped _read', n);
15617 if (paused) {
15618 paused = false;
15619 stream.resume();
15620 }
15621 };
15622
15623 return this;
15624};
15625
15626Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
15627 // making it explicit this property is not enumerable
15628 // because otherwise some prototype manipulation in
15629 // userland will fail
15630 enumerable: false,
15631 get: function () {
15632 return this._readableState.highWaterMark;
15633 }
15634});
15635
15636// exposed for testing purposes only.
15637Readable._fromList = fromList;
15638
15639// Pluck off n bytes from an array of buffers.
15640// Length is the combined lengths of all the buffers in the list.
15641// This function is designed to be inlinable, so please take care when making
15642// changes to the function body.
15643function fromList(n, state) {
15644 // nothing buffered
15645 if (state.length === 0) return null;
15646
15647 var ret;
15648 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
15649 // read it all, truncate the list
15650 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);
15651 state.buffer.clear();
15652 } else {
15653 // read part of list
15654 ret = fromListPartial(n, state.buffer, state.decoder);
15655 }
15656
15657 return ret;
15658}
15659
15660// Extracts only enough buffered data to satisfy the amount requested.
15661// This function is designed to be inlinable, so please take care when making
15662// changes to the function body.
15663function fromListPartial(n, list, hasStrings) {
15664 var ret;
15665 if (n < list.head.data.length) {
15666 // slice is the same for buffers and strings
15667 ret = list.head.data.slice(0, n);
15668 list.head.data = list.head.data.slice(n);
15669 } else if (n === list.head.data.length) {
15670 // first chunk is a perfect match
15671 ret = list.shift();
15672 } else {
15673 // result spans more than one buffer
15674 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
15675 }
15676 return ret;
15677}
15678
15679// Copies a specified amount of characters from the list of buffered data
15680// chunks.
15681// This function is designed to be inlinable, so please take care when making
15682// changes to the function body.
15683function copyFromBufferString(n, list) {
15684 var p = list.head;
15685 var c = 1;
15686 var ret = p.data;
15687 n -= ret.length;
15688 while (p = p.next) {
15689 var str = p.data;
15690 var nb = n > str.length ? str.length : n;
15691 if (nb === str.length) ret += str;else ret += str.slice(0, n);
15692 n -= nb;
15693 if (n === 0) {
15694 if (nb === str.length) {
15695 ++c;
15696 if (p.next) list.head = p.next;else list.head = list.tail = null;
15697 } else {
15698 list.head = p;
15699 p.data = str.slice(nb);
15700 }
15701 break;
15702 }
15703 ++c;
15704 }
15705 list.length -= c;
15706 return ret;
15707}
15708
15709// Copies a specified amount of bytes from the list of buffered data chunks.
15710// This function is designed to be inlinable, so please take care when making
15711// changes to the function body.
15712function copyFromBuffer(n, list) {
15713 var ret = Buffer.allocUnsafe(n);
15714 var p = list.head;
15715 var c = 1;
15716 p.data.copy(ret);
15717 n -= p.data.length;
15718 while (p = p.next) {
15719 var buf = p.data;
15720 var nb = n > buf.length ? buf.length : n;
15721 buf.copy(ret, ret.length - n, 0, nb);
15722 n -= nb;
15723 if (n === 0) {
15724 if (nb === buf.length) {
15725 ++c;
15726 if (p.next) list.head = p.next;else list.head = list.tail = null;
15727 } else {
15728 list.head = p;
15729 p.data = buf.slice(nb);
15730 }
15731 break;
15732 }
15733 ++c;
15734 }
15735 list.length -= c;
15736 return ret;
15737}
15738
15739function endReadable(stream) {
15740 var state = stream._readableState;
15741
15742 // If we get here before consuming all the bytes, then that is a
15743 // bug in node. Should never happen.
15744 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
15745
15746 if (!state.endEmitted) {
15747 state.ended = true;
15748 pna.nextTick(endReadableNT, state, stream);
15749 }
15750}
15751
15752function endReadableNT(state, stream) {
15753 // Check that we didn't get one last unshift.
15754 if (!state.endEmitted && state.length === 0) {
15755 state.endEmitted = true;
15756 stream.readable = false;
15757 stream.emit('end');
15758 }
15759}
15760
15761function indexOf(xs, x) {
15762 for (var i = 0, l = xs.length; i < l; i++) {
15763 if (xs[i] === x) return i;
15764 }
15765 return -1;
15766}
15767}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
15768},{"./_stream_duplex":71,"./internal/streams/BufferList":76,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"events":50,"inherits":56,"isarray":58,"process-nextick-args":68,"safe-buffer":83,"string_decoder/":85,"util":40}],74:[function(require,module,exports){
15769// Copyright Joyent, Inc. and other Node contributors.
15770//
15771// Permission is hereby granted, free of charge, to any person obtaining a
15772// copy of this software and associated documentation files (the
15773// "Software"), to deal in the Software without restriction, including
15774// without limitation the rights to use, copy, modify, merge, publish,
15775// distribute, sublicense, and/or sell copies of the Software, and to permit
15776// persons to whom the Software is furnished to do so, subject to the
15777// following conditions:
15778//
15779// The above copyright notice and this permission notice shall be included
15780// in all copies or substantial portions of the Software.
15781//
15782// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15783// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15784// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
15785// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15786// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15787// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
15788// USE OR OTHER DEALINGS IN THE SOFTWARE.
15789
15790// a transform stream is a readable/writable stream where you do
15791// something with the data. Sometimes it's called a "filter",
15792// but that's not a great name for it, since that implies a thing where
15793// some bits pass through, and others are simply ignored. (That would
15794// be a valid example of a transform, of course.)
15795//
15796// While the output is causally related to the input, it's not a
15797// necessarily symmetric or synchronous transformation. For example,
15798// a zlib stream might take multiple plain-text writes(), and then
15799// emit a single compressed chunk some time in the future.
15800//
15801// Here's how this works:
15802//
15803// The Transform stream has all the aspects of the readable and writable
15804// stream classes. When you write(chunk), that calls _write(chunk,cb)
15805// internally, and returns false if there's a lot of pending writes
15806// buffered up. When you call read(), that calls _read(n) until
15807// there's enough pending readable data buffered up.
15808//
15809// In a transform stream, the written data is placed in a buffer. When
15810// _read(n) is called, it transforms the queued up data, calling the
15811// buffered _write cb's as it consumes chunks. If consuming a single
15812// written chunk would result in multiple output chunks, then the first
15813// outputted bit calls the readcb, and subsequent chunks just go into
15814// the read buffer, and will cause it to emit 'readable' if necessary.
15815//
15816// This way, back-pressure is actually determined by the reading side,
15817// since _read has to be called to start processing a new chunk. However,
15818// a pathological inflate type of transform can cause excessive buffering
15819// here. For example, imagine a stream where every byte of input is
15820// interpreted as an integer from 0-255, and then results in that many
15821// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
15822// 1kb of data being output. In this case, you could write a very small
15823// amount of input, and end up with a very large amount of output. In
15824// such a pathological inflating mechanism, there'd be no way to tell
15825// the system to stop doing the transform. A single 4MB write could
15826// cause the system to run out of memory.
15827//
15828// However, even in such a pathological case, only a single written chunk
15829// would be consumed, and then the rest would wait (un-transformed) until
15830// the results of the previous transformed chunk were consumed.
15831
15832'use strict';
15833
15834module.exports = Transform;
15835
15836var Duplex = require('./_stream_duplex');
15837
15838/*<replacement>*/
15839var util = require('core-util-is');
15840util.inherits = require('inherits');
15841/*</replacement>*/
15842
15843util.inherits(Transform, Duplex);
15844
15845function afterTransform(er, data) {
15846 var ts = this._transformState;
15847 ts.transforming = false;
15848
15849 var cb = ts.writecb;
15850
15851 if (!cb) {
15852 return this.emit('error', new Error('write callback called multiple times'));
15853 }
15854
15855 ts.writechunk = null;
15856 ts.writecb = null;
15857
15858 if (data != null) // single equals check for both `null` and `undefined`
15859 this.push(data);
15860
15861 cb(er);
15862
15863 var rs = this._readableState;
15864 rs.reading = false;
15865 if (rs.needReadable || rs.length < rs.highWaterMark) {
15866 this._read(rs.highWaterMark);
15867 }
15868}
15869
15870function Transform(options) {
15871 if (!(this instanceof Transform)) return new Transform(options);
15872
15873 Duplex.call(this, options);
15874
15875 this._transformState = {
15876 afterTransform: afterTransform.bind(this),
15877 needTransform: false,
15878 transforming: false,
15879 writecb: null,
15880 writechunk: null,
15881 writeencoding: null
15882 };
15883
15884 // start out asking for a readable event once data is transformed.
15885 this._readableState.needReadable = true;
15886
15887 // we have implemented the _read method, and done the other things
15888 // that Readable wants before the first _read call, so unset the
15889 // sync guard flag.
15890 this._readableState.sync = false;
15891
15892 if (options) {
15893 if (typeof options.transform === 'function') this._transform = options.transform;
15894
15895 if (typeof options.flush === 'function') this._flush = options.flush;
15896 }
15897
15898 // When the writable side finishes, then flush out anything remaining.
15899 this.on('prefinish', prefinish);
15900}
15901
15902function prefinish() {
15903 var _this = this;
15904
15905 if (typeof this._flush === 'function') {
15906 this._flush(function (er, data) {
15907 done(_this, er, data);
15908 });
15909 } else {
15910 done(this, null, null);
15911 }
15912}
15913
15914Transform.prototype.push = function (chunk, encoding) {
15915 this._transformState.needTransform = false;
15916 return Duplex.prototype.push.call(this, chunk, encoding);
15917};
15918
15919// This is the part where you do stuff!
15920// override this function in implementation classes.
15921// 'chunk' is an input chunk.
15922//
15923// Call `push(newChunk)` to pass along transformed output
15924// to the readable side. You may call 'push' zero or more times.
15925//
15926// Call `cb(err)` when you are done with this chunk. If you pass
15927// an error, then that'll put the hurt on the whole operation. If you
15928// never call cb(), then you'll never get another chunk.
15929Transform.prototype._transform = function (chunk, encoding, cb) {
15930 throw new Error('_transform() is not implemented');
15931};
15932
15933Transform.prototype._write = function (chunk, encoding, cb) {
15934 var ts = this._transformState;
15935 ts.writecb = cb;
15936 ts.writechunk = chunk;
15937 ts.writeencoding = encoding;
15938 if (!ts.transforming) {
15939 var rs = this._readableState;
15940 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
15941 }
15942};
15943
15944// Doesn't matter what the args are here.
15945// _transform does all the work.
15946// That we got here means that the readable side wants more data.
15947Transform.prototype._read = function (n) {
15948 var ts = this._transformState;
15949
15950 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
15951 ts.transforming = true;
15952 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
15953 } else {
15954 // mark that we need a transform, so that any data that comes in
15955 // will get processed, now that we've asked for it.
15956 ts.needTransform = true;
15957 }
15958};
15959
15960Transform.prototype._destroy = function (err, cb) {
15961 var _this2 = this;
15962
15963 Duplex.prototype._destroy.call(this, err, function (err2) {
15964 cb(err2);
15965 _this2.emit('close');
15966 });
15967};
15968
15969function done(stream, er, data) {
15970 if (er) return stream.emit('error', er);
15971
15972 if (data != null) // single equals check for both `null` and `undefined`
15973 stream.push(data);
15974
15975 // if there's nothing in the write buffer, then that means
15976 // that nothing more will ever be provided
15977 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
15978
15979 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
15980
15981 return stream.push(null);
15982}
15983},{"./_stream_duplex":71,"core-util-is":44,"inherits":56}],75:[function(require,module,exports){
15984(function (process,global,setImmediate){
15985// Copyright Joyent, Inc. and other Node contributors.
15986//
15987// Permission is hereby granted, free of charge, to any person obtaining a
15988// copy of this software and associated documentation files (the
15989// "Software"), to deal in the Software without restriction, including
15990// without limitation the rights to use, copy, modify, merge, publish,
15991// distribute, sublicense, and/or sell copies of the Software, and to permit
15992// persons to whom the Software is furnished to do so, subject to the
15993// following conditions:
15994//
15995// The above copyright notice and this permission notice shall be included
15996// in all copies or substantial portions of the Software.
15997//
15998// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15999// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16000// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16001// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16002// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16003// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16004// USE OR OTHER DEALINGS IN THE SOFTWARE.
16005
16006// A bit simpler than readable streams.
16007// Implement an async ._write(chunk, encoding, cb), and it'll handle all
16008// the drain event emission and buffering.
16009
16010'use strict';
16011
16012/*<replacement>*/
16013
16014var pna = require('process-nextick-args');
16015/*</replacement>*/
16016
16017module.exports = Writable;
16018
16019/* <replacement> */
16020function WriteReq(chunk, encoding, cb) {
16021 this.chunk = chunk;
16022 this.encoding = encoding;
16023 this.callback = cb;
16024 this.next = null;
16025}
16026
16027// It seems a linked list but it is not
16028// there will be only 2 of these for each stream
16029function CorkedRequest(state) {
16030 var _this = this;
16031
16032 this.next = null;
16033 this.entry = null;
16034 this.finish = function () {
16035 onCorkedFinish(_this, state);
16036 };
16037}
16038/* </replacement> */
16039
16040/*<replacement>*/
16041var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
16042/*</replacement>*/
16043
16044/*<replacement>*/
16045var Duplex;
16046/*</replacement>*/
16047
16048Writable.WritableState = WritableState;
16049
16050/*<replacement>*/
16051var util = require('core-util-is');
16052util.inherits = require('inherits');
16053/*</replacement>*/
16054
16055/*<replacement>*/
16056var internalUtil = {
16057 deprecate: require('util-deprecate')
16058};
16059/*</replacement>*/
16060
16061/*<replacement>*/
16062var Stream = require('./internal/streams/stream');
16063/*</replacement>*/
16064
16065/*<replacement>*/
16066
16067var Buffer = require('safe-buffer').Buffer;
16068var OurUint8Array = global.Uint8Array || function () {};
16069function _uint8ArrayToBuffer(chunk) {
16070 return Buffer.from(chunk);
16071}
16072function _isUint8Array(obj) {
16073 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
16074}
16075
16076/*</replacement>*/
16077
16078var destroyImpl = require('./internal/streams/destroy');
16079
16080util.inherits(Writable, Stream);
16081
16082function nop() {}
16083
16084function WritableState(options, stream) {
16085 Duplex = Duplex || require('./_stream_duplex');
16086
16087 options = options || {};
16088
16089 // Duplex streams are both readable and writable, but share
16090 // the same options object.
16091 // However, some cases require setting options to different
16092 // values for the readable and the writable sides of the duplex stream.
16093 // These options can be provided separately as readableXXX and writableXXX.
16094 var isDuplex = stream instanceof Duplex;
16095
16096 // object stream flag to indicate whether or not this stream
16097 // contains buffers or objects.
16098 this.objectMode = !!options.objectMode;
16099
16100 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
16101
16102 // the point at which write() starts returning false
16103 // Note: 0 is a valid value, means that we always return false if
16104 // the entire buffer is not flushed immediately on write()
16105 var hwm = options.highWaterMark;
16106 var writableHwm = options.writableHighWaterMark;
16107 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
16108
16109 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
16110
16111 // cast to ints.
16112 this.highWaterMark = Math.floor(this.highWaterMark);
16113
16114 // if _final has been called
16115 this.finalCalled = false;
16116
16117 // drain event flag.
16118 this.needDrain = false;
16119 // at the start of calling end()
16120 this.ending = false;
16121 // when end() has been called, and returned
16122 this.ended = false;
16123 // when 'finish' is emitted
16124 this.finished = false;
16125
16126 // has it been destroyed
16127 this.destroyed = false;
16128
16129 // should we decode strings into buffers before passing to _write?
16130 // this is here so that some node-core streams can optimize string
16131 // handling at a lower level.
16132 var noDecode = options.decodeStrings === false;
16133 this.decodeStrings = !noDecode;
16134
16135 // Crypto is kind of old and crusty. Historically, its default string
16136 // encoding is 'binary' so we have to make this configurable.
16137 // Everything else in the universe uses 'utf8', though.
16138 this.defaultEncoding = options.defaultEncoding || 'utf8';
16139
16140 // not an actual buffer we keep track of, but a measurement
16141 // of how much we're waiting to get pushed to some underlying
16142 // socket or file.
16143 this.length = 0;
16144
16145 // a flag to see when we're in the middle of a write.
16146 this.writing = false;
16147
16148 // when true all writes will be buffered until .uncork() call
16149 this.corked = 0;
16150
16151 // a flag to be able to tell if the onwrite cb is called immediately,
16152 // or on a later tick. We set this to true at first, because any
16153 // actions that shouldn't happen until "later" should generally also
16154 // not happen before the first write call.
16155 this.sync = true;
16156
16157 // a flag to know if we're processing previously buffered items, which
16158 // may call the _write() callback in the same tick, so that we don't
16159 // end up in an overlapped onwrite situation.
16160 this.bufferProcessing = false;
16161
16162 // the callback that's passed to _write(chunk,cb)
16163 this.onwrite = function (er) {
16164 onwrite(stream, er);
16165 };
16166
16167 // the callback that the user supplies to write(chunk,encoding,cb)
16168 this.writecb = null;
16169
16170 // the amount that is being written when _write is called.
16171 this.writelen = 0;
16172
16173 this.bufferedRequest = null;
16174 this.lastBufferedRequest = null;
16175
16176 // number of pending user-supplied write callbacks
16177 // this must be 0 before 'finish' can be emitted
16178 this.pendingcb = 0;
16179
16180 // emit prefinish if the only thing we're waiting for is _write cbs
16181 // This is relevant for synchronous Transform streams
16182 this.prefinished = false;
16183
16184 // True if the error was already emitted and should not be thrown again
16185 this.errorEmitted = false;
16186
16187 // count buffered requests
16188 this.bufferedRequestCount = 0;
16189
16190 // allocate the first CorkedRequest, there is always
16191 // one allocated and free to use, and we maintain at most two
16192 this.corkedRequestsFree = new CorkedRequest(this);
16193}
16194
16195WritableState.prototype.getBuffer = function getBuffer() {
16196 var current = this.bufferedRequest;
16197 var out = [];
16198 while (current) {
16199 out.push(current);
16200 current = current.next;
16201 }
16202 return out;
16203};
16204
16205(function () {
16206 try {
16207 Object.defineProperty(WritableState.prototype, 'buffer', {
16208 get: internalUtil.deprecate(function () {
16209 return this.getBuffer();
16210 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
16211 });
16212 } catch (_) {}
16213})();
16214
16215// Test _writableState for inheritance to account for Duplex streams,
16216// whose prototype chain only points to Readable.
16217var realHasInstance;
16218if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
16219 realHasInstance = Function.prototype[Symbol.hasInstance];
16220 Object.defineProperty(Writable, Symbol.hasInstance, {
16221 value: function (object) {
16222 if (realHasInstance.call(this, object)) return true;
16223 if (this !== Writable) return false;
16224
16225 return object && object._writableState instanceof WritableState;
16226 }
16227 });
16228} else {
16229 realHasInstance = function (object) {
16230 return object instanceof this;
16231 };
16232}
16233
16234function Writable(options) {
16235 Duplex = Duplex || require('./_stream_duplex');
16236
16237 // Writable ctor is applied to Duplexes, too.
16238 // `realHasInstance` is necessary because using plain `instanceof`
16239 // would return false, as no `_writableState` property is attached.
16240
16241 // Trying to use the custom `instanceof` for Writable here will also break the
16242 // Node.js LazyTransform implementation, which has a non-trivial getter for
16243 // `_writableState` that would lead to infinite recursion.
16244 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
16245 return new Writable(options);
16246 }
16247
16248 this._writableState = new WritableState(options, this);
16249
16250 // legacy.
16251 this.writable = true;
16252
16253 if (options) {
16254 if (typeof options.write === 'function') this._write = options.write;
16255
16256 if (typeof options.writev === 'function') this._writev = options.writev;
16257
16258 if (typeof options.destroy === 'function') this._destroy = options.destroy;
16259
16260 if (typeof options.final === 'function') this._final = options.final;
16261 }
16262
16263 Stream.call(this);
16264}
16265
16266// Otherwise people can pipe Writable streams, which is just wrong.
16267Writable.prototype.pipe = function () {
16268 this.emit('error', new Error('Cannot pipe, not readable'));
16269};
16270
16271function writeAfterEnd(stream, cb) {
16272 var er = new Error('write after end');
16273 // TODO: defer error events consistently everywhere, not just the cb
16274 stream.emit('error', er);
16275 pna.nextTick(cb, er);
16276}
16277
16278// Checks that a user-supplied chunk is valid, especially for the particular
16279// mode the stream is in. Currently this means that `null` is never accepted
16280// and undefined/non-string values are only allowed in object mode.
16281function validChunk(stream, state, chunk, cb) {
16282 var valid = true;
16283 var er = false;
16284
16285 if (chunk === null) {
16286 er = new TypeError('May not write null values to stream');
16287 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
16288 er = new TypeError('Invalid non-string/buffer chunk');
16289 }
16290 if (er) {
16291 stream.emit('error', er);
16292 pna.nextTick(cb, er);
16293 valid = false;
16294 }
16295 return valid;
16296}
16297
16298Writable.prototype.write = function (chunk, encoding, cb) {
16299 var state = this._writableState;
16300 var ret = false;
16301 var isBuf = !state.objectMode && _isUint8Array(chunk);
16302
16303 if (isBuf && !Buffer.isBuffer(chunk)) {
16304 chunk = _uint8ArrayToBuffer(chunk);
16305 }
16306
16307 if (typeof encoding === 'function') {
16308 cb = encoding;
16309 encoding = null;
16310 }
16311
16312 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
16313
16314 if (typeof cb !== 'function') cb = nop;
16315
16316 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
16317 state.pendingcb++;
16318 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
16319 }
16320
16321 return ret;
16322};
16323
16324Writable.prototype.cork = function () {
16325 var state = this._writableState;
16326
16327 state.corked++;
16328};
16329
16330Writable.prototype.uncork = function () {
16331 var state = this._writableState;
16332
16333 if (state.corked) {
16334 state.corked--;
16335
16336 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
16337 }
16338};
16339
16340Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
16341 // node::ParseEncoding() requires lower case.
16342 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
16343 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);
16344 this._writableState.defaultEncoding = encoding;
16345 return this;
16346};
16347
16348function decodeChunk(state, chunk, encoding) {
16349 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
16350 chunk = Buffer.from(chunk, encoding);
16351 }
16352 return chunk;
16353}
16354
16355Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
16356 // making it explicit this property is not enumerable
16357 // because otherwise some prototype manipulation in
16358 // userland will fail
16359 enumerable: false,
16360 get: function () {
16361 return this._writableState.highWaterMark;
16362 }
16363});
16364
16365// if we're already writing something, then just put this
16366// in the queue, and wait our turn. Otherwise, call _write
16367// If we return false, then we need a drain event, so set that flag.
16368function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
16369 if (!isBuf) {
16370 var newChunk = decodeChunk(state, chunk, encoding);
16371 if (chunk !== newChunk) {
16372 isBuf = true;
16373 encoding = 'buffer';
16374 chunk = newChunk;
16375 }
16376 }
16377 var len = state.objectMode ? 1 : chunk.length;
16378
16379 state.length += len;
16380
16381 var ret = state.length < state.highWaterMark;
16382 // we must ensure that previous needDrain will not be reset to false.
16383 if (!ret) state.needDrain = true;
16384
16385 if (state.writing || state.corked) {
16386 var last = state.lastBufferedRequest;
16387 state.lastBufferedRequest = {
16388 chunk: chunk,
16389 encoding: encoding,
16390 isBuf: isBuf,
16391 callback: cb,
16392 next: null
16393 };
16394 if (last) {
16395 last.next = state.lastBufferedRequest;
16396 } else {
16397 state.bufferedRequest = state.lastBufferedRequest;
16398 }
16399 state.bufferedRequestCount += 1;
16400 } else {
16401 doWrite(stream, state, false, len, chunk, encoding, cb);
16402 }
16403
16404 return ret;
16405}
16406
16407function doWrite(stream, state, writev, len, chunk, encoding, cb) {
16408 state.writelen = len;
16409 state.writecb = cb;
16410 state.writing = true;
16411 state.sync = true;
16412 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
16413 state.sync = false;
16414}
16415
16416function onwriteError(stream, state, sync, er, cb) {
16417 --state.pendingcb;
16418
16419 if (sync) {
16420 // defer the callback if we are being called synchronously
16421 // to avoid piling up things on the stack
16422 pna.nextTick(cb, er);
16423 // this can emit finish, and it will always happen
16424 // after error
16425 pna.nextTick(finishMaybe, stream, state);
16426 stream._writableState.errorEmitted = true;
16427 stream.emit('error', er);
16428 } else {
16429 // the caller expect this to happen before if
16430 // it is async
16431 cb(er);
16432 stream._writableState.errorEmitted = true;
16433 stream.emit('error', er);
16434 // this can emit finish, but finish must
16435 // always follow error
16436 finishMaybe(stream, state);
16437 }
16438}
16439
16440function onwriteStateUpdate(state) {
16441 state.writing = false;
16442 state.writecb = null;
16443 state.length -= state.writelen;
16444 state.writelen = 0;
16445}
16446
16447function onwrite(stream, er) {
16448 var state = stream._writableState;
16449 var sync = state.sync;
16450 var cb = state.writecb;
16451
16452 onwriteStateUpdate(state);
16453
16454 if (er) onwriteError(stream, state, sync, er, cb);else {
16455 // Check if we're actually ready to finish, but don't emit yet
16456 var finished = needFinish(state);
16457
16458 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
16459 clearBuffer(stream, state);
16460 }
16461
16462 if (sync) {
16463 /*<replacement>*/
16464 asyncWrite(afterWrite, stream, state, finished, cb);
16465 /*</replacement>*/
16466 } else {
16467 afterWrite(stream, state, finished, cb);
16468 }
16469 }
16470}
16471
16472function afterWrite(stream, state, finished, cb) {
16473 if (!finished) onwriteDrain(stream, state);
16474 state.pendingcb--;
16475 cb();
16476 finishMaybe(stream, state);
16477}
16478
16479// Must force callback to be called on nextTick, so that we don't
16480// emit 'drain' before the write() consumer gets the 'false' return
16481// value, and has a chance to attach a 'drain' listener.
16482function onwriteDrain(stream, state) {
16483 if (state.length === 0 && state.needDrain) {
16484 state.needDrain = false;
16485 stream.emit('drain');
16486 }
16487}
16488
16489// if there's something in the buffer waiting, then process it
16490function clearBuffer(stream, state) {
16491 state.bufferProcessing = true;
16492 var entry = state.bufferedRequest;
16493
16494 if (stream._writev && entry && entry.next) {
16495 // Fast case, write everything using _writev()
16496 var l = state.bufferedRequestCount;
16497 var buffer = new Array(l);
16498 var holder = state.corkedRequestsFree;
16499 holder.entry = entry;
16500
16501 var count = 0;
16502 var allBuffers = true;
16503 while (entry) {
16504 buffer[count] = entry;
16505 if (!entry.isBuf) allBuffers = false;
16506 entry = entry.next;
16507 count += 1;
16508 }
16509 buffer.allBuffers = allBuffers;
16510
16511 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
16512
16513 // doWrite is almost always async, defer these to save a bit of time
16514 // as the hot path ends with doWrite
16515 state.pendingcb++;
16516 state.lastBufferedRequest = null;
16517 if (holder.next) {
16518 state.corkedRequestsFree = holder.next;
16519 holder.next = null;
16520 } else {
16521 state.corkedRequestsFree = new CorkedRequest(state);
16522 }
16523 state.bufferedRequestCount = 0;
16524 } else {
16525 // Slow case, write chunks one-by-one
16526 while (entry) {
16527 var chunk = entry.chunk;
16528 var encoding = entry.encoding;
16529 var cb = entry.callback;
16530 var len = state.objectMode ? 1 : chunk.length;
16531
16532 doWrite(stream, state, false, len, chunk, encoding, cb);
16533 entry = entry.next;
16534 state.bufferedRequestCount--;
16535 // if we didn't call the onwrite immediately, then
16536 // it means that we need to wait until it does.
16537 // also, that means that the chunk and cb are currently
16538 // being processed, so move the buffer counter past them.
16539 if (state.writing) {
16540 break;
16541 }
16542 }
16543
16544 if (entry === null) state.lastBufferedRequest = null;
16545 }
16546
16547 state.bufferedRequest = entry;
16548 state.bufferProcessing = false;
16549}
16550
16551Writable.prototype._write = function (chunk, encoding, cb) {
16552 cb(new Error('_write() is not implemented'));
16553};
16554
16555Writable.prototype._writev = null;
16556
16557Writable.prototype.end = function (chunk, encoding, cb) {
16558 var state = this._writableState;
16559
16560 if (typeof chunk === 'function') {
16561 cb = chunk;
16562 chunk = null;
16563 encoding = null;
16564 } else if (typeof encoding === 'function') {
16565 cb = encoding;
16566 encoding = null;
16567 }
16568
16569 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
16570
16571 // .end() fully uncorks
16572 if (state.corked) {
16573 state.corked = 1;
16574 this.uncork();
16575 }
16576
16577 // ignore unnecessary end() calls.
16578 if (!state.ending && !state.finished) endWritable(this, state, cb);
16579};
16580
16581function needFinish(state) {
16582 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
16583}
16584function callFinal(stream, state) {
16585 stream._final(function (err) {
16586 state.pendingcb--;
16587 if (err) {
16588 stream.emit('error', err);
16589 }
16590 state.prefinished = true;
16591 stream.emit('prefinish');
16592 finishMaybe(stream, state);
16593 });
16594}
16595function prefinish(stream, state) {
16596 if (!state.prefinished && !state.finalCalled) {
16597 if (typeof stream._final === 'function') {
16598 state.pendingcb++;
16599 state.finalCalled = true;
16600 pna.nextTick(callFinal, stream, state);
16601 } else {
16602 state.prefinished = true;
16603 stream.emit('prefinish');
16604 }
16605 }
16606}
16607
16608function finishMaybe(stream, state) {
16609 var need = needFinish(state);
16610 if (need) {
16611 prefinish(stream, state);
16612 if (state.pendingcb === 0) {
16613 state.finished = true;
16614 stream.emit('finish');
16615 }
16616 }
16617 return need;
16618}
16619
16620function endWritable(stream, state, cb) {
16621 state.ending = true;
16622 finishMaybe(stream, state);
16623 if (cb) {
16624 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
16625 }
16626 state.ended = true;
16627 stream.writable = false;
16628}
16629
16630function onCorkedFinish(corkReq, state, err) {
16631 var entry = corkReq.entry;
16632 corkReq.entry = null;
16633 while (entry) {
16634 var cb = entry.callback;
16635 state.pendingcb--;
16636 cb(err);
16637 entry = entry.next;
16638 }
16639 if (state.corkedRequestsFree) {
16640 state.corkedRequestsFree.next = corkReq;
16641 } else {
16642 state.corkedRequestsFree = corkReq;
16643 }
16644}
16645
16646Object.defineProperty(Writable.prototype, 'destroyed', {
16647 get: function () {
16648 if (this._writableState === undefined) {
16649 return false;
16650 }
16651 return this._writableState.destroyed;
16652 },
16653 set: function (value) {
16654 // we ignore the value if the stream
16655 // has not been initialized yet
16656 if (!this._writableState) {
16657 return;
16658 }
16659
16660 // backward compatibility, the user is explicitly
16661 // managing destroyed
16662 this._writableState.destroyed = value;
16663 }
16664});
16665
16666Writable.prototype.destroy = destroyImpl.destroy;
16667Writable.prototype._undestroy = destroyImpl.undestroy;
16668Writable.prototype._destroy = function (err, cb) {
16669 this.end();
16670 cb(err);
16671};
16672}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
16673},{"./_stream_duplex":71,"./internal/streams/destroy":77,"./internal/streams/stream":78,"_process":69,"core-util-is":44,"inherits":56,"process-nextick-args":68,"safe-buffer":83,"timers":86,"util-deprecate":87}],76:[function(require,module,exports){
16674'use strict';
16675
16676function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16677
16678var Buffer = require('safe-buffer').Buffer;
16679var util = require('util');
16680
16681function copyBuffer(src, target, offset) {
16682 src.copy(target, offset);
16683}
16684
16685module.exports = function () {
16686 function BufferList() {
16687 _classCallCheck(this, BufferList);
16688
16689 this.head = null;
16690 this.tail = null;
16691 this.length = 0;
16692 }
16693
16694 BufferList.prototype.push = function push(v) {
16695 var entry = { data: v, next: null };
16696 if (this.length > 0) this.tail.next = entry;else this.head = entry;
16697 this.tail = entry;
16698 ++this.length;
16699 };
16700
16701 BufferList.prototype.unshift = function unshift(v) {
16702 var entry = { data: v, next: this.head };
16703 if (this.length === 0) this.tail = entry;
16704 this.head = entry;
16705 ++this.length;
16706 };
16707
16708 BufferList.prototype.shift = function shift() {
16709 if (this.length === 0) return;
16710 var ret = this.head.data;
16711 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
16712 --this.length;
16713 return ret;
16714 };
16715
16716 BufferList.prototype.clear = function clear() {
16717 this.head = this.tail = null;
16718 this.length = 0;
16719 };
16720
16721 BufferList.prototype.join = function join(s) {
16722 if (this.length === 0) return '';
16723 var p = this.head;
16724 var ret = '' + p.data;
16725 while (p = p.next) {
16726 ret += s + p.data;
16727 }return ret;
16728 };
16729
16730 BufferList.prototype.concat = function concat(n) {
16731 if (this.length === 0) return Buffer.alloc(0);
16732 if (this.length === 1) return this.head.data;
16733 var ret = Buffer.allocUnsafe(n >>> 0);
16734 var p = this.head;
16735 var i = 0;
16736 while (p) {
16737 copyBuffer(p.data, ret, i);
16738 i += p.data.length;
16739 p = p.next;
16740 }
16741 return ret;
16742 };
16743
16744 return BufferList;
16745}();
16746
16747if (util && util.inspect && util.inspect.custom) {
16748 module.exports.prototype[util.inspect.custom] = function () {
16749 var obj = util.inspect({ length: this.length });
16750 return this.constructor.name + ' ' + obj;
16751 };
16752}
16753},{"safe-buffer":83,"util":40}],77:[function(require,module,exports){
16754'use strict';
16755
16756/*<replacement>*/
16757
16758var pna = require('process-nextick-args');
16759/*</replacement>*/
16760
16761// undocumented cb() API, needed for core, not for public API
16762function destroy(err, cb) {
16763 var _this = this;
16764
16765 var readableDestroyed = this._readableState && this._readableState.destroyed;
16766 var writableDestroyed = this._writableState && this._writableState.destroyed;
16767
16768 if (readableDestroyed || writableDestroyed) {
16769 if (cb) {
16770 cb(err);
16771 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
16772 pna.nextTick(emitErrorNT, this, err);
16773 }
16774 return this;
16775 }
16776
16777 // we set destroyed to true before firing error callbacks in order
16778 // to make it re-entrance safe in case destroy() is called within callbacks
16779
16780 if (this._readableState) {
16781 this._readableState.destroyed = true;
16782 }
16783
16784 // if this is a duplex stream mark the writable part as destroyed as well
16785 if (this._writableState) {
16786 this._writableState.destroyed = true;
16787 }
16788
16789 this._destroy(err || null, function (err) {
16790 if (!cb && err) {
16791 pna.nextTick(emitErrorNT, _this, err);
16792 if (_this._writableState) {
16793 _this._writableState.errorEmitted = true;
16794 }
16795 } else if (cb) {
16796 cb(err);
16797 }
16798 });
16799
16800 return this;
16801}
16802
16803function undestroy() {
16804 if (this._readableState) {
16805 this._readableState.destroyed = false;
16806 this._readableState.reading = false;
16807 this._readableState.ended = false;
16808 this._readableState.endEmitted = false;
16809 }
16810
16811 if (this._writableState) {
16812 this._writableState.destroyed = false;
16813 this._writableState.ended = false;
16814 this._writableState.ending = false;
16815 this._writableState.finished = false;
16816 this._writableState.errorEmitted = false;
16817 }
16818}
16819
16820function emitErrorNT(self, err) {
16821 self.emit('error', err);
16822}
16823
16824module.exports = {
16825 destroy: destroy,
16826 undestroy: undestroy
16827};
16828},{"process-nextick-args":68}],78:[function(require,module,exports){
16829module.exports = require('events').EventEmitter;
16830
16831},{"events":50}],79:[function(require,module,exports){
16832module.exports = require('./readable').PassThrough
16833
16834},{"./readable":80}],80:[function(require,module,exports){
16835exports = module.exports = require('./lib/_stream_readable.js');
16836exports.Stream = exports;
16837exports.Readable = exports;
16838exports.Writable = require('./lib/_stream_writable.js');
16839exports.Duplex = require('./lib/_stream_duplex.js');
16840exports.Transform = require('./lib/_stream_transform.js');
16841exports.PassThrough = require('./lib/_stream_passthrough.js');
16842
16843},{"./lib/_stream_duplex.js":71,"./lib/_stream_passthrough.js":72,"./lib/_stream_readable.js":73,"./lib/_stream_transform.js":74,"./lib/_stream_writable.js":75}],81:[function(require,module,exports){
16844module.exports = require('./readable').Transform
16845
16846},{"./readable":80}],82:[function(require,module,exports){
16847module.exports = require('./lib/_stream_writable.js');
16848
16849},{"./lib/_stream_writable.js":75}],83:[function(require,module,exports){
16850/* eslint-disable node/no-deprecated-api */
16851var buffer = require('buffer')
16852var Buffer = buffer.Buffer
16853
16854// alternative to using Object.keys for old browsers
16855function copyProps (src, dst) {
16856 for (var key in src) {
16857 dst[key] = src[key]
16858 }
16859}
16860if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
16861 module.exports = buffer
16862} else {
16863 // Copy properties from require('buffer')
16864 copyProps(buffer, exports)
16865 exports.Buffer = SafeBuffer
16866}
16867
16868function SafeBuffer (arg, encodingOrOffset, length) {
16869 return Buffer(arg, encodingOrOffset, length)
16870}
16871
16872// Copy static methods from Buffer
16873copyProps(Buffer, SafeBuffer)
16874
16875SafeBuffer.from = function (arg, encodingOrOffset, length) {
16876 if (typeof arg === 'number') {
16877 throw new TypeError('Argument must not be a number')
16878 }
16879 return Buffer(arg, encodingOrOffset, length)
16880}
16881
16882SafeBuffer.alloc = function (size, fill, encoding) {
16883 if (typeof size !== 'number') {
16884 throw new TypeError('Argument must be a number')
16885 }
16886 var buf = Buffer(size)
16887 if (fill !== undefined) {
16888 if (typeof encoding === 'string') {
16889 buf.fill(fill, encoding)
16890 } else {
16891 buf.fill(fill)
16892 }
16893 } else {
16894 buf.fill(0)
16895 }
16896 return buf
16897}
16898
16899SafeBuffer.allocUnsafe = function (size) {
16900 if (typeof size !== 'number') {
16901 throw new TypeError('Argument must be a number')
16902 }
16903 return Buffer(size)
16904}
16905
16906SafeBuffer.allocUnsafeSlow = function (size) {
16907 if (typeof size !== 'number') {
16908 throw new TypeError('Argument must be a number')
16909 }
16910 return buffer.SlowBuffer(size)
16911}
16912
16913},{"buffer":43}],84:[function(require,module,exports){
16914// Copyright Joyent, Inc. and other Node contributors.
16915//
16916// Permission is hereby granted, free of charge, to any person obtaining a
16917// copy of this software and associated documentation files (the
16918// "Software"), to deal in the Software without restriction, including
16919// without limitation the rights to use, copy, modify, merge, publish,
16920// distribute, sublicense, and/or sell copies of the Software, and to permit
16921// persons to whom the Software is furnished to do so, subject to the
16922// following conditions:
16923//
16924// The above copyright notice and this permission notice shall be included
16925// in all copies or substantial portions of the Software.
16926//
16927// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16928// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16929// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
16930// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16931// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16932// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
16933// USE OR OTHER DEALINGS IN THE SOFTWARE.
16934
16935module.exports = Stream;
16936
16937var EE = require('events').EventEmitter;
16938var inherits = require('inherits');
16939
16940inherits(Stream, EE);
16941Stream.Readable = require('readable-stream/readable.js');
16942Stream.Writable = require('readable-stream/writable.js');
16943Stream.Duplex = require('readable-stream/duplex.js');
16944Stream.Transform = require('readable-stream/transform.js');
16945Stream.PassThrough = require('readable-stream/passthrough.js');
16946
16947// Backwards-compat with node 0.4.x
16948Stream.Stream = Stream;
16949
16950
16951
16952// old-style streams. Note that the pipe method (the only relevant
16953// part of this class) is overridden in the Readable class.
16954
16955function Stream() {
16956 EE.call(this);
16957}
16958
16959Stream.prototype.pipe = function(dest, options) {
16960 var source = this;
16961
16962 function ondata(chunk) {
16963 if (dest.writable) {
16964 if (false === dest.write(chunk) && source.pause) {
16965 source.pause();
16966 }
16967 }
16968 }
16969
16970 source.on('data', ondata);
16971
16972 function ondrain() {
16973 if (source.readable && source.resume) {
16974 source.resume();
16975 }
16976 }
16977
16978 dest.on('drain', ondrain);
16979
16980 // If the 'end' option is not supplied, dest.end() will be called when
16981 // source gets the 'end' or 'close' events. Only dest.end() once.
16982 if (!dest._isStdio && (!options || options.end !== false)) {
16983 source.on('end', onend);
16984 source.on('close', onclose);
16985 }
16986
16987 var didOnEnd = false;
16988 function onend() {
16989 if (didOnEnd) return;
16990 didOnEnd = true;
16991
16992 dest.end();
16993 }
16994
16995
16996 function onclose() {
16997 if (didOnEnd) return;
16998 didOnEnd = true;
16999
17000 if (typeof dest.destroy === 'function') dest.destroy();
17001 }
17002
17003 // don't leave dangling pipes when there are errors.
17004 function onerror(er) {
17005 cleanup();
17006 if (EE.listenerCount(this, 'error') === 0) {
17007 throw er; // Unhandled stream error in pipe.
17008 }
17009 }
17010
17011 source.on('error', onerror);
17012 dest.on('error', onerror);
17013
17014 // remove all the event listeners that were added.
17015 function cleanup() {
17016 source.removeListener('data', ondata);
17017 dest.removeListener('drain', ondrain);
17018
17019 source.removeListener('end', onend);
17020 source.removeListener('close', onclose);
17021
17022 source.removeListener('error', onerror);
17023 dest.removeListener('error', onerror);
17024
17025 source.removeListener('end', cleanup);
17026 source.removeListener('close', cleanup);
17027
17028 dest.removeListener('close', cleanup);
17029 }
17030
17031 source.on('end', cleanup);
17032 source.on('close', cleanup);
17033
17034 dest.on('close', cleanup);
17035
17036 dest.emit('pipe', source);
17037
17038 // Allow for unix-like usage: A.pipe(B).pipe(C)
17039 return dest;
17040};
17041
17042},{"events":50,"inherits":56,"readable-stream/duplex.js":70,"readable-stream/passthrough.js":79,"readable-stream/readable.js":80,"readable-stream/transform.js":81,"readable-stream/writable.js":82}],85:[function(require,module,exports){
17043// Copyright Joyent, Inc. and other Node contributors.
17044//
17045// Permission is hereby granted, free of charge, to any person obtaining a
17046// copy of this software and associated documentation files (the
17047// "Software"), to deal in the Software without restriction, including
17048// without limitation the rights to use, copy, modify, merge, publish,
17049// distribute, sublicense, and/or sell copies of the Software, and to permit
17050// persons to whom the Software is furnished to do so, subject to the
17051// following conditions:
17052//
17053// The above copyright notice and this permission notice shall be included
17054// in all copies or substantial portions of the Software.
17055//
17056// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17057// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17058// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17059// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17060// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17061// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17062// USE OR OTHER DEALINGS IN THE SOFTWARE.
17063
17064'use strict';
17065
17066/*<replacement>*/
17067
17068var Buffer = require('safe-buffer').Buffer;
17069/*</replacement>*/
17070
17071var isEncoding = Buffer.isEncoding || function (encoding) {
17072 encoding = '' + encoding;
17073 switch (encoding && encoding.toLowerCase()) {
17074 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':
17075 return true;
17076 default:
17077 return false;
17078 }
17079};
17080
17081function _normalizeEncoding(enc) {
17082 if (!enc) return 'utf8';
17083 var retried;
17084 while (true) {
17085 switch (enc) {
17086 case 'utf8':
17087 case 'utf-8':
17088 return 'utf8';
17089 case 'ucs2':
17090 case 'ucs-2':
17091 case 'utf16le':
17092 case 'utf-16le':
17093 return 'utf16le';
17094 case 'latin1':
17095 case 'binary':
17096 return 'latin1';
17097 case 'base64':
17098 case 'ascii':
17099 case 'hex':
17100 return enc;
17101 default:
17102 if (retried) return; // undefined
17103 enc = ('' + enc).toLowerCase();
17104 retried = true;
17105 }
17106 }
17107};
17108
17109// Do not cache `Buffer.isEncoding` when checking encoding names as some
17110// modules monkey-patch it to support additional encodings
17111function normalizeEncoding(enc) {
17112 var nenc = _normalizeEncoding(enc);
17113 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
17114 return nenc || enc;
17115}
17116
17117// StringDecoder provides an interface for efficiently splitting a series of
17118// buffers into a series of JS strings without breaking apart multi-byte
17119// characters.
17120exports.StringDecoder = StringDecoder;
17121function StringDecoder(encoding) {
17122 this.encoding = normalizeEncoding(encoding);
17123 var nb;
17124 switch (this.encoding) {
17125 case 'utf16le':
17126 this.text = utf16Text;
17127 this.end = utf16End;
17128 nb = 4;
17129 break;
17130 case 'utf8':
17131 this.fillLast = utf8FillLast;
17132 nb = 4;
17133 break;
17134 case 'base64':
17135 this.text = base64Text;
17136 this.end = base64End;
17137 nb = 3;
17138 break;
17139 default:
17140 this.write = simpleWrite;
17141 this.end = simpleEnd;
17142 return;
17143 }
17144 this.lastNeed = 0;
17145 this.lastTotal = 0;
17146 this.lastChar = Buffer.allocUnsafe(nb);
17147}
17148
17149StringDecoder.prototype.write = function (buf) {
17150 if (buf.length === 0) return '';
17151 var r;
17152 var i;
17153 if (this.lastNeed) {
17154 r = this.fillLast(buf);
17155 if (r === undefined) return '';
17156 i = this.lastNeed;
17157 this.lastNeed = 0;
17158 } else {
17159 i = 0;
17160 }
17161 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
17162 return r || '';
17163};
17164
17165StringDecoder.prototype.end = utf8End;
17166
17167// Returns only complete characters in a Buffer
17168StringDecoder.prototype.text = utf8Text;
17169
17170// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
17171StringDecoder.prototype.fillLast = function (buf) {
17172 if (this.lastNeed <= buf.length) {
17173 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
17174 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17175 }
17176 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
17177 this.lastNeed -= buf.length;
17178};
17179
17180// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
17181// continuation byte. If an invalid byte is detected, -2 is returned.
17182function utf8CheckByte(byte) {
17183 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;
17184 return byte >> 6 === 0x02 ? -1 : -2;
17185}
17186
17187// Checks at most 3 bytes at the end of a Buffer in order to detect an
17188// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
17189// needed to complete the UTF-8 character (if applicable) are returned.
17190function utf8CheckIncomplete(self, buf, i) {
17191 var j = buf.length - 1;
17192 if (j < i) return 0;
17193 var nb = utf8CheckByte(buf[j]);
17194 if (nb >= 0) {
17195 if (nb > 0) self.lastNeed = nb - 1;
17196 return nb;
17197 }
17198 if (--j < i || nb === -2) return 0;
17199 nb = utf8CheckByte(buf[j]);
17200 if (nb >= 0) {
17201 if (nb > 0) self.lastNeed = nb - 2;
17202 return nb;
17203 }
17204 if (--j < i || nb === -2) return 0;
17205 nb = utf8CheckByte(buf[j]);
17206 if (nb >= 0) {
17207 if (nb > 0) {
17208 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
17209 }
17210 return nb;
17211 }
17212 return 0;
17213}
17214
17215// Validates as many continuation bytes for a multi-byte UTF-8 character as
17216// needed or are available. If we see a non-continuation byte where we expect
17217// one, we "replace" the validated continuation bytes we've seen so far with
17218// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
17219// behavior. The continuation byte check is included three times in the case
17220// where all of the continuation bytes for a character exist in the same buffer.
17221// It is also done this way as a slight performance increase instead of using a
17222// loop.
17223function utf8CheckExtraBytes(self, buf, p) {
17224 if ((buf[0] & 0xC0) !== 0x80) {
17225 self.lastNeed = 0;
17226 return '\ufffd';
17227 }
17228 if (self.lastNeed > 1 && buf.length > 1) {
17229 if ((buf[1] & 0xC0) !== 0x80) {
17230 self.lastNeed = 1;
17231 return '\ufffd';
17232 }
17233 if (self.lastNeed > 2 && buf.length > 2) {
17234 if ((buf[2] & 0xC0) !== 0x80) {
17235 self.lastNeed = 2;
17236 return '\ufffd';
17237 }
17238 }
17239 }
17240}
17241
17242// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
17243function utf8FillLast(buf) {
17244 var p = this.lastTotal - this.lastNeed;
17245 var r = utf8CheckExtraBytes(this, buf, p);
17246 if (r !== undefined) return r;
17247 if (this.lastNeed <= buf.length) {
17248 buf.copy(this.lastChar, p, 0, this.lastNeed);
17249 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
17250 }
17251 buf.copy(this.lastChar, p, 0, buf.length);
17252 this.lastNeed -= buf.length;
17253}
17254
17255// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
17256// partial character, the character's bytes are buffered until the required
17257// number of bytes are available.
17258function utf8Text(buf, i) {
17259 var total = utf8CheckIncomplete(this, buf, i);
17260 if (!this.lastNeed) return buf.toString('utf8', i);
17261 this.lastTotal = total;
17262 var end = buf.length - (total - this.lastNeed);
17263 buf.copy(this.lastChar, 0, end);
17264 return buf.toString('utf8', i, end);
17265}
17266
17267// For UTF-8, a replacement character is added when ending on a partial
17268// character.
17269function utf8End(buf) {
17270 var r = buf && buf.length ? this.write(buf) : '';
17271 if (this.lastNeed) return r + '\ufffd';
17272 return r;
17273}
17274
17275// UTF-16LE typically needs two bytes per character, but even if we have an even
17276// number of bytes available, we need to check if we end on a leading/high
17277// surrogate. In that case, we need to wait for the next two bytes in order to
17278// decode the last character properly.
17279function utf16Text(buf, i) {
17280 if ((buf.length - i) % 2 === 0) {
17281 var r = buf.toString('utf16le', i);
17282 if (r) {
17283 var c = r.charCodeAt(r.length - 1);
17284 if (c >= 0xD800 && c <= 0xDBFF) {
17285 this.lastNeed = 2;
17286 this.lastTotal = 4;
17287 this.lastChar[0] = buf[buf.length - 2];
17288 this.lastChar[1] = buf[buf.length - 1];
17289 return r.slice(0, -1);
17290 }
17291 }
17292 return r;
17293 }
17294 this.lastNeed = 1;
17295 this.lastTotal = 2;
17296 this.lastChar[0] = buf[buf.length - 1];
17297 return buf.toString('utf16le', i, buf.length - 1);
17298}
17299
17300// For UTF-16LE we do not explicitly append special replacement characters if we
17301// end on a partial character, we simply let v8 handle that.
17302function utf16End(buf) {
17303 var r = buf && buf.length ? this.write(buf) : '';
17304 if (this.lastNeed) {
17305 var end = this.lastTotal - this.lastNeed;
17306 return r + this.lastChar.toString('utf16le', 0, end);
17307 }
17308 return r;
17309}
17310
17311function base64Text(buf, i) {
17312 var n = (buf.length - i) % 3;
17313 if (n === 0) return buf.toString('base64', i);
17314 this.lastNeed = 3 - n;
17315 this.lastTotal = 3;
17316 if (n === 1) {
17317 this.lastChar[0] = buf[buf.length - 1];
17318 } else {
17319 this.lastChar[0] = buf[buf.length - 2];
17320 this.lastChar[1] = buf[buf.length - 1];
17321 }
17322 return buf.toString('base64', i, buf.length - n);
17323}
17324
17325function base64End(buf) {
17326 var r = buf && buf.length ? this.write(buf) : '';
17327 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
17328 return r;
17329}
17330
17331// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
17332function simpleWrite(buf) {
17333 return buf.toString(this.encoding);
17334}
17335
17336function simpleEnd(buf) {
17337 return buf && buf.length ? this.write(buf) : '';
17338}
17339},{"safe-buffer":83}],86:[function(require,module,exports){
17340(function (setImmediate,clearImmediate){
17341var nextTick = require('process/browser.js').nextTick;
17342var apply = Function.prototype.apply;
17343var slice = Array.prototype.slice;
17344var immediateIds = {};
17345var nextImmediateId = 0;
17346
17347// DOM APIs, for completeness
17348
17349exports.setTimeout = function() {
17350 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
17351};
17352exports.setInterval = function() {
17353 return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
17354};
17355exports.clearTimeout =
17356exports.clearInterval = function(timeout) { timeout.close(); };
17357
17358function Timeout(id, clearFn) {
17359 this._id = id;
17360 this._clearFn = clearFn;
17361}
17362Timeout.prototype.unref = Timeout.prototype.ref = function() {};
17363Timeout.prototype.close = function() {
17364 this._clearFn.call(window, this._id);
17365};
17366
17367// Does not start the time, just sets up the members needed.
17368exports.enroll = function(item, msecs) {
17369 clearTimeout(item._idleTimeoutId);
17370 item._idleTimeout = msecs;
17371};
17372
17373exports.unenroll = function(item) {
17374 clearTimeout(item._idleTimeoutId);
17375 item._idleTimeout = -1;
17376};
17377
17378exports._unrefActive = exports.active = function(item) {
17379 clearTimeout(item._idleTimeoutId);
17380
17381 var msecs = item._idleTimeout;
17382 if (msecs >= 0) {
17383 item._idleTimeoutId = setTimeout(function onTimeout() {
17384 if (item._onTimeout)
17385 item._onTimeout();
17386 }, msecs);
17387 }
17388};
17389
17390// That's not how node.js implements it but the exposed api is the same.
17391exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) {
17392 var id = nextImmediateId++;
17393 var args = arguments.length < 2 ? false : slice.call(arguments, 1);
17394
17395 immediateIds[id] = true;
17396
17397 nextTick(function onNextTick() {
17398 if (immediateIds[id]) {
17399 // fn.call() is faster so we optimize for the common use-case
17400 // @see http://jsperf.com/call-apply-segu
17401 if (args) {
17402 fn.apply(null, args);
17403 } else {
17404 fn.call(null);
17405 }
17406 // Prevent ids from leaking
17407 exports.clearImmediate(id);
17408 }
17409 });
17410
17411 return id;
17412};
17413
17414exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) {
17415 delete immediateIds[id];
17416};
17417}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
17418},{"process/browser.js":69,"timers":86}],87:[function(require,module,exports){
17419(function (global){
17420
17421/**
17422 * Module exports.
17423 */
17424
17425module.exports = deprecate;
17426
17427/**
17428 * Mark that a method should not be used.
17429 * Returns a modified function which warns once by default.
17430 *
17431 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
17432 *
17433 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
17434 * will throw an Error when invoked.
17435 *
17436 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
17437 * will invoke `console.trace()` instead of `console.error()`.
17438 *
17439 * @param {Function} fn - the function to deprecate
17440 * @param {String} msg - the string to print to the console when `fn` is invoked
17441 * @returns {Function} a new "deprecated" version of `fn`
17442 * @api public
17443 */
17444
17445function deprecate (fn, msg) {
17446 if (config('noDeprecation')) {
17447 return fn;
17448 }
17449
17450 var warned = false;
17451 function deprecated() {
17452 if (!warned) {
17453 if (config('throwDeprecation')) {
17454 throw new Error(msg);
17455 } else if (config('traceDeprecation')) {
17456 console.trace(msg);
17457 } else {
17458 console.warn(msg);
17459 }
17460 warned = true;
17461 }
17462 return fn.apply(this, arguments);
17463 }
17464
17465 return deprecated;
17466}
17467
17468/**
17469 * Checks `localStorage` for boolean values for the given `name`.
17470 *
17471 * @param {String} name
17472 * @returns {Boolean}
17473 * @api private
17474 */
17475
17476function config (name) {
17477 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
17478 try {
17479 if (!global.localStorage) return false;
17480 } catch (_) {
17481 return false;
17482 }
17483 var val = global.localStorage[name];
17484 if (null == val) return false;
17485 return String(val).toLowerCase() === 'true';
17486}
17487
17488}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17489},{}],88:[function(require,module,exports){
17490module.exports = function isBuffer(arg) {
17491 return arg && typeof arg === 'object'
17492 && typeof arg.copy === 'function'
17493 && typeof arg.fill === 'function'
17494 && typeof arg.readUInt8 === 'function';
17495}
17496},{}],89:[function(require,module,exports){
17497(function (process,global){
17498// Copyright Joyent, Inc. and other Node contributors.
17499//
17500// Permission is hereby granted, free of charge, to any person obtaining a
17501// copy of this software and associated documentation files (the
17502// "Software"), to deal in the Software without restriction, including
17503// without limitation the rights to use, copy, modify, merge, publish,
17504// distribute, sublicense, and/or sell copies of the Software, and to permit
17505// persons to whom the Software is furnished to do so, subject to the
17506// following conditions:
17507//
17508// The above copyright notice and this permission notice shall be included
17509// in all copies or substantial portions of the Software.
17510//
17511// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17512// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17513// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17514// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17515// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17516// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
17517// USE OR OTHER DEALINGS IN THE SOFTWARE.
17518
17519var formatRegExp = /%[sdj%]/g;
17520exports.format = function(f) {
17521 if (!isString(f)) {
17522 var objects = [];
17523 for (var i = 0; i < arguments.length; i++) {
17524 objects.push(inspect(arguments[i]));
17525 }
17526 return objects.join(' ');
17527 }
17528
17529 var i = 1;
17530 var args = arguments;
17531 var len = args.length;
17532 var str = String(f).replace(formatRegExp, function(x) {
17533 if (x === '%%') return '%';
17534 if (i >= len) return x;
17535 switch (x) {
17536 case '%s': return String(args[i++]);
17537 case '%d': return Number(args[i++]);
17538 case '%j':
17539 try {
17540 return JSON.stringify(args[i++]);
17541 } catch (_) {
17542 return '[Circular]';
17543 }
17544 default:
17545 return x;
17546 }
17547 });
17548 for (var x = args[i]; i < len; x = args[++i]) {
17549 if (isNull(x) || !isObject(x)) {
17550 str += ' ' + x;
17551 } else {
17552 str += ' ' + inspect(x);
17553 }
17554 }
17555 return str;
17556};
17557
17558
17559// Mark that a method should not be used.
17560// Returns a modified function which warns once by default.
17561// If --no-deprecation is set, then it is a no-op.
17562exports.deprecate = function(fn, msg) {
17563 // Allow for deprecating things in the process of starting up.
17564 if (isUndefined(global.process)) {
17565 return function() {
17566 return exports.deprecate(fn, msg).apply(this, arguments);
17567 };
17568 }
17569
17570 if (process.noDeprecation === true) {
17571 return fn;
17572 }
17573
17574 var warned = false;
17575 function deprecated() {
17576 if (!warned) {
17577 if (process.throwDeprecation) {
17578 throw new Error(msg);
17579 } else if (process.traceDeprecation) {
17580 console.trace(msg);
17581 } else {
17582 console.error(msg);
17583 }
17584 warned = true;
17585 }
17586 return fn.apply(this, arguments);
17587 }
17588
17589 return deprecated;
17590};
17591
17592
17593var debugs = {};
17594var debugEnviron;
17595exports.debuglog = function(set) {
17596 if (isUndefined(debugEnviron))
17597 debugEnviron = process.env.NODE_DEBUG || '';
17598 set = set.toUpperCase();
17599 if (!debugs[set]) {
17600 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
17601 var pid = process.pid;
17602 debugs[set] = function() {
17603 var msg = exports.format.apply(exports, arguments);
17604 console.error('%s %d: %s', set, pid, msg);
17605 };
17606 } else {
17607 debugs[set] = function() {};
17608 }
17609 }
17610 return debugs[set];
17611};
17612
17613
17614/**
17615 * Echos the value of a value. Trys to print the value out
17616 * in the best way possible given the different types.
17617 *
17618 * @param {Object} obj The object to print out.
17619 * @param {Object} opts Optional options object that alters the output.
17620 */
17621/* legacy: obj, showHidden, depth, colors*/
17622function inspect(obj, opts) {
17623 // default options
17624 var ctx = {
17625 seen: [],
17626 stylize: stylizeNoColor
17627 };
17628 // legacy...
17629 if (arguments.length >= 3) ctx.depth = arguments[2];
17630 if (arguments.length >= 4) ctx.colors = arguments[3];
17631 if (isBoolean(opts)) {
17632 // legacy...
17633 ctx.showHidden = opts;
17634 } else if (opts) {
17635 // got an "options" object
17636 exports._extend(ctx, opts);
17637 }
17638 // set default options
17639 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
17640 if (isUndefined(ctx.depth)) ctx.depth = 2;
17641 if (isUndefined(ctx.colors)) ctx.colors = false;
17642 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
17643 if (ctx.colors) ctx.stylize = stylizeWithColor;
17644 return formatValue(ctx, obj, ctx.depth);
17645}
17646exports.inspect = inspect;
17647
17648
17649// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
17650inspect.colors = {
17651 'bold' : [1, 22],
17652 'italic' : [3, 23],
17653 'underline' : [4, 24],
17654 'inverse' : [7, 27],
17655 'white' : [37, 39],
17656 'grey' : [90, 39],
17657 'black' : [30, 39],
17658 'blue' : [34, 39],
17659 'cyan' : [36, 39],
17660 'green' : [32, 39],
17661 'magenta' : [35, 39],
17662 'red' : [31, 39],
17663 'yellow' : [33, 39]
17664};
17665
17666// Don't use 'blue' not visible on cmd.exe
17667inspect.styles = {
17668 'special': 'cyan',
17669 'number': 'yellow',
17670 'boolean': 'yellow',
17671 'undefined': 'grey',
17672 'null': 'bold',
17673 'string': 'green',
17674 'date': 'magenta',
17675 // "name": intentionally not styling
17676 'regexp': 'red'
17677};
17678
17679
17680function stylizeWithColor(str, styleType) {
17681 var style = inspect.styles[styleType];
17682
17683 if (style) {
17684 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
17685 '\u001b[' + inspect.colors[style][1] + 'm';
17686 } else {
17687 return str;
17688 }
17689}
17690
17691
17692function stylizeNoColor(str, styleType) {
17693 return str;
17694}
17695
17696
17697function arrayToHash(array) {
17698 var hash = {};
17699
17700 array.forEach(function(val, idx) {
17701 hash[val] = true;
17702 });
17703
17704 return hash;
17705}
17706
17707
17708function formatValue(ctx, value, recurseTimes) {
17709 // Provide a hook for user-specified inspect functions.
17710 // Check that value is an object with an inspect function on it
17711 if (ctx.customInspect &&
17712 value &&
17713 isFunction(value.inspect) &&
17714 // Filter out the util module, it's inspect function is special
17715 value.inspect !== exports.inspect &&
17716 // Also filter out any prototype objects using the circular check.
17717 !(value.constructor && value.constructor.prototype === value)) {
17718 var ret = value.inspect(recurseTimes, ctx);
17719 if (!isString(ret)) {
17720 ret = formatValue(ctx, ret, recurseTimes);
17721 }
17722 return ret;
17723 }
17724
17725 // Primitive types cannot have properties
17726 var primitive = formatPrimitive(ctx, value);
17727 if (primitive) {
17728 return primitive;
17729 }
17730
17731 // Look up the keys of the object.
17732 var keys = Object.keys(value);
17733 var visibleKeys = arrayToHash(keys);
17734
17735 if (ctx.showHidden) {
17736 keys = Object.getOwnPropertyNames(value);
17737 }
17738
17739 // IE doesn't make error fields non-enumerable
17740 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
17741 if (isError(value)
17742 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
17743 return formatError(value);
17744 }
17745
17746 // Some type of object without properties can be shortcutted.
17747 if (keys.length === 0) {
17748 if (isFunction(value)) {
17749 var name = value.name ? ': ' + value.name : '';
17750 return ctx.stylize('[Function' + name + ']', 'special');
17751 }
17752 if (isRegExp(value)) {
17753 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
17754 }
17755 if (isDate(value)) {
17756 return ctx.stylize(Date.prototype.toString.call(value), 'date');
17757 }
17758 if (isError(value)) {
17759 return formatError(value);
17760 }
17761 }
17762
17763 var base = '', array = false, braces = ['{', '}'];
17764
17765 // Make Array say that they are Array
17766 if (isArray(value)) {
17767 array = true;
17768 braces = ['[', ']'];
17769 }
17770
17771 // Make functions say that they are functions
17772 if (isFunction(value)) {
17773 var n = value.name ? ': ' + value.name : '';
17774 base = ' [Function' + n + ']';
17775 }
17776
17777 // Make RegExps say that they are RegExps
17778 if (isRegExp(value)) {
17779 base = ' ' + RegExp.prototype.toString.call(value);
17780 }
17781
17782 // Make dates with properties first say the date
17783 if (isDate(value)) {
17784 base = ' ' + Date.prototype.toUTCString.call(value);
17785 }
17786
17787 // Make error with message first say the error
17788 if (isError(value)) {
17789 base = ' ' + formatError(value);
17790 }
17791
17792 if (keys.length === 0 && (!array || value.length == 0)) {
17793 return braces[0] + base + braces[1];
17794 }
17795
17796 if (recurseTimes < 0) {
17797 if (isRegExp(value)) {
17798 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
17799 } else {
17800 return ctx.stylize('[Object]', 'special');
17801 }
17802 }
17803
17804 ctx.seen.push(value);
17805
17806 var output;
17807 if (array) {
17808 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
17809 } else {
17810 output = keys.map(function(key) {
17811 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
17812 });
17813 }
17814
17815 ctx.seen.pop();
17816
17817 return reduceToSingleString(output, base, braces);
17818}
17819
17820
17821function formatPrimitive(ctx, value) {
17822 if (isUndefined(value))
17823 return ctx.stylize('undefined', 'undefined');
17824 if (isString(value)) {
17825 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
17826 .replace(/'/g, "\\'")
17827 .replace(/\\"/g, '"') + '\'';
17828 return ctx.stylize(simple, 'string');
17829 }
17830 if (isNumber(value))
17831 return ctx.stylize('' + value, 'number');
17832 if (isBoolean(value))
17833 return ctx.stylize('' + value, 'boolean');
17834 // For some reason typeof null is "object", so special case here.
17835 if (isNull(value))
17836 return ctx.stylize('null', 'null');
17837}
17838
17839
17840function formatError(value) {
17841 return '[' + Error.prototype.toString.call(value) + ']';
17842}
17843
17844
17845function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
17846 var output = [];
17847 for (var i = 0, l = value.length; i < l; ++i) {
17848 if (hasOwnProperty(value, String(i))) {
17849 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
17850 String(i), true));
17851 } else {
17852 output.push('');
17853 }
17854 }
17855 keys.forEach(function(key) {
17856 if (!key.match(/^\d+$/)) {
17857 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
17858 key, true));
17859 }
17860 });
17861 return output;
17862}
17863
17864
17865function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
17866 var name, str, desc;
17867 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
17868 if (desc.get) {
17869 if (desc.set) {
17870 str = ctx.stylize('[Getter/Setter]', 'special');
17871 } else {
17872 str = ctx.stylize('[Getter]', 'special');
17873 }
17874 } else {
17875 if (desc.set) {
17876 str = ctx.stylize('[Setter]', 'special');
17877 }
17878 }
17879 if (!hasOwnProperty(visibleKeys, key)) {
17880 name = '[' + key + ']';
17881 }
17882 if (!str) {
17883 if (ctx.seen.indexOf(desc.value) < 0) {
17884 if (isNull(recurseTimes)) {
17885 str = formatValue(ctx, desc.value, null);
17886 } else {
17887 str = formatValue(ctx, desc.value, recurseTimes - 1);
17888 }
17889 if (str.indexOf('\n') > -1) {
17890 if (array) {
17891 str = str.split('\n').map(function(line) {
17892 return ' ' + line;
17893 }).join('\n').substr(2);
17894 } else {
17895 str = '\n' + str.split('\n').map(function(line) {
17896 return ' ' + line;
17897 }).join('\n');
17898 }
17899 }
17900 } else {
17901 str = ctx.stylize('[Circular]', 'special');
17902 }
17903 }
17904 if (isUndefined(name)) {
17905 if (array && key.match(/^\d+$/)) {
17906 return str;
17907 }
17908 name = JSON.stringify('' + key);
17909 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
17910 name = name.substr(1, name.length - 2);
17911 name = ctx.stylize(name, 'name');
17912 } else {
17913 name = name.replace(/'/g, "\\'")
17914 .replace(/\\"/g, '"')
17915 .replace(/(^"|"$)/g, "'");
17916 name = ctx.stylize(name, 'string');
17917 }
17918 }
17919
17920 return name + ': ' + str;
17921}
17922
17923
17924function reduceToSingleString(output, base, braces) {
17925 var numLinesEst = 0;
17926 var length = output.reduce(function(prev, cur) {
17927 numLinesEst++;
17928 if (cur.indexOf('\n') >= 0) numLinesEst++;
17929 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
17930 }, 0);
17931
17932 if (length > 60) {
17933 return braces[0] +
17934 (base === '' ? '' : base + '\n ') +
17935 ' ' +
17936 output.join(',\n ') +
17937 ' ' +
17938 braces[1];
17939 }
17940
17941 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
17942}
17943
17944
17945// NOTE: These type checking functions intentionally don't use `instanceof`
17946// because it is fragile and can be easily faked with `Object.create()`.
17947function isArray(ar) {
17948 return Array.isArray(ar);
17949}
17950exports.isArray = isArray;
17951
17952function isBoolean(arg) {
17953 return typeof arg === 'boolean';
17954}
17955exports.isBoolean = isBoolean;
17956
17957function isNull(arg) {
17958 return arg === null;
17959}
17960exports.isNull = isNull;
17961
17962function isNullOrUndefined(arg) {
17963 return arg == null;
17964}
17965exports.isNullOrUndefined = isNullOrUndefined;
17966
17967function isNumber(arg) {
17968 return typeof arg === 'number';
17969}
17970exports.isNumber = isNumber;
17971
17972function isString(arg) {
17973 return typeof arg === 'string';
17974}
17975exports.isString = isString;
17976
17977function isSymbol(arg) {
17978 return typeof arg === 'symbol';
17979}
17980exports.isSymbol = isSymbol;
17981
17982function isUndefined(arg) {
17983 return arg === void 0;
17984}
17985exports.isUndefined = isUndefined;
17986
17987function isRegExp(re) {
17988 return isObject(re) && objectToString(re) === '[object RegExp]';
17989}
17990exports.isRegExp = isRegExp;
17991
17992function isObject(arg) {
17993 return typeof arg === 'object' && arg !== null;
17994}
17995exports.isObject = isObject;
17996
17997function isDate(d) {
17998 return isObject(d) && objectToString(d) === '[object Date]';
17999}
18000exports.isDate = isDate;
18001
18002function isError(e) {
18003 return isObject(e) &&
18004 (objectToString(e) === '[object Error]' || e instanceof Error);
18005}
18006exports.isError = isError;
18007
18008function isFunction(arg) {
18009 return typeof arg === 'function';
18010}
18011exports.isFunction = isFunction;
18012
18013function isPrimitive(arg) {
18014 return arg === null ||
18015 typeof arg === 'boolean' ||
18016 typeof arg === 'number' ||
18017 typeof arg === 'string' ||
18018 typeof arg === 'symbol' || // ES6 symbol
18019 typeof arg === 'undefined';
18020}
18021exports.isPrimitive = isPrimitive;
18022
18023exports.isBuffer = require('./support/isBuffer');
18024
18025function objectToString(o) {
18026 return Object.prototype.toString.call(o);
18027}
18028
18029
18030function pad(n) {
18031 return n < 10 ? '0' + n.toString(10) : n.toString(10);
18032}
18033
18034
18035var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
18036 'Oct', 'Nov', 'Dec'];
18037
18038// 26 Feb 16:19:34
18039function timestamp() {
18040 var d = new Date();
18041 var time = [pad(d.getHours()),
18042 pad(d.getMinutes()),
18043 pad(d.getSeconds())].join(':');
18044 return [d.getDate(), months[d.getMonth()], time].join(' ');
18045}
18046
18047
18048// log is just a thin wrapper to console.log that prepends a timestamp
18049exports.log = function() {
18050 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
18051};
18052
18053
18054/**
18055 * Inherit the prototype methods from one constructor into another.
18056 *
18057 * The Function.prototype.inherits from lang.js rewritten as a standalone
18058 * function (not on Function.prototype). NOTE: If this file is to be loaded
18059 * during bootstrapping this function needs to be rewritten using some native
18060 * functions as prototype setup using normal JavaScript does not work as
18061 * expected during bootstrapping (see mirror.js in r114903).
18062 *
18063 * @param {function} ctor Constructor function which needs to inherit the
18064 * prototype.
18065 * @param {function} superCtor Constructor function to inherit prototype from.
18066 */
18067exports.inherits = require('inherits');
18068
18069exports._extend = function(origin, add) {
18070 // Don't do anything if add isn't an object
18071 if (!add || !isObject(add)) return origin;
18072
18073 var keys = Object.keys(add);
18074 var i = keys.length;
18075 while (i--) {
18076 origin[keys[i]] = add[keys[i]];
18077 }
18078 return origin;
18079};
18080
18081function hasOwnProperty(obj, prop) {
18082 return Object.prototype.hasOwnProperty.call(obj, prop);
18083}
18084
18085}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
18086},{"./support/isBuffer":88,"_process":69,"inherits":56}],90:[function(require,module,exports){
18087module.exports={
18088 "name": "mocha",
18089 "version": "6.2.2",
18090 "homepage": "https://mochajs.org/",
18091 "notifyLogo": "https://ibin.co/4QuRuGjXvl36.png"
18092}
18093},{}]},{},[1]);