?!?.?!?   F
last analyzed

Complexity

Conditions 14
Paths 126

Size

Total Lines 49
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 14
eloc 29
nc 126
nop 2
dl 0
loc 49
rs 3.6
c 0
b 0
f 0

How to fix   Complexity   

Complexity

Complex classes like ?!?.?!? often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
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
12
process.stdout = require('browser-stdout')({level: false});
13
14
var Mocha = require('./lib/mocha');
15
16
/**
17
 * Create a Mocha instance.
18
 *
19
 * @return {undefined}
20
 */
21
22
var mocha = new Mocha({ reporter: 'html' });
23
24
/**
25
 * Save timer references to avoid Sinon interfering (see GH-237).
26
 */
27
28
var Date = global.Date;
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Date. This makes code hard to read, consider using a different name.
Loading history...
29
var setTimeout = global.setTimeout;
30
var setInterval = global.setInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setInterval seems to be never used. Consider removing it.
Loading history...
31
var clearTimeout = global.clearTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearTimeout seems to be never used. Consider removing it.
Loading history...
32
var clearInterval = global.clearInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearInterval seems to be never used. Consider removing it.
Loading history...
33
34
var uncaughtExceptionHandlers = [];
35
36
var originalOnerrorHandler = global.onerror;
37
38
/**
39
 * Remove uncaughtException listener.
40
 * Revert to original onerror handler if previously defined.
41
 */
42
43
process.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
61
process.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.
74
mocha.suite.removeAllListeners('pre-require');
75
76
var immediateQueue = [];
77
var immediateTimeout;
78
79
function 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
95
Mocha.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
 */
107
mocha.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
119
mocha.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
129
mocha.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
145
mocha.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 (document && document.getElementById('mocha') && options.noHighlighting !== true) {
164
      Mocha.utils.highlightTags('code');
165
    }
166
    if (fn) {
167
      fn(err);
168
    }
169
  });
170
};
171
172
/**
173
 * Expose the process shim.
174
 * https://github.com/mochajs/mocha/pull/916
175
 */
176
177
Mocha.process = process;
178
179
/**
180
 * Expose mocha.
181
 */
182
183
global.Mocha = Mocha;
184
global.mocha = mocha;
185
186
// this allows test/acceptance/required-tokens.js to pass; thus,
187
// you can now do `const describe = require('mocha').describe` in a
188
// browser context (assuming browserification).  should fix #880
189
module.exports = global;
190
191
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
192
},{"./lib/mocha":13,"_process":55,"browser-stdout":39}],2:[function(require,module,exports){
193
'use strict';
194
195
// just stub out growl
196
197
module.exports = require('../utils').noop;
198
199
},{"../utils":36}],3:[function(require,module,exports){
200
'use strict';
201
202
/**
203
 * Expose `Progress`.
204
 */
205
206
module.exports = Progress;
207
208
/**
209
 * Initialize a new `Progress` indicator.
210
 */
211
function Progress () {
212
  this.percent = 0;
213
  this.size(0);
214
  this.fontSize(11);
215
  this.font('helvetica, arial, sans-serif');
216
}
217
218
/**
219
 * Set progress size to `size`.
220
 *
221
 * @api public
222
 * @param {number} size
223
 * @return {Progress} Progress instance.
224
 */
225
Progress.prototype.size = function (size) {
226
  this._size = size;
227
  return this;
228
};
229
230
/**
231
 * Set text to `text`.
232
 *
233
 * @api public
234
 * @param {string} text
235
 * @return {Progress} Progress instance.
236
 */
237
Progress.prototype.text = function (text) {
238
  this._text = text;
239
  return this;
240
};
241
242
/**
243
 * Set font size to `size`.
244
 *
245
 * @api public
246
 * @param {number} size
247
 * @return {Progress} Progress instance.
248
 */
249
Progress.prototype.fontSize = function (size) {
250
  this._fontSize = size;
251
  return this;
252
};
253
254
/**
255
 * Set font to `family`.
256
 *
257
 * @param {string} family
258
 * @return {Progress} Progress instance.
259
 */
260
Progress.prototype.font = function (family) {
261
  this._font = family;
262
  return this;
263
};
264
265
/**
266
 * Update percentage to `n`.
267
 *
268
 * @param {number} n
269
 * @return {Progress} Progress instance.
270
 */
271
Progress.prototype.update = function (n) {
272
  this.percent = n;
273
  return this;
274
};
275
276
/**
277
 * Draw on `ctx`.
278
 *
279
 * @param {CanvasRenderingContext2d} ctx
280
 * @return {Progress} Progress instance.
281
 */
282 View Code Duplication
Progress.prototype.draw = function (ctx) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
283
  try {
284
    var percent = Math.min(this.percent, 100);
285
    var size = this._size;
286
    var half = size / 2;
287
    var x = half;
288
    var y = half;
289
    var rad = half - 1;
290
    var fontSize = this._fontSize;
291
292
    ctx.font = fontSize + 'px ' + this._font;
293
294
    var angle = Math.PI * 2 * (percent / 100);
295
    ctx.clearRect(0, 0, size, size);
296
297
    // outer circle
298
    ctx.strokeStyle = '#9f9f9f';
299
    ctx.beginPath();
300
    ctx.arc(x, y, rad, 0, angle, false);
301
    ctx.stroke();
302
303
    // inner circle
304
    ctx.strokeStyle = '#eee';
305
    ctx.beginPath();
306
    ctx.arc(x, y, rad - 1, 0, angle, true);
307
    ctx.stroke();
308
309
    // text
310
    var text = this._text || (percent | 0) + '%';
311
    var w = ctx.measureText(text).width;
312
313
    ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
314
  } catch (err) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
315
    // don't fail if we can't render progress
316
  }
317
  return this;
318
};
319
320
},{}],4:[function(require,module,exports){
321
(function (global){
322
'use strict';
323
324
exports.isatty = function isatty () {
325
  return true;
326
};
327
328
exports.getWindowSize = function getWindowSize () {
329
  if ('innerHeight' in global) {
330
    return [global.innerHeight, global.innerWidth];
331
  }
332
  // In a Web Worker, the DOM Window is not available.
333
  return [640, 480];
334
};
335
336
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
337
},{}],5:[function(require,module,exports){
338
'use strict';
339
340
/**
341
 * Expose `Context`.
342
 */
343
344
module.exports = Context;
345
346
/**
347
 * Initialize a new `Context`.
348
 *
349
 * @api private
350
 */
351
function Context () {}
352
353
/**
354
 * Set or get the context `Runnable` to `runnable`.
355
 *
356
 * @api private
357
 * @param {Runnable} runnable
358
 * @return {Context}
359
 */
360
Context.prototype.runnable = function (runnable) {
361
  if (!arguments.length) {
362
    return this._runnable;
363
  }
364
  this.test = this._runnable = runnable;
365
  return this;
366
};
367
368
/**
369
 * Set test timeout `ms`.
370
 *
371
 * @api private
372
 * @param {number} ms
373
 * @return {Context} self
374
 */
375
Context.prototype.timeout = function (ms) {
376
  if (!arguments.length) {
377
    return this.runnable().timeout();
378
  }
379
  this.runnable().timeout(ms);
380
  return this;
381
};
382
383
/**
384
 * Set test timeout `enabled`.
385
 *
386
 * @api private
387
 * @param {boolean} enabled
388
 * @return {Context} self
389
 */
390
Context.prototype.enableTimeouts = function (enabled) {
391
  this.runnable().enableTimeouts(enabled);
392
  return this;
393
};
394
395
/**
396
 * Set test slowness threshold `ms`.
397
 *
398
 * @api private
399
 * @param {number} ms
400
 * @return {Context} self
401
 */
402
Context.prototype.slow = function (ms) {
403
  this.runnable().slow(ms);
404
  return this;
405
};
406
407
/**
408
 * Mark a test as skipped.
409
 *
410
 * @api private
411
 * @throws Pending
412
 */
413
Context.prototype.skip = function () {
414
  this.runnable().skip();
415
};
416
417
/**
418
 * Allow a number of retries on failed tests
419
 *
420
 * @api private
421
 * @param {number} n
422
 * @return {Context} self
423
 */
424
Context.prototype.retries = function (n) {
425
  if (!arguments.length) {
426
    return this.runnable().retries();
427
  }
428
  this.runnable().retries(n);
429
  return this;
430
};
431
432
/**
433
 * Inspect the context void of `._runnable`.
434
 *
435
 * @api private
436
 * @return {string}
437
 */
438
Context.prototype.inspect = function () {
439
  return JSON.stringify(this, function (key, val) {
440
    return key === 'runnable' || key === 'test' ? undefined : val;
441
  }, 2);
442
};
443
444
},{}],6:[function(require,module,exports){
445
'use strict';
446
447
/**
448
 * Module dependencies.
449
 */
450
451
var Runnable = require('./runnable');
452
var inherits = require('./utils').inherits;
453
454
/**
455
 * Expose `Hook`.
456
 */
457
458
module.exports = Hook;
459
460
/**
461
 * Initialize a new `Hook` with the given `title` and callback `fn`.
462
 *
463
 * @param {String} title
464
 * @param {Function} fn
465
 * @api private
466
 */
467
function Hook (title, fn) {
468
  Runnable.call(this, title, fn);
469
  this.type = 'hook';
470
}
471
472
/**
473
 * Inherit from `Runnable.prototype`.
474
 */
475
inherits(Hook, Runnable);
476
477
/**
478
 * Get or set the test `err`.
479
 *
480
 * @param {Error} err
481
 * @return {Error}
482
 * @api public
483
 */
484
Hook.prototype.error = function (err) {
485
  if (!arguments.length) {
486
    err = this._error;
487
    this._error = null;
488
    return err;
489
  }
490
491
  this._error = err;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
492
};
493
494 View Code Duplication
},{"./runnable":32,"./utils":36}],7:[function(require,module,exports){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
495
'use strict';
496
497
/**
498
 * Module dependencies.
499
 */
500
501
var Test = require('../test');
502
503
/**
504
 * BDD-style interface:
505
 *
506
 *      describe('Array', function() {
507
 *        describe('#indexOf()', function() {
508
 *          it('should return -1 when not present', function() {
509
 *            // ...
510
 *          });
511
 *
512
 *          it('should return the index when present', function() {
513
 *            // ...
514
 *          });
515
 *        });
516
 *      });
517
 *
518
 * @param {Suite} suite Root suite.
519
 */
520
module.exports = function (suite) {
521
  var suites = [suite];
522
523
  suite.on('pre-require', function (context, file, mocha) {
524
    var common = require('./common')(suites, context, mocha);
525
526
    context.before = common.before;
527
    context.after = common.after;
528
    context.beforeEach = common.beforeEach;
529
    context.afterEach = common.afterEach;
530
    context.run = mocha.options.delay && common.runWithSuite(suite);
531
    /**
532
     * Describe a "suite" with the given `title`
533
     * and callback `fn` containing nested suites
534
     * and/or tests.
535
     */
536
537
    context.describe = context.context = function (title, fn) {
538
      return common.suite.create({
539
        title: title,
540
        file: file,
541
        fn: fn
542
      });
543
    };
544
545
    /**
546
     * Pending describe.
547
     */
548
549
    context.xdescribe = context.xcontext = context.describe.skip = function (title, fn) {
550
      return common.suite.skip({
551
        title: title,
552
        file: file,
553
        fn: fn
554
      });
555
    };
556
557
    /**
558
     * Exclusive suite.
559
     */
560
561
    context.describe.only = function (title, fn) {
562
      return common.suite.only({
563
        title: title,
564
        file: file,
565
        fn: fn
566
      });
567
    };
568
569
    /**
570
     * Describe a specification or test-case
571
     * with the given `title` and callback `fn`
572
     * acting as a thunk.
573
     */
574
575
    context.it = context.specify = function (title, fn) {
576
      var suite = suites[0];
577
      if (suite.isPending()) {
578
        fn = null;
579
      }
580
      var test = new Test(title, fn);
581
      test.file = file;
582
      suite.addTest(test);
583
      return test;
584
    };
585
586
    /**
587
     * Exclusive test-case.
588
     */
589
590
    context.it.only = function (title, fn) {
591
      return common.test.only(mocha, context.it(title, fn));
592
    };
593
594
    /**
595
     * Pending test case.
596
     */
597
598
    context.xit = context.xspecify = context.it.skip = function (title) {
599
      context.it(title);
600
    };
601
602
    /**
603
     * Number of attempts to retry.
604
     */
605
    context.it.retries = function (n) {
606
      context.retries(n);
607
    };
608
  });
609
};
610
611
},{"../test":35,"./common":8}],8:[function(require,module,exports){
612
'use strict';
613
614
var Suite = require('../suite');
615
616
/**
617
 * Functions common to more than one interface.
618
 *
619
 * @param {Suite[]} suites
620
 * @param {Context} context
621
 * @param {Mocha} mocha
622
 * @return {Object} An object containing common functions.
623
 */
624 View Code Duplication
module.exports = function (suites, context, mocha) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
625
  return {
626
    /**
627
     * This is only present if flag --delay is passed into Mocha. It triggers
628
     * root suite execution.
629
     *
630
     * @param {Suite} suite The root suite.
631
     * @return {Function} A function which runs the root suite
632
     */
633
    runWithSuite: function runWithSuite (suite) {
634
      return function run () {
635
        suite.run();
636
      };
637
    },
638
639
    /**
640
     * Execute before running tests.
641
     *
642
     * @param {string} name
643
     * @param {Function} fn
644
     */
645
    before: function (name, fn) {
646
      suites[0].beforeAll(name, fn);
647
    },
648
649
    /**
650
     * Execute after running tests.
651
     *
652
     * @param {string} name
653
     * @param {Function} fn
654
     */
655
    after: function (name, fn) {
656
      suites[0].afterAll(name, fn);
657
    },
658
659
    /**
660
     * Execute before each test case.
661
     *
662
     * @param {string} name
663
     * @param {Function} fn
664
     */
665
    beforeEach: function (name, fn) {
666
      suites[0].beforeEach(name, fn);
667
    },
668
669
    /**
670
     * Execute after each test case.
671
     *
672
     * @param {string} name
673
     * @param {Function} fn
674
     */
675
    afterEach: function (name, fn) {
676
      suites[0].afterEach(name, fn);
677
    },
678
679
    suite: {
680
      /**
681
       * Create an exclusive Suite; convenience function
682
       * See docstring for create() below.
683
       *
684
       * @param {Object} opts
685
       * @returns {Suite}
686
       */
687
      only: function only (opts) {
688
        opts.isOnly = true;
689
        return this.create(opts);
690
      },
691
692
      /**
693
       * Create a Suite, but skip it; convenience function
694
       * See docstring for create() below.
695
       *
696
       * @param {Object} opts
697
       * @returns {Suite}
698
       */
699
      skip: function skip (opts) {
700
        opts.pending = true;
701
        return this.create(opts);
702
      },
703
704
      /**
705
       * Creates a suite.
706
       * @param {Object} opts Options
707
       * @param {string} opts.title Title of Suite
708
       * @param {Function} [opts.fn] Suite Function (not always applicable)
709
       * @param {boolean} [opts.pending] Is Suite pending?
710
       * @param {string} [opts.file] Filepath where this Suite resides
711
       * @param {boolean} [opts.isOnly] Is Suite exclusive?
712
       * @returns {Suite}
713
       */
714
      create: function create (opts) {
715
        var suite = Suite.create(suites[0], opts.title);
716
        suite.pending = Boolean(opts.pending);
717
        suite.file = opts.file;
718
        suites.unshift(suite);
719
        if (opts.isOnly) {
720
          suite.parent._onlySuites = suite.parent._onlySuites.concat(suite);
721
        }
722
        if (typeof opts.fn === 'function') {
723
          opts.fn.call(suite);
724
          suites.shift();
725
        } else if (typeof opts.fn === 'undefined' && !suite.pending) {
726
          throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
727
        }
728
729
        return suite;
730
      }
731
    },
732
733
    test: {
734
735
      /**
736
       * Exclusive test-case.
737
       *
738
       * @param {Object} mocha
739
       * @param {Function} test
740
       * @returns {*}
741
       */
742
      only: function (mocha, test) {
743
        test.parent._onlyTests = test.parent._onlyTests.concat(test);
744
        return test;
745
      },
746
747
      /**
748
       * Pending test case.
749
       *
750
       * @param {string} title
751
       */
752
      skip: function (title) {
753
        context.test(title);
754
      },
755
756
      /**
757
       * Number of retry attempts
758
       *
759
       * @param {number} n
760
       */
761
      retries: function (n) {
762
        context.retries(n);
763
      }
764
    }
765
  };
766
};
767
768
},{"../suite":34}],9:[function(require,module,exports){
769
'use strict';
770
771
/**
772
 * Module dependencies.
773
 */
774
775
var Suite = require('../suite');
776
var Test = require('../test');
777
778
/**
779
 * Exports-style (as Node.js module) interface:
780
 *
781
 *     exports.Array = {
782
 *       '#indexOf()': {
783
 *         'should return -1 when the value is not present': function() {
784
 *
785
 *         },
786
 *
787
 *         'should return the correct index when the value is present': function() {
788
 *
789
 *         }
790
 *       }
791
 *     };
792
 *
793
 * @param {Suite} suite Root suite.
794
 */
795 View Code Duplication
module.exports = function (suite) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
796
  var suites = [suite];
797
798
  suite.on('require', visit);
799
800
  function visit (obj, file) {
801
    var suite;
802
    for (var key in obj) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
803
      if (typeof obj[key] === 'function') {
804
        var fn = obj[key];
805
        switch (key) {
806
          case 'before':
807
            suites[0].beforeAll(fn);
808
            break;
809
          case 'after':
810
            suites[0].afterAll(fn);
811
            break;
812
          case 'beforeEach':
813
            suites[0].beforeEach(fn);
814
            break;
815
          case 'afterEach':
816
            suites[0].afterEach(fn);
817
            break;
818
          default:
819
            var test = new Test(key, fn);
820
            test.file = file;
821
            suites[0].addTest(test);
822
        }
823
      } else {
824
        suite = Suite.create(suites[0], key);
825
        suites.unshift(suite);
826
        visit(obj[key], file);
827
        suites.shift();
828
      }
829
    }
830
  }
831
};
832
833
},{"../suite":34,"../test":35}],10:[function(require,module,exports){
834
'use strict';
835
836
exports.bdd = require('./bdd');
837
exports.tdd = require('./tdd');
838
exports.qunit = require('./qunit');
839
exports.exports = require('./exports');
840
841 View Code Duplication
},{"./bdd":7,"./exports":9,"./qunit":11,"./tdd":12}],11:[function(require,module,exports){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
842
'use strict';
843
844
/**
845
 * Module dependencies.
846
 */
847
848
var Test = require('../test');
849
850
/**
851
 * QUnit-style interface:
852
 *
853
 *     suite('Array');
854
 *
855
 *     test('#length', function() {
856
 *       var arr = [1,2,3];
857
 *       ok(arr.length == 3);
858
 *     });
859
 *
860
 *     test('#indexOf()', function() {
861
 *       var arr = [1,2,3];
862
 *       ok(arr.indexOf(1) == 0);
863
 *       ok(arr.indexOf(2) == 1);
864
 *       ok(arr.indexOf(3) == 2);
865
 *     });
866
 *
867
 *     suite('String');
868
 *
869
 *     test('#length', function() {
870
 *       ok('foo'.length == 3);
871
 *     });
872
 *
873
 * @param {Suite} suite Root suite.
874
 */
875
module.exports = function (suite) {
876
  var suites = [suite];
877
878
  suite.on('pre-require', function (context, file, mocha) {
879
    var common = require('./common')(suites, context, mocha);
880
881
    context.before = common.before;
882
    context.after = common.after;
883
    context.beforeEach = common.beforeEach;
884
    context.afterEach = common.afterEach;
885
    context.run = mocha.options.delay && common.runWithSuite(suite);
886
    /**
887
     * Describe a "suite" with the given `title`.
888
     */
889
890
    context.suite = function (title) {
891
      if (suites.length > 1) {
892
        suites.shift();
893
      }
894
      return common.suite.create({
895
        title: title,
896
        file: file,
897
        fn: false
898
      });
899
    };
900
901
    /**
902
     * Exclusive Suite.
903
     */
904
905
    context.suite.only = function (title) {
906
      if (suites.length > 1) {
907
        suites.shift();
908
      }
909
      return common.suite.only({
910
        title: title,
911
        file: file,
912
        fn: false
913
      });
914
    };
915
916
    /**
917
     * Describe a specification or test-case
918
     * with the given `title` and callback `fn`
919
     * acting as a thunk.
920
     */
921
922
    context.test = function (title, fn) {
923
      var test = new Test(title, fn);
924
      test.file = file;
925
      suites[0].addTest(test);
926
      return test;
927
    };
928
929
    /**
930
     * Exclusive test-case.
931
     */
932
933
    context.test.only = function (title, fn) {
934
      return common.test.only(mocha, context.test(title, fn));
935
    };
936
937
    context.test.skip = common.test.skip;
938
    context.test.retries = common.test.retries;
939
  });
940
};
941
942
},{"../test":35,"./common":8}],12:[function(require,module,exports){
943
'use strict';
944
945
/**
946
 * Module dependencies.
947
 */
948
949
var Test = require('../test');
950
951
/**
952
 * TDD-style interface:
953
 *
954
 *      suite('Array', function() {
955
 *        suite('#indexOf()', function() {
956
 *          suiteSetup(function() {
957
 *
958
 *          });
959
 *
960
 *          test('should return -1 when not present', function() {
961
 *
962
 *          });
963
 *
964
 *          test('should return the index when present', function() {
965
 *
966
 *          });
967
 *
968
 *          suiteTeardown(function() {
969
 *
970
 *          });
971
 *        });
972
 *      });
973
 *
974
 * @param {Suite} suite Root suite.
975
 */
976 View Code Duplication
module.exports = function (suite) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
977
  var suites = [suite];
978
979
  suite.on('pre-require', function (context, file, mocha) {
980
    var common = require('./common')(suites, context, mocha);
981
982
    context.setup = common.beforeEach;
983
    context.teardown = common.afterEach;
984
    context.suiteSetup = common.before;
985
    context.suiteTeardown = common.after;
986
    context.run = mocha.options.delay && common.runWithSuite(suite);
987
988
    /**
989
     * Describe a "suite" with the given `title` and callback `fn` containing
990
     * nested suites and/or tests.
991
     */
992
    context.suite = function (title, fn) {
993
      return common.suite.create({
994
        title: title,
995
        file: file,
996
        fn: fn
997
      });
998
    };
999
1000
    /**
1001
     * Pending suite.
1002
     */
1003
    context.suite.skip = function (title, fn) {
1004
      return common.suite.skip({
1005
        title: title,
1006
        file: file,
1007
        fn: fn
1008
      });
1009
    };
1010
1011
    /**
1012
     * Exclusive test-case.
1013
     */
1014
    context.suite.only = function (title, fn) {
1015
      return common.suite.only({
1016
        title: title,
1017
        file: file,
1018
        fn: fn
1019
      });
1020
    };
1021
1022
    /**
1023
     * Describe a specification or test-case with the given `title` and
1024
     * callback `fn` acting as a thunk.
1025
     */
1026
    context.test = function (title, fn) {
1027
      var suite = suites[0];
1028
      if (suite.isPending()) {
1029
        fn = null;
1030
      }
1031
      var test = new Test(title, fn);
1032
      test.file = file;
1033
      suite.addTest(test);
1034
      return test;
1035
    };
1036
1037
    /**
1038
     * Exclusive test-case.
1039
     */
1040
1041
    context.test.only = function (title, fn) {
1042
      return common.test.only(mocha, context.test(title, fn));
1043
    };
1044
1045
    context.test.skip = common.test.skip;
1046
    context.test.retries = common.test.retries;
1047
  });
1048
};
1049
1050
},{"../test":35,"./common":8}],13:[function(require,module,exports){
1051
(function (process,global,__dirname){
1052
'use strict';
1053
1054
/*!
1055
 * mocha
1056
 * Copyright(c) 2011 TJ Holowaychuk <[email protected]>
1057
 * MIT Licensed
1058
 */
1059
1060
/**
1061
 * Module dependencies.
1062
 */
1063
1064
var escapeRe = require('escape-string-regexp');
1065
var path = require('path');
1066
var reporters = require('./reporters');
1067
var utils = require('./utils');
1068
1069
/**
1070
 * Expose `Mocha`.
1071
 */
1072
1073
exports = module.exports = Mocha;
1074
1075
/**
1076
 * To require local UIs and reporters when running in node.
1077
 */
1078
1079
if (!process.browser) {
1080
  var cwd = process.cwd();
1081
  module.paths.push(cwd, path.join(cwd, 'node_modules'));
1082
}
1083
1084
/**
1085
 * Expose internals.
1086
 */
1087
1088
exports.utils = utils;
1089
exports.interfaces = require('./interfaces');
1090
exports.reporters = reporters;
1091
exports.Runnable = require('./runnable');
1092
exports.Context = require('./context');
1093
exports.Runner = require('./runner');
1094
exports.Suite = require('./suite');
1095
exports.Hook = require('./hook');
1096
exports.Test = require('./test');
1097
1098
/**
1099
 * Return image `name` path.
1100
 *
1101
 * @api private
1102
 * @param {string} name
1103
 * @return {string}
1104
 */
1105
function image (name) {
1106
  return path.join(__dirname, '../images', name + '.png');
1107
}
1108
1109
/**
1110
 * Set up mocha with `options`.
1111
 *
1112
 * Options:
1113
 *
1114
 *   - `ui` name "bdd", "tdd", "exports" etc
1115
 *   - `reporter` reporter instance, defaults to `mocha.reporters.spec`
1116
 *   - `globals` array of accepted globals
1117
 *   - `timeout` timeout in milliseconds
1118
 *   - `retries` number of times to retry failed tests
1119
 *   - `bail` bail on the first test failure
1120
 *   - `slow` milliseconds to wait before considering a test slow
1121
 *   - `ignoreLeaks` ignore global leaks
1122
 *   - `fullTrace` display the full stack-trace on failing
1123
 *   - `grep` string or regexp to filter tests with
1124
 *
1125
 * @param {Object} options
1126
 * @api public
1127
 */
1128 View Code Duplication
function Mocha (options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1129
  options = options || {};
1130
  this.files = [];
1131
  this.options = options;
1132
  if (options.grep) {
1133
    this.grep(new RegExp(options.grep));
1134
  }
1135
  if (options.fgrep) {
1136
    this.fgrep(options.fgrep);
1137
  }
1138
  this.suite = new exports.Suite('', new exports.Context());
1139
  this.ui(options.ui);
1140
  this.bail(options.bail);
1141
  this.reporter(options.reporter, options.reporterOptions);
1142
  if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
1143
    this.timeout(options.timeout);
1144
  }
1145
  if (typeof options.retries !== 'undefined' && options.retries !== null) {
1146
    this.retries(options.retries);
1147
  }
1148
  this.useColors(options.useColors);
1149
  if (options.enableTimeouts !== null) {
1150
    this.enableTimeouts(options.enableTimeouts);
1151
  }
1152
  if (options.slow) {
1153
    this.slow(options.slow);
1154
  }
1155
}
1156
1157
/**
1158
 * Enable or disable bailing on the first failure.
1159
 *
1160
 * @api public
1161
 * @param {boolean} [bail]
1162
 */
1163
Mocha.prototype.bail = function (bail) {
1164
  if (!arguments.length) {
1165
    bail = true;
1166
  }
1167
  this.suite.bail(bail);
1168
  return this;
1169
};
1170
1171
/**
1172
 * Add test `file`.
1173
 *
1174
 * @api public
1175
 * @param {string} file
1176
 */
1177
Mocha.prototype.addFile = function (file) {
1178
  this.files.push(file);
1179
  return this;
1180
};
1181
1182
/**
1183
 * Set reporter to `reporter`, defaults to "spec".
1184
 *
1185
 * @param {String|Function} reporter name or constructor
1186
 * @param {Object} reporterOptions optional options
1187
 * @api public
1188
 * @param {string|Function} reporter name or constructor
1189
 * @param {Object} reporterOptions optional options
1190
 */
1191 View Code Duplication
Mocha.prototype.reporter = function (reporter, reporterOptions) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1192
  if (typeof reporter === 'function') {
1193
    this._reporter = reporter;
1194
  } else {
1195
    reporter = reporter || 'spec';
1196
    var _reporter;
1197
    // Try to load a built-in reporter.
1198
    if (reporters[reporter]) {
1199
      _reporter = reporters[reporter];
1200
    }
1201
    // Try to load reporters from process.cwd() and node_modules
1202
    if (!_reporter) {
1203
      try {
1204
        _reporter = require(reporter);
1205
      } catch (err) {
1206
        if (err.message.indexOf('Cannot find module') !== -1) {
1207
          // Try to load reporters from a path (absolute or relative)
1208
          try {
1209
            _reporter = require(path.resolve(process.cwd(), reporter));
1210
          } catch (_err) {
1211
            err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')
1212
              : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
1213
          }
1214
        } else {
1215
          console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
1216
        }
1217
      }
1218
    }
1219
    if (!_reporter && reporter === 'teamcity') {
1220
      console.warn('The Teamcity reporter was moved to a package named ' +
1221
        'mocha-teamcity-reporter ' +
1222
        '(https://npmjs.org/package/mocha-teamcity-reporter).');
1223
    }
1224
    if (!_reporter) {
1225
      throw new Error('invalid reporter "' + reporter + '"');
1226
    }
1227
    this._reporter = _reporter;
1228
  }
1229
  this.options.reporterOptions = reporterOptions;
1230
  return this;
1231
};
1232
1233
/**
1234
 * Set test UI `name`, defaults to "bdd".
1235
 *
1236
 * @api public
1237
 * @param {string} bdd
1238
 */
1239 View Code Duplication
Mocha.prototype.ui = function (name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1240
  name = name || 'bdd';
1241
  this._ui = exports.interfaces[name];
1242
  if (!this._ui) {
1243
    try {
1244
      this._ui = require(name);
1245
    } catch (err) {
1246
      throw new Error('invalid interface "' + name + '"');
1247
    }
1248
  }
1249
  this._ui = this._ui(this.suite);
1250
1251
  this.suite.on('pre-require', function (context) {
1252
    exports.afterEach = context.afterEach || context.teardown;
1253
    exports.after = context.after || context.suiteTeardown;
1254
    exports.beforeEach = context.beforeEach || context.setup;
1255
    exports.before = context.before || context.suiteSetup;
1256
    exports.describe = context.describe || context.suite;
1257
    exports.it = context.it || context.test;
1258
    exports.xit = context.xit || context.test.skip;
1259
    exports.setup = context.setup || context.beforeEach;
1260
    exports.suiteSetup = context.suiteSetup || context.before;
1261
    exports.suiteTeardown = context.suiteTeardown || context.after;
1262
    exports.suite = context.suite || context.describe;
1263
    exports.teardown = context.teardown || context.afterEach;
1264
    exports.test = context.test || context.it;
1265
    exports.run = context.run;
1266
  });
1267
1268
  return this;
1269
};
1270
1271
/**
1272
 * Load registered files.
1273
 *
1274
 * @api private
1275
 */
1276
Mocha.prototype.loadFiles = function (fn) {
1277
  var self = this;
1278
  var suite = this.suite;
1279
  this.files.forEach(function (file) {
1280
    file = path.resolve(file);
1281
    suite.emit('pre-require', global, file, self);
1282
    suite.emit('require', require(file), file, self);
1283
    suite.emit('post-require', global, file, self);
1284
  });
1285
  fn && fn();
1286
};
1287
1288
/**
1289
 * Enable growl support.
1290
 *
1291
 * @api private
1292
 */
1293 View Code Duplication
Mocha.prototype._growl = function (runner, reporter) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1294
  var notify = require('growl');
1295
1296
  runner.on('end', function () {
1297
    var stats = reporter.stats;
1298
    if (stats.failures) {
1299
      var msg = stats.failures + ' of ' + runner.total + ' tests failed';
1300
      notify(msg, { name: 'mocha', title: 'Failed', image: image('error') });
1301
    } else {
1302
      notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {
1303
        name: 'mocha',
1304
        title: 'Passed',
1305
        image: image('ok')
1306
      });
1307
    }
1308
  });
1309
};
1310
1311
/**
1312
 * Escape string and add it to grep as a regexp.
1313
 *
1314
 * @api public
1315
 * @param str
1316
 * @returns {Mocha}
1317
 */
1318
Mocha.prototype.fgrep = function (str) {
1319
  return this.grep(new RegExp(escapeRe(str)));
1320
};
1321
1322
/**
1323
 * Add regexp to grep, if `re` is a string it is escaped.
1324
 *
1325
 * @param {RegExp|String} re
1326
 * @return {Mocha}
1327
 * @api public
1328
 * @param {RegExp|string} re
1329
 * @return {Mocha}
1330
 */
1331
Mocha.prototype.grep = function (re) {
1332
  if (utils.isString(re)) {
1333
    // extract args if it's regex-like, i.e: [string, pattern, flag]
1334
    var arg = re.match(/^\/(.*)\/(g|i|)$|.*/);
1335
    this.options.grep = new RegExp(arg[1] || arg[0], arg[2]);
1336
  } else {
1337
    this.options.grep = re;
1338
  }
1339
  return this;
1340
};
1341
/**
1342
 * Invert `.grep()` matches.
1343
 *
1344
 * @return {Mocha}
1345
 * @api public
1346
 */
1347
Mocha.prototype.invert = function () {
1348
  this.options.invert = true;
1349
  return this;
1350
};
1351
1352
/**
1353
 * Ignore global leaks.
1354
 *
1355
 * @param {Boolean} ignore
1356
 * @return {Mocha}
1357
 * @api public
1358
 * @param {boolean} ignore
1359
 * @return {Mocha}
1360
 */
1361
Mocha.prototype.ignoreLeaks = function (ignore) {
1362
  this.options.ignoreLeaks = Boolean(ignore);
1363
  return this;
1364
};
1365
1366
/**
1367
 * Enable global leak checking.
1368
 *
1369
 * @return {Mocha}
1370
 * @api public
1371
 */
1372
Mocha.prototype.checkLeaks = function () {
1373
  this.options.ignoreLeaks = false;
1374
  return this;
1375
};
1376
1377
/**
1378
 * Display long stack-trace on failing
1379
 *
1380
 * @return {Mocha}
1381
 * @api public
1382
 */
1383
Mocha.prototype.fullTrace = function () {
1384
  this.options.fullStackTrace = true;
1385
  return this;
1386
};
1387
1388
/**
1389
 * Enable growl support.
1390
 *
1391
 * @return {Mocha}
1392
 * @api public
1393
 */
1394
Mocha.prototype.growl = function () {
1395
  this.options.growl = true;
1396
  return this;
1397
};
1398
1399
/**
1400
 * Ignore `globals` array or string.
1401
 *
1402
 * @param {Array|String} globals
1403
 * @return {Mocha}
1404
 * @api public
1405
 * @param {Array|string} globals
1406
 * @return {Mocha}
1407
 */
1408
Mocha.prototype.globals = function (globals) {
1409
  this.options.globals = (this.options.globals || []).concat(globals);
1410
  return this;
1411
};
1412
1413
/**
1414
 * Emit color output.
1415
 *
1416
 * @param {Boolean} colors
1417
 * @return {Mocha}
1418
 * @api public
1419
 * @param {boolean} colors
1420
 * @return {Mocha}
1421
 */
1422
Mocha.prototype.useColors = function (colors) {
1423
  if (colors !== undefined) {
1424
    this.options.useColors = colors;
1425
  }
1426
  return this;
1427
};
1428
1429
/**
1430
 * Use inline diffs rather than +/-.
1431
 *
1432
 * @param {Boolean} inlineDiffs
1433
 * @return {Mocha}
1434
 * @api public
1435
 * @param {boolean} inlineDiffs
1436
 * @return {Mocha}
1437
 */
1438
Mocha.prototype.useInlineDiffs = function (inlineDiffs) {
1439
  this.options.useInlineDiffs = inlineDiffs !== undefined && inlineDiffs;
1440
  return this;
1441
};
1442
1443
/**
1444
 * Set the timeout in milliseconds.
1445
 *
1446
 * @param {Number} timeout
1447
 * @return {Mocha}
1448
 * @api public
1449
 * @param {number} timeout
1450
 * @return {Mocha}
1451
 */
1452
Mocha.prototype.timeout = function (timeout) {
1453
  this.suite.timeout(timeout);
1454
  return this;
1455
};
1456
1457
/**
1458
 * Set the number of times to retry failed tests.
1459
 *
1460
 * @param {Number} retry times
1461
 * @return {Mocha}
1462
 * @api public
1463
 */
1464
Mocha.prototype.retries = function (n) {
1465
  this.suite.retries(n);
1466
  return this;
1467
};
1468
1469
/**
1470
 * Set slowness threshold in milliseconds.
1471
 *
1472
 * @param {Number} slow
1473
 * @return {Mocha}
1474
 * @api public
1475
 * @param {number} slow
1476
 * @return {Mocha}
1477
 */
1478
Mocha.prototype.slow = function (slow) {
1479
  this.suite.slow(slow);
1480
  return this;
1481
};
1482
1483
/**
1484
 * Enable timeouts.
1485
 *
1486
 * @param {Boolean} enabled
1487
 * @return {Mocha}
1488
 * @api public
1489
 * @param {boolean} enabled
1490
 * @return {Mocha}
1491
 */
1492
Mocha.prototype.enableTimeouts = function (enabled) {
1493
  this.suite.enableTimeouts(arguments.length && enabled !== undefined ? enabled : true);
1494
  return this;
1495
};
1496
1497
/**
1498
 * Makes all tests async (accepting a callback)
1499
 *
1500
 * @return {Mocha}
1501
 * @api public
1502
 */
1503
Mocha.prototype.asyncOnly = function () {
1504
  this.options.asyncOnly = true;
1505
  return this;
1506
};
1507
1508
/**
1509
 * Disable syntax highlighting (in browser).
1510
 *
1511
 * @api public
1512
 */
1513
Mocha.prototype.noHighlighting = function () {
1514
  this.options.noHighlighting = true;
1515
  return this;
1516
};
1517
1518
/**
1519
 * Enable uncaught errors to propagate (in browser).
1520
 *
1521
 * @return {Mocha}
1522
 * @api public
1523
 */
1524
Mocha.prototype.allowUncaught = function () {
1525
  this.options.allowUncaught = true;
1526
  return this;
1527
};
1528
1529
/**
1530
 * Delay root suite execution.
1531
 * @returns {Mocha}
1532
 */
1533
Mocha.prototype.delay = function delay () {
1534
  this.options.delay = true;
1535
  return this;
1536
};
1537
1538
/**
1539
 * Tests marked only fail the suite
1540
 * @returns {Mocha}
1541
 */
1542
Mocha.prototype.forbidOnly = function () {
1543
  this.options.forbidOnly = true;
1544
  return this;
1545
};
1546
1547
/**
1548
 * Pending tests and tests marked skip fail the suite
1549
 * @returns {Mocha}
1550
 */
1551
Mocha.prototype.forbidPending = function () {
1552
  this.options.forbidPending = true;
1553
  return this;
1554
};
1555
1556
/**
1557
 * Run tests and invoke `fn()` when complete.
1558
 *
1559
 * @api public
1560
 * @param {Function} fn
1561
 * @return {Runner}
1562
 */
1563 View Code Duplication
Mocha.prototype.run = function (fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1564
  if (this.files.length) {
1565
    this.loadFiles();
1566
  }
1567
  var suite = this.suite;
1568
  var options = this.options;
1569
  options.files = this.files;
1570
  var runner = new exports.Runner(suite, options.delay);
1571
  var reporter = new this._reporter(runner, options);
1572
  runner.ignoreLeaks = options.ignoreLeaks !== false;
1573
  runner.fullStackTrace = options.fullStackTrace;
1574
  runner.asyncOnly = options.asyncOnly;
1575
  runner.allowUncaught = options.allowUncaught;
1576
  runner.forbidOnly = options.forbidOnly;
1577
  runner.forbidPending = options.forbidPending;
1578
  if (options.grep) {
1579
    runner.grep(options.grep, options.invert);
1580
  }
1581
  if (options.globals) {
1582
    runner.globals(options.globals);
1583
  }
1584
  if (options.growl) {
1585
    this._growl(runner, reporter);
1586
  }
1587
  if (options.useColors !== undefined) {
1588
    exports.reporters.Base.useColors = options.useColors;
1589
  }
1590
  exports.reporters.Base.inlineDiffs = options.useInlineDiffs;
1591
1592
  function done (failures) {
1593
    if (reporter.done) {
1594
      reporter.done(failures, fn);
1595
    } else {
1596
      fn && fn(failures);
1597
    }
1598
  }
1599
1600
  return runner.run(done);
1601
};
1602
1603
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib")
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
1604
},{"./context":5,"./hook":6,"./interfaces":10,"./reporters":20,"./runnable":32,"./runner":33,"./suite":34,"./test":35,"./utils":36,"_process":55,"escape-string-regexp":45,"growl":2,"path":40}],14:[function(require,module,exports){
1605
'use strict';
1606
1607
/**
1608
 * Helpers.
1609
 */
1610
1611
var s = 1000;
1612
var m = s * 60;
1613
var h = m * 60;
1614
var d = h * 24;
1615
var y = d * 365.25;
1616
1617
/**
1618
 * Parse or format the given `val`.
1619
 *
1620
 * Options:
1621
 *
1622
 *  - `long` verbose formatting [false]
1623
 *
1624
 * @api public
1625
 * @param {string|number} val
1626
 * @param {Object} options
1627
 * @return {string|number}
1628
 */
1629
module.exports = function (val, options) {
1630
  options = options || {};
1631
  if (typeof val === 'string') {
1632
    return parse(val);
1633
  }
1634
  // https://github.com/mochajs/mocha/pull/1035
1635
  return options['long'] ? longFormat(val) : shortFormat(val);
1636
};
1637
1638
/**
1639
 * Parse the given `str` and return milliseconds.
1640
 *
1641
 * @api private
1642
 * @param {string} str
1643
 * @return {number}
1644
 */
1645 View Code Duplication
function parse (str) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1646
  var match = (/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i).exec(str);
1647
  if (!match) {
1648
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
1649
  }
1650
  var n = parseFloat(match[1]);
1651
  var type = (match[2] || 'ms').toLowerCase();
1652
  switch (type) {
1653
    case 'years':
1654
    case 'year':
1655
    case 'y':
1656
      return n * y;
1657
    case 'days':
1658
    case 'day':
1659
    case 'd':
1660
      return n * d;
1661
    case 'hours':
1662
    case 'hour':
1663
    case 'h':
1664
      return n * h;
1665
    case 'minutes':
1666
    case 'minute':
1667
    case 'm':
1668
      return n * m;
1669
    case 'seconds':
1670
    case 'second':
1671
    case 's':
1672
      return n * s;
1673
    case 'ms':
1674
      return n;
1675
    default:
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
1676
      // No default case
1677
  }
1678
}
1679
1680
/**
1681
 * Short format for `ms`.
1682
 *
1683
 * @api private
1684
 * @param {number} ms
1685
 * @return {string}
1686
 */
1687 View Code Duplication
function shortFormat (ms) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1688
  if (ms >= d) {
1689
    return Math.round(ms / d) + 'd';
1690
  }
1691
  if (ms >= h) {
1692
    return Math.round(ms / h) + 'h';
1693
  }
1694
  if (ms >= m) {
1695
    return Math.round(ms / m) + 'm';
1696
  }
1697
  if (ms >= s) {
1698
    return Math.round(ms / s) + 's';
1699
  }
1700
  return ms + 'ms';
1701
}
1702
1703
/**
1704
 * Long format for `ms`.
1705
 *
1706
 * @api private
1707
 * @param {number} ms
1708
 * @return {string}
1709
 */
1710
function longFormat (ms) {
1711
  return plural(ms, d, 'day') ||
1712
    plural(ms, h, 'hour') ||
1713
    plural(ms, m, 'minute') ||
1714
    plural(ms, s, 'second') ||
1715
    ms + ' ms';
1716
}
1717
1718
/**
1719
 * Pluralization helper.
1720
 *
1721
 * @api private
1722
 * @param {number} ms
1723
 * @param {number} n
1724
 * @param {string} name
1725
 */
1726 View Code Duplication
function plural (ms, n, name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1727
  if (ms < n) {
1728
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
1729
  }
1730
  if (ms < n * 1.5) {
1731
    return Math.floor(ms / n) + ' ' + name;
1732
  }
1733
  return Math.ceil(ms / n) + ' ' + name + 's';
1734
}
1735
1736
},{}],15:[function(require,module,exports){
1737
'use strict';
1738
1739
/**
1740
 * Expose `Pending`.
1741
 */
1742
1743
module.exports = Pending;
1744
1745
/**
1746
 * Initialize a new `Pending` error with the given message.
1747
 *
1748
 * @param {string} message
1749
 */
1750
function Pending (message) {
1751
  this.message = message;
1752
}
1753
1754
},{}],16:[function(require,module,exports){
1755
(function (process,global){
1756
'use strict';
1757
1758
/**
1759
 * Module dependencies.
1760
 */
1761
1762
var tty = require('tty');
1763
var diff = require('diff');
1764
var ms = require('../ms');
1765
var utils = require('../utils');
1766
var supportsColor = process.browser ? null : require('supports-color');
1767
1768
/**
1769
 * Expose `Base`.
1770
 */
1771
1772
exports = module.exports = Base;
1773
1774
/**
1775
 * Save timer references to avoid Sinon interfering.
1776
 * See: https://github.com/mochajs/mocha/issues/237
1777
 */
1778
1779
/* eslint-disable no-unused-vars, no-native-reassign */
1780
var Date = global.Date;
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Date. This makes code hard to read, consider using a different name.
Loading history...
1781
var setTimeout = global.setTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setTimeout seems to be never used. Consider removing it.
Loading history...
1782
var setInterval = global.setInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setInterval seems to be never used. Consider removing it.
Loading history...
1783
var clearTimeout = global.clearTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearTimeout seems to be never used. Consider removing it.
Loading history...
1784
var clearInterval = global.clearInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearInterval seems to be never used. Consider removing it.
Loading history...
1785
/* eslint-enable no-unused-vars, no-native-reassign */
1786
1787
/**
1788
 * Check if both stdio streams are associated with a tty.
1789
 */
1790
1791
var isatty = tty.isatty(1) && tty.isatty(2);
1792
1793
/**
1794
 * Enable coloring by default, except in the browser interface.
1795
 */
1796
1797
exports.useColors = !process.browser && (supportsColor || (process.env.MOCHA_COLORS !== undefined));
1798
1799
/**
1800
 * Inline diffs instead of +/-
1801
 */
1802
1803
exports.inlineDiffs = false;
1804
1805
/**
1806
 * Default color map.
1807
 */
1808
1809
exports.colors = {
1810
  pass: 90,
1811
  fail: 31,
1812
  'bright pass': 92,
1813
  'bright fail': 91,
1814
  'bright yellow': 93,
1815
  pending: 36,
1816
  suite: 0,
1817
  'error title': 0,
1818
  'error message': 31,
1819
  'error stack': 90,
1820
  checkmark: 32,
1821
  fast: 90,
1822
  medium: 33,
1823
  slow: 31,
1824
  green: 32,
1825
  light: 90,
1826
  'diff gutter': 90,
1827
  'diff added': 32,
1828
  'diff removed': 31
1829
};
1830
1831
/**
1832
 * Default symbol map.
1833
 */
1834
1835
exports.symbols = {
1836
  ok: '✓',
1837
  err: '✖',
1838
  dot: '․',
1839
  comma: ',',
1840
  bang: '!'
1841
};
1842
1843
// With node.js on Windows: use symbols available in terminal default fonts
1844
if (process.platform === 'win32') {
1845
  exports.symbols.ok = '\u221A';
1846
  exports.symbols.err = '\u00D7';
1847
  exports.symbols.dot = '.';
1848
}
1849
1850
/**
1851
 * Color `str` with the given `type`,
1852
 * allowing colors to be disabled,
1853
 * as well as user-defined color
1854
 * schemes.
1855
 *
1856
 * @param {string} type
1857
 * @param {string} str
1858
 * @return {string}
1859
 * @api private
1860
 */
1861
var color = exports.color = function (type, str) {
1862
  if (!exports.useColors) {
1863
    return String(str);
1864
  }
1865
  return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m';
1866
};
1867
1868
/**
1869
 * Expose term window size, with some defaults for when stderr is not a tty.
1870
 */
1871
1872
exports.window = {
1873
  width: 75
1874
};
1875
1876
if (isatty) {
1877
  exports.window.width = process.stdout.getWindowSize
1878
    ? process.stdout.getWindowSize(1)[0]
1879
    : tty.getWindowSize()[1];
1880
}
1881
1882
/**
1883
 * Expose some basic cursor interactions that are common among reporters.
1884
 */
1885
1886
exports.cursor = {
1887
  hide: function () {
1888
    isatty && process.stdout.write('\u001b[?25l');
1889
  },
1890
1891
  show: function () {
1892
    isatty && process.stdout.write('\u001b[?25h');
1893
  },
1894
1895
  deleteLine: function () {
1896
    isatty && process.stdout.write('\u001b[2K');
1897
  },
1898
1899
  beginningOfLine: function () {
1900
    isatty && process.stdout.write('\u001b[0G');
1901
  },
1902
1903
  CR: function () {
1904
    if (isatty) {
1905
      exports.cursor.deleteLine();
1906
      exports.cursor.beginningOfLine();
1907
    } else {
1908
      process.stdout.write('\r');
1909
    }
1910
  }
1911
};
1912
1913
/**
1914
 * Output the given `failures` as a list.
1915
 *
1916
 * @param {Array} failures
1917
 * @api public
1918
 */
1919
1920 View Code Duplication
exports.list = function (failures) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
1921
  console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
1922
  failures.forEach(function (test, i) {
1923
    // format
1924
    var fmt = color('error title', '  %s) %s:\n') +
1925
      color('error message', '     %s') +
1926
      color('error stack', '\n%s\n');
1927
1928
    // msg
1929
    var msg;
1930
    var err = test.err;
1931
    var message;
1932
    if (err.message && typeof err.message.toString === 'function') {
1933
      message = err.message + '';
1934
    } else if (typeof err.inspect === 'function') {
1935
      message = err.inspect() + '';
1936
    } else {
1937
      message = '';
1938
    }
1939
    var stack = err.stack || message;
1940
    var index = message ? stack.indexOf(message) : -1;
1941
    var actual = err.actual;
1942
    var expected = err.expected;
1943
    var escape = true;
0 ignored issues
show
Unused Code introduced by
The assignment to variable escape seems to be never used. Consider removing it.
Loading history...
1944
1945
    if (index === -1) {
1946
      msg = message;
1947
    } else {
1948
      index += message.length;
1949
      msg = stack.slice(0, index);
1950
      // remove msg from stack
1951
      stack = stack.slice(index + 1);
1952
    }
1953
1954
    // uncaught
1955
    if (err.uncaught) {
1956
      msg = 'Uncaught ' + msg;
1957
    }
1958
    // explicitly show diff
1959
    if (err.showDiff !== false && sameType(actual, expected) && expected !== undefined) {
1960
      escape = false;
1961
      if (!(utils.isString(actual) && utils.isString(expected))) {
1962
        err.actual = actual = utils.stringify(actual);
1963
        err.expected = expected = utils.stringify(expected);
1964
      }
1965
1966
      fmt = color('error title', '  %s) %s:\n%s') + color('error stack', '\n%s\n');
1967
      var match = message.match(/^([^:]+): expected/);
1968
      msg = '\n      ' + color('error message', match ? match[1] : msg);
1969
1970
      if (exports.inlineDiffs) {
1971
        msg += inlineDiff(err, escape);
1972
      } else {
1973
        msg += unifiedDiff(err, escape);
1974
      }
1975
    }
1976
1977
    // indent stack trace
1978
    stack = stack.replace(/^/gm, '  ');
1979
1980
    // indented test title
1981
    var testTitle = '';
1982
    test.titlePath().forEach(function (str, index) {
1983
      if (index !== 0) {
1984
        testTitle += '\n     ';
1985
      }
1986
      for (var i = 0; i < index; i++) {
1987
        testTitle += '  ';
0 ignored issues
show
Bug introduced by
The variable testTitle is changed as part of the for loop for example by " " on line 1987. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
1988
      }
1989
      testTitle += str;
1990
    });
1991
1992
    console.log(fmt, (i + 1), testTitle, msg, stack);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
1993
  });
1994
};
1995
1996
/**
1997
 * Initialize a new `Base` reporter.
1998
 *
1999
 * All other reporters generally
2000
 * inherit from this reporter, providing
2001
 * stats such as test duration, number
2002
 * of tests passed / failed etc.
2003
 *
2004
 * @param {Runner} runner
2005
 * @api public
2006
 */
2007
2008 View Code Duplication
function Base (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2009
  var stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 };
2010
  var failures = this.failures = [];
2011
2012
  if (!runner) {
2013
    return;
2014
  }
2015
  this.runner = runner;
2016
2017
  runner.stats = stats;
2018
2019
  runner.on('start', function () {
2020
    stats.start = new Date();
2021
  });
2022
2023
  runner.on('suite', function (suite) {
2024
    stats.suites = stats.suites || 0;
2025
    suite.root || stats.suites++;
2026
  });
2027
2028
  runner.on('test end', function () {
2029
    stats.tests = stats.tests || 0;
2030
    stats.tests++;
2031
  });
2032
2033
  runner.on('pass', function (test) {
2034
    stats.passes = stats.passes || 0;
2035
2036
    if (test.duration > test.slow()) {
2037
      test.speed = 'slow';
2038
    } else if (test.duration > test.slow() / 2) {
2039
      test.speed = 'medium';
2040
    } else {
2041
      test.speed = 'fast';
2042
    }
2043
2044
    stats.passes++;
2045
  });
2046
2047
  runner.on('fail', function (test, err) {
2048
    stats.failures = stats.failures || 0;
2049
    stats.failures++;
2050
    test.err = err;
2051
    failures.push(test);
2052
  });
2053
2054
  runner.on('end', function () {
2055
    stats.end = new Date();
2056
    stats.duration = new Date() - stats.start;
2057
  });
2058
2059
  runner.on('pending', function () {
2060
    stats.pending++;
2061
  });
2062
}
2063
2064
/**
2065
 * Output common epilogue used by many of
2066
 * the bundled reporters.
2067
 *
2068
 * @api public
2069
 */
2070
Base.prototype.epilogue = function () {
2071
  var stats = this.stats;
2072
  var fmt;
2073
2074
  console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2075
2076
  // passes
2077
  fmt = color('bright pass', ' ') +
2078
    color('green', ' %d passing') +
2079
    color('light', ' (%s)');
2080
2081
  console.log(fmt,
2082
    stats.passes || 0,
2083
    ms(stats.duration));
2084
2085
  // pending
2086
  if (stats.pending) {
2087
    fmt = color('pending', ' ') +
2088
      color('pending', ' %d pending');
2089
2090
    console.log(fmt, stats.pending);
2091
  }
2092
2093
  // failures
2094
  if (stats.failures) {
2095
    fmt = color('fail', '  %d failing');
2096
2097
    console.log(fmt, stats.failures);
2098
2099
    Base.list(this.failures);
2100
    console.log();
2101
  }
2102
2103
  console.log();
2104
};
2105
2106
/**
2107
 * Pad the given `str` to `len`.
2108
 *
2109
 * @api private
2110
 * @param {string} str
2111
 * @param {string} len
2112
 * @return {string}
2113
 */
2114
function pad (str, len) {
2115
  str = String(str);
2116
  return Array(len - str.length + 1).join(' ') + str;
2117
}
2118
2119
/**
2120
 * Returns an inline diff between 2 strings with coloured ANSI output
2121
 *
2122
 * @api private
2123
 * @param {Error} err with actual/expected
2124
 * @param {boolean} escape
2125
 * @return {string} Diff
2126
 */
2127 View Code Duplication
function inlineDiff (err, escape) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2128
  var msg = errorDiff(err, 'WordsWithSpace', escape);
2129
2130
  // linenos
2131
  var lines = msg.split('\n');
2132
  if (lines.length > 4) {
2133
    var width = String(lines.length).length;
2134
    msg = lines.map(function (str, i) {
2135
      return pad(++i, width) + ' |' + ' ' + str;
2136
    }).join('\n');
2137
  }
2138
2139
  // legend
2140
  msg = '\n' +
2141
    color('diff removed', 'actual') +
2142
    ' ' +
2143
    color('diff added', 'expected') +
2144
    '\n\n' +
2145
    msg +
2146
    '\n';
2147
2148
  // indent
2149
  msg = msg.replace(/^/gm, '      ');
2150
  return msg;
2151
}
2152
2153
/**
2154
 * Returns a unified diff between two strings.
2155
 *
2156
 * @api private
2157
 * @param {Error} err with actual/expected
2158
 * @param {boolean} escape
2159
 * @return {string} The diff.
2160
 */
2161 View Code Duplication
function unifiedDiff (err, escape) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2162
  var indent = '      ';
2163
  function cleanUp (line) {
2164
    if (escape) {
2165
      line = escapeInvisibles(line);
2166
    }
2167
    if (line[0] === '+') {
2168
      return indent + colorLines('diff added', line);
2169
    }
2170
    if (line[0] === '-') {
2171
      return indent + colorLines('diff removed', line);
2172
    }
2173
    if (line.match(/@@/)) {
2174
      return '--';
2175
    }
2176
    if (line.match(/\\ No newline/)) {
2177
      return null;
2178
    }
2179
    return indent + line;
2180
  }
2181
  function notBlank (line) {
2182
    return typeof line !== 'undefined' && line !== null;
2183
  }
2184
  var msg = diff.createPatch('string', err.actual, err.expected);
2185
  var lines = msg.split('\n').splice(5);
2186
  return '\n      ' +
2187
    colorLines('diff added', '+ expected') + ' ' +
2188
    colorLines('diff removed', '- actual') +
2189
    '\n\n' +
2190
    lines.map(cleanUp).filter(notBlank).join('\n');
2191
}
2192
2193
/**
2194
 * Return a character diff for `err`.
2195
 *
2196
 * @api private
2197
 * @param {Error} err
2198
 * @param {string} type
2199
 * @param {boolean} escape
2200
 * @return {string}
2201
 */
2202
function errorDiff (err, type, escape) {
2203
  var actual = escape ? escapeInvisibles(err.actual) : err.actual;
2204
  var expected = escape ? escapeInvisibles(err.expected) : err.expected;
2205
  return diff['diff' + type](actual, expected).map(function (str) {
2206
    if (str.added) {
2207
      return colorLines('diff added', str.value);
2208
    }
2209
    if (str.removed) {
2210
      return colorLines('diff removed', str.value);
2211
    }
2212
    return str.value;
2213
  }).join('');
2214
}
2215
2216
/**
2217
 * Returns a string with all invisible characters in plain text
2218
 *
2219
 * @api private
2220
 * @param {string} line
2221
 * @return {string}
2222
 */
2223
function escapeInvisibles (line) {
2224
  return line.replace(/\t/g, '<tab>')
2225
    .replace(/\r/g, '<CR>')
2226
    .replace(/\n/g, '<LF>\n');
2227
}
2228
2229
/**
2230
 * Color lines for `str`, using the color `name`.
2231
 *
2232
 * @api private
2233
 * @param {string} name
2234
 * @param {string} str
2235
 * @return {string}
2236
 */
2237
function colorLines (name, str) {
2238
  return str.split('\n').map(function (str) {
2239
    return color(name, str);
2240
  }).join('\n');
2241
}
2242
2243
/**
2244
 * Object#toString reference.
2245
 */
2246
var objToString = Object.prototype.toString;
2247
2248
/**
2249
 * Check that a / b have the same type.
2250
 *
2251
 * @api private
2252
 * @param {Object} a
2253
 * @param {Object} b
2254
 * @return {boolean}
2255
 */
2256
function sameType (a, b) {
2257
  return objToString.call(a) === objToString.call(b);
2258
}
2259
2260
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2261
},{"../ms":14,"../utils":36,"_process":55,"diff":44,"supports-color":40,"tty":4}],17:[function(require,module,exports){
2262
'use strict';
2263
2264
/**
2265
 * Module dependencies.
2266
 */
2267
2268
var Base = require('./base');
2269
var utils = require('../utils');
2270
2271
/**
2272
 * Expose `Doc`.
2273
 */
2274
2275
exports = module.exports = Doc;
0 ignored issues
show
Unused Code introduced by
The assignment to variable exports seems to be never used. Consider removing it.
Loading history...
2276
2277
/**
2278
 * Initialize a new `Doc` reporter.
2279
 *
2280
 * @param {Runner} runner
2281
 * @api public
2282
 */
2283 View Code Duplication
function Doc (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2284
  Base.call(this, runner);
2285
2286
  var indents = 2;
2287
2288
  function indent () {
2289
    return Array(indents).join('  ');
2290
  }
2291
2292
  runner.on('suite', function (suite) {
2293
    if (suite.root) {
2294
      return;
2295
    }
2296
    ++indents;
2297
    console.log('%s<section class="suite">', indent());
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2298
    ++indents;
2299
    console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
2300
    console.log('%s<dl>', indent());
2301
  });
2302
2303
  runner.on('suite end', function (suite) {
2304
    if (suite.root) {
2305
      return;
2306
    }
2307
    console.log('%s</dl>', indent());
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2308
    --indents;
2309
    console.log('%s</section>', indent());
2310
    --indents;
2311
  });
2312
2313
  runner.on('pass', function (test) {
2314
    console.log('%s  <dt>%s</dt>', indent(), utils.escape(test.title));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2315
    var code = utils.escape(utils.clean(test.body));
2316
    console.log('%s  <dd><pre><code>%s</code></pre></dd>', indent(), code);
2317
  });
2318
2319
  runner.on('fail', function (test, err) {
2320
    console.log('%s  <dt class="error">%s</dt>', indent(), utils.escape(test.title));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2321
    var code = utils.escape(utils.clean(test.body));
2322
    console.log('%s  <dd class="error"><pre><code>%s</code></pre></dd>', indent(), code);
2323
    console.log('%s  <dd class="error">%s</dd>', indent(), utils.escape(err));
2324
  });
2325
}
2326
2327
},{"../utils":36,"./base":16}],18:[function(require,module,exports){
2328
(function (process){
2329
'use strict';
2330
2331
/**
2332
 * Module dependencies.
2333
 */
2334
2335
var Base = require('./base');
2336
var inherits = require('../utils').inherits;
2337
var color = Base.color;
2338
2339
/**
2340
 * Expose `Dot`.
2341
 */
2342
2343
exports = module.exports = Dot;
2344
2345
/**
2346
 * Initialize a new `Dot` matrix test reporter.
2347
 *
2348
 * @api public
2349
 * @param {Runner} runner
2350
 */
2351 View Code Duplication
function Dot (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2352
  Base.call(this, runner);
2353
2354
  var self = this;
2355
  var width = Base.window.width * 0.75 | 0;
2356
  var n = -1;
2357
2358
  runner.on('start', function () {
2359
    process.stdout.write('\n');
2360
  });
2361
2362
  runner.on('pending', function () {
2363
    if (++n % width === 0) {
2364
      process.stdout.write('\n  ');
2365
    }
2366
    process.stdout.write(color('pending', Base.symbols.comma));
2367
  });
2368
2369
  runner.on('pass', function (test) {
2370
    if (++n % width === 0) {
2371
      process.stdout.write('\n  ');
2372
    }
2373
    if (test.speed === 'slow') {
2374
      process.stdout.write(color('bright yellow', Base.symbols.dot));
2375
    } else {
2376
      process.stdout.write(color(test.speed, Base.symbols.dot));
2377
    }
2378
  });
2379
2380
  runner.on('fail', function () {
2381
    if (++n % width === 0) {
2382
      process.stdout.write('\n  ');
2383
    }
2384
    process.stdout.write(color('fail', Base.symbols.bang));
2385
  });
2386
2387
  runner.on('end', function () {
2388
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2389
    self.epilogue();
2390
  });
2391
}
2392
2393
/**
2394
 * Inherit from `Base.prototype`.
2395
 */
2396
inherits(Dot, Base);
2397
2398
}).call(this,require('_process'))
2399
},{"../utils":36,"./base":16,"_process":55}],19:[function(require,module,exports){
2400
(function (global){
2401
'use strict';
2402
2403
/* eslint-env browser */
2404
2405
/**
2406
 * Module dependencies.
2407
 */
2408
2409
var Base = require('./base');
2410
var utils = require('../utils');
2411
var Progress = require('../browser/progress');
2412
var escapeRe = require('escape-string-regexp');
2413
var escape = utils.escape;
2414
2415
/**
2416
 * Save timer references to avoid Sinon interfering (see GH-237).
2417
 */
2418
2419
/* eslint-disable no-unused-vars, no-native-reassign */
2420
var Date = global.Date;
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Date. This makes code hard to read, consider using a different name.
Loading history...
2421
var setTimeout = global.setTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setTimeout seems to be never used. Consider removing it.
Loading history...
2422
var setInterval = global.setInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setInterval seems to be never used. Consider removing it.
Loading history...
2423
var clearTimeout = global.clearTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearTimeout seems to be never used. Consider removing it.
Loading history...
2424
var clearInterval = global.clearInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearInterval seems to be never used. Consider removing it.
Loading history...
2425
/* eslint-enable no-unused-vars, no-native-reassign */
2426
2427
/**
2428
 * Expose `HTML`.
2429
 */
2430
2431
exports = module.exports = HTML;
2432
2433
/**
2434
 * Stats template.
2435
 */
2436
2437
var statsTemplate = '<ul id="mocha-stats">' +
2438
  '<li class="progress"><canvas width="40" height="40"></canvas></li>' +
2439
  '<li class="passes"><a href="javascript:void(0);">passes:</a> <em>0</em></li>' +
2440
  '<li class="failures"><a href="javascript:void(0);">failures:</a> <em>0</em></li>' +
2441
  '<li class="duration">duration: <em>0</em>s</li>' +
2442
  '</ul>';
2443
2444
var playIcon = '&#x2023;';
2445
2446
/**
2447
 * Initialize a new `HTML` reporter.
2448
 *
2449
 * @api public
2450
 * @param {Runner} runner
2451
 */
2452 View Code Duplication
function HTML (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2453
  Base.call(this, runner);
2454
2455
  var self = this;
2456
  var stats = this.stats;
2457
  var stat = fragment(statsTemplate);
2458
  var items = stat.getElementsByTagName('li');
2459
  var passes = items[1].getElementsByTagName('em')[0];
2460
  var passesLink = items[1].getElementsByTagName('a')[0];
2461
  var failures = items[2].getElementsByTagName('em')[0];
2462
  var failuresLink = items[2].getElementsByTagName('a')[0];
2463
  var duration = items[3].getElementsByTagName('em')[0];
2464
  var canvas = stat.getElementsByTagName('canvas')[0];
2465
  var report = fragment('<ul id="mocha-report"></ul>');
2466
  var stack = [report];
2467
  var progress;
2468
  var ctx;
2469
  var root = document.getElementById('mocha');
2470
2471
  if (canvas.getContext) {
2472
    var ratio = window.devicePixelRatio || 1;
2473
    canvas.style.width = canvas.width;
2474
    canvas.style.height = canvas.height;
2475
    canvas.width *= ratio;
2476
    canvas.height *= ratio;
2477
    ctx = canvas.getContext('2d');
2478
    ctx.scale(ratio, ratio);
2479
    progress = new Progress();
2480
  }
2481
2482
  if (!root) {
2483
    return error('#mocha div missing, add it to your document');
2484
  }
2485
2486
  // pass toggle
2487
  on(passesLink, 'click', function (evt) {
2488
    evt.preventDefault();
2489
    unhide();
2490
    var name = (/pass/).test(report.className) ? '' : ' pass';
2491
    report.className = report.className.replace(/fail|pass/g, '') + name;
2492
    if (report.className.trim()) {
2493
      hideSuitesWithout('test pass');
2494
    }
2495
  });
2496
2497
  // failure toggle
2498
  on(failuresLink, 'click', function (evt) {
2499
    evt.preventDefault();
2500
    unhide();
2501
    var name = (/fail/).test(report.className) ? '' : ' fail';
2502
    report.className = report.className.replace(/fail|pass/g, '') + name;
2503
    if (report.className.trim()) {
2504
      hideSuitesWithout('test fail');
2505
    }
2506
  });
2507
2508
  root.appendChild(stat);
2509
  root.appendChild(report);
2510
2511
  if (progress) {
2512
    progress.size(40);
2513
  }
2514
2515
  runner.on('suite', function (suite) {
2516
    if (suite.root) {
2517
      return;
2518
    }
2519
2520
    // suite
2521
    var url = self.suiteURL(suite);
2522
    var el = fragment('<li class="suite"><h1><a href="%s">%s</a></h1></li>', url, escape(suite.title));
2523
2524
    // container
2525
    stack[0].appendChild(el);
2526
    stack.unshift(document.createElement('ul'));
2527
    el.appendChild(stack[0]);
2528
  });
2529
2530
  runner.on('suite end', function (suite) {
2531
    if (suite.root) {
2532
      updateStats();
2533
      return;
2534
    }
2535
    stack.shift();
2536
  });
2537
2538
  runner.on('pass', function (test) {
2539
    var url = self.testURL(test);
2540
    var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
2541
      '<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
2542
    var el = fragment(markup, test.speed, test.title, test.duration, url);
2543
    self.addCodeToggle(el, test.body);
2544
    appendToStack(el);
2545
    updateStats();
2546
  });
2547
2548
  runner.on('fail', function (test) {
2549
    var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
2550
      test.title, self.testURL(test));
2551
    var stackString; // Note: Includes leading newline
2552
    var message = test.err.toString();
2553
2554
    // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
2555
    // check for the result of the stringifying.
2556
    if (message === '[object Error]') {
2557
      message = test.err.message;
2558
    }
2559
2560
    if (test.err.stack) {
2561
      var indexOfMessage = test.err.stack.indexOf(test.err.message);
2562
      if (indexOfMessage === -1) {
2563
        stackString = test.err.stack;
2564
      } else {
2565
        stackString = test.err.stack.substr(test.err.message.length + indexOfMessage);
2566
      }
2567
    } else if (test.err.sourceURL && test.err.line !== undefined) {
2568
      // Safari doesn't give you a stack. Let's at least provide a source line.
2569
      stackString = '\n(' + test.err.sourceURL + ':' + test.err.line + ')';
2570
    }
2571
2572
    stackString = stackString || '';
2573
2574
    if (test.err.htmlMessage && stackString) {
2575
      el.appendChild(fragment('<div class="html-error">%s\n<pre class="error">%e</pre></div>',
2576
        test.err.htmlMessage, stackString));
2577
    } else if (test.err.htmlMessage) {
2578
      el.appendChild(fragment('<div class="html-error">%s</div>', test.err.htmlMessage));
2579
    } else {
2580
      el.appendChild(fragment('<pre class="error">%e%e</pre>', message, stackString));
2581
    }
2582
2583
    self.addCodeToggle(el, test.body);
2584
    appendToStack(el);
2585
    updateStats();
2586
  });
2587
2588
  runner.on('pending', function (test) {
2589
    var el = fragment('<li class="test pass pending"><h2>%e</h2></li>', test.title);
2590
    appendToStack(el);
2591
    updateStats();
2592
  });
2593
2594
  function appendToStack (el) {
2595
    // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
2596
    if (stack[0]) {
2597
      stack[0].appendChild(el);
2598
    }
2599
  }
2600
2601
  function updateStats () {
2602
    // TODO: add to stats
2603
    var percent = stats.tests / runner.total * 100 | 0;
2604
    if (progress) {
2605
      progress.update(percent).draw(ctx);
0 ignored issues
show
Bug introduced by
The variable ctx does not seem to be initialized in case canvas.getContext on line 2471 is false. Are you sure the function draw handles undefined variables?
Loading history...
2606
    }
2607
2608
    // update stats
2609
    var ms = new Date() - stats.start;
2610
    text(passes, stats.passes);
2611
    text(failures, stats.failures);
2612
    text(duration, (ms / 1000).toFixed(2));
2613
  }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
2614
}
2615
2616
/**
2617
 * Makes a URL, preserving querystring ("search") parameters.
2618
 *
2619
 * @param {string} s
2620
 * @return {string} A new URL.
2621
 */
2622
function makeUrl (s) {
2623
  var search = window.location.search;
2624
2625
  // Remove previous grep query parameter if present
2626
  if (search) {
2627
    search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
2628
  }
2629
2630
  return window.location.pathname + (search ? search + '&' : '?') + 'grep=' + encodeURIComponent(escapeRe(s));
2631
}
2632
2633
/**
2634
 * Provide suite URL.
2635
 *
2636
 * @param {Object} [suite]
2637
 */
2638
HTML.prototype.suiteURL = function (suite) {
2639
  return makeUrl(suite.fullTitle());
2640
};
2641
2642
/**
2643
 * Provide test URL.
2644
 *
2645
 * @param {Object} [test]
2646
 */
2647
HTML.prototype.testURL = function (test) {
2648
  return makeUrl(test.fullTitle());
2649
};
2650
2651
/**
2652
 * Adds code toggle functionality for the provided test's list element.
2653
 *
2654
 * @param {HTMLLIElement} el
2655
 * @param {string} contents
2656
 */
2657
HTML.prototype.addCodeToggle = function (el, contents) {
2658
  var h2 = el.getElementsByTagName('h2')[0];
2659
2660
  on(h2, 'click', function () {
2661
    pre.style.display = pre.style.display === 'none' ? 'block' : 'none';
2662
  });
2663
2664
  var pre = fragment('<pre><code>%e</code></pre>', utils.clean(contents));
2665
  el.appendChild(pre);
2666
  pre.style.display = 'none';
2667
};
2668
2669
/**
2670
 * Display error `msg`.
2671
 *
2672
 * @param {string} msg
2673
 */
2674
function error (msg) {
2675
  document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg));
2676
}
2677
2678
/**
2679
 * Return a DOM fragment from `html`.
2680
 *
2681
 * @param {string} html
2682
 */
2683
function fragment (html) {
2684
  var args = arguments;
2685
  var div = document.createElement('div');
2686
  var i = 1;
2687
2688
  div.innerHTML = html.replace(/%([se])/g, function (_, type) {
2689
    switch (type) {
2690
      case 's': return String(args[i++]);
2691
      case 'e': return escape(args[i++]);
2692
      // no default
2693
    }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
2694
  });
2695
2696
  return div.firstChild;
2697
}
2698
2699
/**
2700
 * Check for suites that do not have elements
2701
 * with `classname`, and hide them.
2702
 *
2703
 * @param {text} classname
2704
 */
2705
function hideSuitesWithout (classname) {
2706
  var suites = document.getElementsByClassName('suite');
2707
  for (var i = 0; i < suites.length; i++) {
2708
    var els = suites[i].getElementsByClassName(classname);
2709
    if (!els.length) {
2710
      suites[i].className += ' hidden';
2711
    }
2712
  }
2713
}
2714
2715
/**
2716
 * Unhide .hidden suites.
2717
 */
2718
function unhide () {
2719
  var els = document.getElementsByClassName('suite hidden');
2720
  for (var i = 0; i < els.length; ++i) {
2721
    els[i].className = els[i].className.replace('suite hidden', 'suite');
2722
  }
2723
}
2724
2725
/**
2726
 * Set an element's text contents.
2727
 *
2728
 * @param {HTMLElement} el
2729
 * @param {string} contents
2730
 */
2731
function text (el, contents) {
2732
  if (el.textContent) {
2733
    el.textContent = contents;
2734
  } else {
2735
    el.innerText = contents;
2736
  }
2737
}
2738
2739
/**
2740
 * Listen on `event` with callback `fn`.
2741
 */
2742
function on (el, event, fn) {
2743
  if (el.addEventListener) {
2744
    el.addEventListener(event, fn, false);
2745
  } else {
2746
    el.attachEvent('on' + event, fn);
2747
  }
2748
}
2749
2750
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
2751
},{"../browser/progress":3,"../utils":36,"./base":16,"escape-string-regexp":45}],20:[function(require,module,exports){
2752
'use strict';
2753
2754
// Alias exports to a their normalized format Mocha#reporter to prevent a need
2755
// for dynamic (try/catch) requires, which Browserify doesn't handle.
2756
exports.Base = exports.base = require('./base');
2757
exports.Dot = exports.dot = require('./dot');
2758
exports.Doc = exports.doc = require('./doc');
2759
exports.TAP = exports.tap = require('./tap');
2760
exports.JSON = exports.json = require('./json');
2761
exports.HTML = exports.html = require('./html');
2762
exports.List = exports.list = require('./list');
2763
exports.Min = exports.min = require('./min');
2764
exports.Spec = exports.spec = require('./spec');
2765
exports.Nyan = exports.nyan = require('./nyan');
2766
exports.XUnit = exports.xunit = require('./xunit');
2767
exports.Markdown = exports.markdown = require('./markdown');
2768
exports.Progress = exports.progress = require('./progress');
2769
exports.Landing = exports.landing = require('./landing');
2770
exports.JSONStream = exports['json-stream'] = require('./json-stream');
2771
2772
},{"./base":16,"./doc":17,"./dot":18,"./html":19,"./json":22,"./json-stream":21,"./landing":23,"./list":24,"./markdown":25,"./min":26,"./nyan":27,"./progress":28,"./spec":29,"./tap":30,"./xunit":31}],21:[function(require,module,exports){
2773
(function (process){
2774
'use strict';
2775
2776
/**
2777
 * Module dependencies.
2778
 */
2779
2780
var Base = require('./base');
2781
2782
/**
2783
 * Expose `List`.
2784
 */
2785
2786
exports = module.exports = List;
2787
2788
/**
2789
 * Initialize a new `List` test reporter.
2790
 *
2791
 * @api public
2792
 * @param {Runner} runner
2793
 */
2794 View Code Duplication
function List (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2795
  Base.call(this, runner);
2796
2797
  var self = this;
2798
  var total = runner.total;
2799
2800
  runner.on('start', function () {
2801
    console.log(JSON.stringify(['start', { total: total }]));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2802
  });
2803
2804
  runner.on('pass', function (test) {
2805
    console.log(JSON.stringify(['pass', clean(test)]));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2806
  });
2807
2808
  runner.on('fail', function (test, err) {
2809
    test = clean(test);
2810
    test.err = err.message;
2811
    test.stack = err.stack || null;
2812
    console.log(JSON.stringify(['fail', test]));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
2813
  });
2814
2815
  runner.on('end', function () {
2816
    process.stdout.write(JSON.stringify(['end', self.stats]));
2817
  });
2818
}
2819
2820
/**
2821
 * Return a plain-object representation of `test`
2822
 * free of cyclic properties etc.
2823
 *
2824
 * @api private
2825
 * @param {Object} test
2826
 * @return {Object}
2827
 */
2828
function clean (test) {
2829
  return {
2830
    title: test.title,
2831
    fullTitle: test.fullTitle(),
2832
    duration: test.duration,
2833
    currentRetry: test.currentRetry()
2834
  };
2835
}
2836
2837
}).call(this,require('_process'))
2838
},{"./base":16,"_process":55}],22:[function(require,module,exports){
2839
(function (process){
2840
'use strict';
2841
2842
/**
2843
 * Module dependencies.
2844
 */
2845
2846
var Base = require('./base');
2847
2848
/**
2849
 * Expose `JSON`.
2850
 */
2851
2852
exports = module.exports = JSONReporter;
2853
2854
/**
2855
 * Initialize a new `JSON` reporter.
2856
 *
2857
 * @api public
2858
 * @param {Runner} runner
2859
 */
2860 View Code Duplication
function JSONReporter (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2861
  Base.call(this, runner);
2862
2863
  var self = this;
2864
  var tests = [];
2865
  var pending = [];
2866
  var failures = [];
2867
  var passes = [];
2868
2869
  runner.on('test end', function (test) {
2870
    tests.push(test);
2871
  });
2872
2873
  runner.on('pass', function (test) {
2874
    passes.push(test);
2875
  });
2876
2877
  runner.on('fail', function (test) {
2878
    failures.push(test);
2879
  });
2880
2881
  runner.on('pending', function (test) {
2882
    pending.push(test);
2883
  });
2884
2885
  runner.on('end', function () {
2886
    var obj = {
2887
      stats: self.stats,
2888
      tests: tests.map(clean),
2889
      pending: pending.map(clean),
2890
      failures: failures.map(clean),
2891
      passes: passes.map(clean)
2892
    };
2893
2894
    runner.testResults = obj;
2895
2896
    process.stdout.write(JSON.stringify(obj, null, 2));
2897
  });
2898
}
2899
2900
/**
2901
 * Return a plain-object representation of `test`
2902
 * free of cyclic properties etc.
2903
 *
2904
 * @api private
2905
 * @param {Object} test
2906
 * @return {Object}
2907
 */
2908
function clean (test) {
2909
  return {
2910
    title: test.title,
2911
    fullTitle: test.fullTitle(),
2912
    duration: test.duration,
2913
    currentRetry: test.currentRetry(),
2914
    err: errorJSON(test.err || {})
2915
  };
2916
}
2917
2918
/**
2919
 * Transform `error` into a JSON object.
2920
 *
2921
 * @api private
2922
 * @param {Error} err
2923
 * @return {Object}
2924
 */
2925
function errorJSON (err) {
2926
  var res = {};
2927
  Object.getOwnPropertyNames(err).forEach(function (key) {
2928
    res[key] = err[key];
2929
  }, err);
2930
  return res;
2931
}
2932
2933
}).call(this,require('_process'))
2934
},{"./base":16,"_process":55}],23:[function(require,module,exports){
2935
(function (process){
2936
'use strict';
2937
2938
/**
2939
 * Module dependencies.
2940
 */
2941
2942
var Base = require('./base');
2943
var inherits = require('../utils').inherits;
2944
var cursor = Base.cursor;
2945
var color = Base.color;
2946
2947
/**
2948
 * Expose `Landing`.
2949
 */
2950
2951
exports = module.exports = Landing;
2952
2953
/**
2954
 * Airplane color.
2955
 */
2956
2957
Base.colors.plane = 0;
2958
2959
/**
2960
 * Airplane crash color.
2961
 */
2962
2963
Base.colors['plane crash'] = 31;
2964
2965
/**
2966
 * Runway color.
2967
 */
2968
2969
Base.colors.runway = 90;
2970
2971
/**
2972
 * Initialize a new `Landing` reporter.
2973
 *
2974
 * @api public
2975
 * @param {Runner} runner
2976
 */
2977 View Code Duplication
function Landing (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2978
  Base.call(this, runner);
2979
2980
  var self = this;
2981
  var width = Base.window.width * 0.75 | 0;
2982
  var total = runner.total;
2983
  var stream = process.stdout;
2984
  var plane = color('plane', '✈');
2985
  var crashed = -1;
2986
  var n = 0;
2987
2988
  function runway () {
2989
    var buf = Array(width).join('-');
2990
    return '  ' + color('runway', buf);
2991
  }
2992
2993
  runner.on('start', function () {
2994
    stream.write('\n\n\n  ');
2995
    cursor.hide();
2996
  });
2997
2998
  runner.on('test end', function (test) {
2999
    // check if the plane crashed
3000
    var col = crashed === -1 ? width * ++n / total | 0 : crashed;
3001
3002
    // show the crash
3003
    if (test.state === 'failed') {
3004
      plane = color('plane crash', '✈');
3005
      crashed = col;
3006
    }
3007
3008
    // render landing strip
3009
    stream.write('\u001b[' + (width + 1) + 'D\u001b[2A');
3010
    stream.write(runway());
3011
    stream.write('\n  ');
3012
    stream.write(color('runway', Array(col).join('⋅')));
3013
    stream.write(plane);
3014
    stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
3015
    stream.write(runway());
3016
    stream.write('\u001b[0m');
3017
  });
3018
3019
  runner.on('end', function () {
3020
    cursor.show();
3021
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3022
    self.epilogue();
3023
  });
3024
}
3025
3026
/**
3027
 * Inherit from `Base.prototype`.
3028
 */
3029
inherits(Landing, Base);
3030
3031
}).call(this,require('_process'))
3032
},{"../utils":36,"./base":16,"_process":55}],24:[function(require,module,exports){
3033
(function (process){
3034
'use strict';
3035
3036
/**
3037
 * Module dependencies.
3038
 */
3039
3040
var Base = require('./base');
3041
var inherits = require('../utils').inherits;
3042
var color = Base.color;
3043
var cursor = Base.cursor;
3044
3045
/**
3046
 * Expose `List`.
3047
 */
3048
3049
exports = module.exports = List;
3050
3051
/**
3052
 * Initialize a new `List` test reporter.
3053
 *
3054
 * @api public
3055
 * @param {Runner} runner
3056
 */
3057 View Code Duplication
function List (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3058
  Base.call(this, runner);
3059
3060
  var self = this;
3061
  var n = 0;
3062
3063
  runner.on('start', function () {
3064
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3065
  });
3066
3067
  runner.on('test', function (test) {
3068
    process.stdout.write(color('pass', '    ' + test.fullTitle() + ': '));
3069
  });
3070
3071
  runner.on('pending', function (test) {
3072
    var fmt = color('checkmark', '  -') +
3073
      color('pending', ' %s');
3074
    console.log(fmt, test.fullTitle());
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3075
  });
3076
3077
  runner.on('pass', function (test) {
3078
    var fmt = color('checkmark', '  ' + Base.symbols.ok) +
3079
      color('pass', ' %s: ') +
3080
      color(test.speed, '%dms');
3081
    cursor.CR();
3082
    console.log(fmt, test.fullTitle(), test.duration);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3083
  });
3084
3085
  runner.on('fail', function (test) {
3086
    cursor.CR();
3087
    console.log(color('fail', '  %d) %s'), ++n, test.fullTitle());
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3088
  });
3089
3090
  runner.on('end', self.epilogue.bind(self));
3091
}
3092
3093
/**
3094
 * Inherit from `Base.prototype`.
3095
 */
3096
inherits(List, Base);
3097
3098
}).call(this,require('_process'))
3099
},{"../utils":36,"./base":16,"_process":55}],25:[function(require,module,exports){
3100
(function (process){
3101
'use strict';
3102
3103
/**
3104
 * Module dependencies.
3105
 */
3106
3107
var Base = require('./base');
3108
var utils = require('../utils');
3109
3110
/**
3111
 * Constants
3112
 */
3113
3114
var SUITE_PREFIX = '$';
3115
3116
/**
3117
 * Expose `Markdown`.
3118
 */
3119
3120
exports = module.exports = Markdown;
3121
3122
/**
3123
 * Initialize a new `Markdown` reporter.
3124
 *
3125
 * @api public
3126
 * @param {Runner} runner
3127
 */
3128 View Code Duplication
function Markdown (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3129
  Base.call(this, runner);
3130
3131
  var level = 0;
3132
  var buf = '';
3133
3134
  function title (str) {
3135
    return Array(level).join('#') + ' ' + str;
3136
  }
3137
3138
  function mapTOC (suite, obj) {
3139
    var ret = obj;
3140
    var key = SUITE_PREFIX + suite.title;
3141
3142
    obj = obj[key] = obj[key] || { suite: suite };
3143
    suite.suites.forEach(function (suite) {
3144
      mapTOC(suite, obj);
3145
    });
3146
3147
    return ret;
3148
  }
3149
3150
  function stringifyTOC (obj, level) {
3151
    ++level;
3152
    var buf = '';
3153
    var link;
3154
    for (var key in obj) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3155
      if (key === 'suite') {
3156
        continue;
3157
      }
3158
      if (key !== SUITE_PREFIX) {
3159
        link = ' - [' + key.substring(1) + ']';
3160
        link += '(#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
3161
        buf += Array(level).join('  ') + link;
3162
      }
3163
      buf += stringifyTOC(obj[key], level);
3164
    }
3165
    return buf;
3166
  }
3167
3168
  function generateTOC (suite) {
3169
    var obj = mapTOC(suite, {});
3170
    return stringifyTOC(obj, 0);
3171
  }
3172
3173
  generateTOC(runner.suite);
3174
3175
  runner.on('suite', function (suite) {
3176
    ++level;
3177
    var slug = utils.slug(suite.fullTitle());
3178
    buf += '<a name="' + slug + '"></a>' + '\n';
3179
    buf += title(suite.title) + '\n';
3180
  });
3181
3182
  runner.on('suite end', function () {
3183
    --level;
3184
  });
3185
3186
  runner.on('pass', function (test) {
3187
    var code = utils.clean(test.body);
3188
    buf += test.title + '.\n';
3189
    buf += '\n```js\n';
3190
    buf += code + '\n';
3191
    buf += '```\n\n';
3192
  });
3193
3194
  runner.on('end', function () {
3195
    process.stdout.write('# TOC\n');
3196
    process.stdout.write(generateTOC(runner.suite));
3197
    process.stdout.write(buf);
3198
  });
3199
}
3200
3201
}).call(this,require('_process'))
3202
},{"../utils":36,"./base":16,"_process":55}],26:[function(require,module,exports){
3203
(function (process){
3204
'use strict';
3205
3206
/**
3207
 * Module dependencies.
3208
 */
3209
3210
var Base = require('./base');
3211
var inherits = require('../utils').inherits;
3212
3213
/**
3214
 * Expose `Min`.
3215
 */
3216
3217
exports = module.exports = Min;
3218
3219
/**
3220
 * Initialize a new `Min` minimal test reporter (best used with --watch).
3221
 *
3222
 * @api public
3223
 * @param {Runner} runner
3224
 */
3225
function Min (runner) {
3226
  Base.call(this, runner);
3227
3228
  runner.on('start', function () {
3229
    // clear screen
3230
    process.stdout.write('\u001b[2J');
3231
    // set cursor position
3232
    process.stdout.write('\u001b[1;3H');
3233
  });
3234
3235
  runner.on('end', this.epilogue.bind(this));
3236
}
3237
3238
/**
3239
 * Inherit from `Base.prototype`.
3240
 */
3241
inherits(Min, Base);
3242
3243
}).call(this,require('_process'))
3244
},{"../utils":36,"./base":16,"_process":55}],27:[function(require,module,exports){
3245
(function (process){
3246
'use strict';
3247
3248
/**
3249
 * Module dependencies.
3250
 */
3251
3252
var Base = require('./base');
3253
var inherits = require('../utils').inherits;
3254
3255
/**
3256
 * Expose `Dot`.
3257
 */
3258
3259
exports = module.exports = NyanCat;
3260
3261
/**
3262
 * Initialize a new `Dot` matrix test reporter.
3263
 *
3264
 * @param {Runner} runner
3265
 * @api public
3266
 */
3267
3268 View Code Duplication
function NyanCat (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3269
  Base.call(this, runner);
3270
3271
  var self = this;
3272
  var width = Base.window.width * 0.75 | 0;
3273
  var nyanCatWidth = this.nyanCatWidth = 11;
3274
3275
  this.colorIndex = 0;
3276
  this.numberOfLines = 4;
3277
  this.rainbowColors = self.generateColors();
3278
  this.scoreboardWidth = 5;
3279
  this.tick = 0;
3280
  this.trajectories = [[], [], [], []];
3281
  this.trajectoryWidthMax = (width - nyanCatWidth);
3282
3283
  runner.on('start', function () {
3284
    Base.cursor.hide();
3285
    self.draw();
3286
  });
3287
3288
  runner.on('pending', function () {
3289
    self.draw();
3290
  });
3291
3292
  runner.on('pass', function () {
3293
    self.draw();
3294
  });
3295
3296
  runner.on('fail', function () {
3297
    self.draw();
3298
  });
3299
3300
  runner.on('end', function () {
3301
    Base.cursor.show();
3302
    for (var i = 0; i < self.numberOfLines; i++) {
3303
      write('\n');
3304
    }
3305
    self.epilogue();
3306
  });
3307
}
3308
3309
/**
3310
 * Inherit from `Base.prototype`.
3311
 */
3312
inherits(NyanCat, Base);
3313
3314
/**
3315
 * Draw the nyan cat
3316
 *
3317
 * @api private
3318
 */
3319
3320
NyanCat.prototype.draw = function () {
3321
  this.appendRainbow();
3322
  this.drawScoreboard();
3323
  this.drawRainbow();
3324
  this.drawNyanCat();
3325
  this.tick = !this.tick;
3326
};
3327
3328
/**
3329
 * Draw the "scoreboard" showing the number
3330
 * of passes, failures and pending tests.
3331
 *
3332
 * @api private
3333
 */
3334
3335
NyanCat.prototype.drawScoreboard = function () {
3336
  var stats = this.stats;
3337
3338
  function draw (type, n) {
3339
    write(' ');
3340
    write(Base.color(type, n));
3341
    write('\n');
3342
  }
3343
3344
  draw('green', stats.passes);
3345
  draw('fail', stats.failures);
3346
  draw('pending', stats.pending);
3347
  write('\n');
3348
3349
  this.cursorUp(this.numberOfLines);
3350
};
3351
3352
/**
3353
 * Append the rainbow.
3354
 *
3355
 * @api private
3356
 */
3357
3358
NyanCat.prototype.appendRainbow = function () {
3359
  var segment = this.tick ? '_' : '-';
3360
  var rainbowified = this.rainbowify(segment);
3361
3362
  for (var index = 0; index < this.numberOfLines; index++) {
3363
    var trajectory = this.trajectories[index];
3364
    if (trajectory.length >= this.trajectoryWidthMax) {
3365
      trajectory.shift();
3366
    }
3367
    trajectory.push(rainbowified);
3368
  }
3369
};
3370
3371
/**
3372
 * Draw the rainbow.
3373
 *
3374
 * @api private
3375
 */
3376
3377
NyanCat.prototype.drawRainbow = function () {
3378
  var self = this;
3379
3380
  this.trajectories.forEach(function (line) {
3381
    write('\u001b[' + self.scoreboardWidth + 'C');
3382
    write(line.join(''));
3383
    write('\n');
3384
  });
3385
3386
  this.cursorUp(this.numberOfLines);
3387
};
3388
3389
/**
3390
 * Draw the nyan cat
3391
 *
3392
 * @api private
3393
 */
3394 View Code Duplication
NyanCat.prototype.drawNyanCat = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3395
  var self = this;
3396
  var startWidth = this.scoreboardWidth + this.trajectories[0].length;
3397
  var dist = '\u001b[' + startWidth + 'C';
3398
  var padding = '';
3399
3400
  write(dist);
3401
  write('_,------,');
3402
  write('\n');
3403
3404
  write(dist);
3405
  padding = self.tick ? '  ' : '   ';
3406
  write('_|' + padding + '/\\_/\\ ');
3407
  write('\n');
3408
3409
  write(dist);
3410
  padding = self.tick ? '_' : '__';
3411
  var tail = self.tick ? '~' : '^';
3412
  write(tail + '|' + padding + this.face() + ' ');
3413
  write('\n');
3414
3415
  write(dist);
3416
  padding = self.tick ? ' ' : '  ';
3417
  write(padding + '""  "" ');
3418
  write('\n');
3419
3420
  this.cursorUp(this.numberOfLines);
3421
};
3422
3423
/**
3424
 * Draw nyan cat face.
3425
 *
3426
 * @api private
3427
 * @return {string}
3428
 */
3429
3430
NyanCat.prototype.face = function () {
3431
  var stats = this.stats;
3432
  if (stats.failures) {
3433
    return '( x .x)';
3434
  } else if (stats.pending) {
3435
    return '( o .o)';
3436
  } else if (stats.passes) {
3437
    return '( ^ .^)';
3438
  }
3439
  return '( - .-)';
3440
};
3441
3442
/**
3443
 * Move cursor up `n`.
3444
 *
3445
 * @api private
3446
 * @param {number} n
3447
 */
3448
3449
NyanCat.prototype.cursorUp = function (n) {
3450
  write('\u001b[' + n + 'A');
3451
};
3452
3453
/**
3454
 * Move cursor down `n`.
3455
 *
3456
 * @api private
3457
 * @param {number} n
3458
 */
3459
3460
NyanCat.prototype.cursorDown = function (n) {
3461
  write('\u001b[' + n + 'B');
3462
};
3463
3464
/**
3465
 * Generate rainbow colors.
3466
 *
3467
 * @api private
3468
 * @return {Array}
3469
 */
3470 View Code Duplication
NyanCat.prototype.generateColors = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3471
  var colors = [];
3472
3473
  for (var i = 0; i < (6 * 7); i++) {
3474
    var pi3 = Math.floor(Math.PI / 3);
3475
    var n = (i * (1.0 / 6));
3476
    var r = Math.floor(3 * Math.sin(n) + 3);
3477
    var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
3478
    var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
3479
    colors.push(36 * r + 6 * g + b + 16);
3480
  }
3481
3482
  return colors;
3483
};
3484
3485
/**
3486
 * Apply rainbow to the given `str`.
3487
 *
3488
 * @api private
3489
 * @param {string} str
3490
 * @return {string}
3491
 */
3492
NyanCat.prototype.rainbowify = function (str) {
3493
  if (!Base.useColors) {
3494
    return str;
3495
  }
3496
  var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
3497
  this.colorIndex += 1;
3498
  return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
3499
};
3500
3501
/**
3502
 * Stdout helper.
3503
 *
3504
 * @param {string} string A message to write to stdout.
3505
 */
3506
function write (string) {
3507
  process.stdout.write(string);
3508
}
3509
3510
}).call(this,require('_process'))
3511
},{"../utils":36,"./base":16,"_process":55}],28:[function(require,module,exports){
3512
(function (process){
3513
'use strict';
3514
3515
/**
3516
 * Module dependencies.
3517
 */
3518
3519
var Base = require('./base');
3520
var inherits = require('../utils').inherits;
3521
var color = Base.color;
3522
var cursor = Base.cursor;
3523
3524
/**
3525
 * Expose `Progress`.
3526
 */
3527
3528
exports = module.exports = Progress;
3529
3530
/**
3531
 * General progress bar color.
3532
 */
3533
3534
Base.colors.progress = 90;
3535
3536
/**
3537
 * Initialize a new `Progress` bar test reporter.
3538
 *
3539
 * @api public
3540
 * @param {Runner} runner
3541
 * @param {Object} options
3542
 */
3543 View Code Duplication
function Progress (runner, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3544
  Base.call(this, runner);
3545
3546
  var self = this;
3547
  var width = Base.window.width * 0.50 | 0;
3548
  var total = runner.total;
3549
  var complete = 0;
3550
  var lastN = -1;
3551
3552
  // default chars
3553
  options = options || {};
3554
  options.open = options.open || '[';
3555
  options.complete = options.complete || '▬';
3556
  options.incomplete = options.incomplete || Base.symbols.dot;
3557
  options.close = options.close || ']';
3558
  options.verbose = false;
3559
3560
  // tests started
3561
  runner.on('start', function () {
3562
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3563
    cursor.hide();
3564
  });
3565
3566
  // tests complete
3567
  runner.on('test end', function () {
3568
    complete++;
3569
3570
    var percent = complete / total;
3571
    var n = width * percent | 0;
3572
    var i = width - n;
3573
3574
    if (n === lastN && !options.verbose) {
3575
      // Don't re-render the line if it hasn't changed
3576
      return;
3577
    }
3578
    lastN = n;
3579
3580
    cursor.CR();
3581
    process.stdout.write('\u001b[J');
3582
    process.stdout.write(color('progress', '  ' + options.open));
3583
    process.stdout.write(Array(n).join(options.complete));
3584
    process.stdout.write(Array(i).join(options.incomplete));
3585
    process.stdout.write(color('progress', options.close));
3586
    if (options.verbose) {
3587
      process.stdout.write(color('progress', ' ' + complete + ' of ' + total));
3588
    }
3589
  });
3590
3591
  // tests are complete, output some stats
3592
  // and the failures if any
3593
  runner.on('end', function () {
3594
    cursor.show();
3595
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3596
    self.epilogue();
3597
  });
3598
}
3599
3600
/**
3601
 * Inherit from `Base.prototype`.
3602
 */
3603
inherits(Progress, Base);
3604
3605
}).call(this,require('_process'))
3606
},{"../utils":36,"./base":16,"_process":55}],29:[function(require,module,exports){
3607
'use strict';
3608
3609
/**
3610
 * Module dependencies.
3611
 */
3612
3613
var Base = require('./base');
3614
var inherits = require('../utils').inherits;
3615
var color = Base.color;
3616
3617
/**
3618
 * Expose `Spec`.
3619
 */
3620
3621
exports = module.exports = Spec;
0 ignored issues
show
Unused Code introduced by
The assignment to variable exports seems to be never used. Consider removing it.
Loading history...
3622
3623
/**
3624
 * Initialize a new `Spec` test reporter.
3625
 *
3626
 * @api public
3627
 * @param {Runner} runner
3628
 */
3629 View Code Duplication
function Spec (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3630
  Base.call(this, runner);
3631
3632
  var self = this;
3633
  var indents = 0;
3634
  var n = 0;
3635
3636
  function indent () {
3637
    return Array(indents).join('  ');
3638
  }
3639
3640
  runner.on('start', function () {
3641
    console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3642
  });
3643
3644
  runner.on('suite', function (suite) {
3645
    ++indents;
3646
    console.log(color('suite', '%s%s'), indent(), suite.title);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3647
  });
3648
3649
  runner.on('suite end', function () {
3650
    --indents;
3651
    if (indents === 1) {
3652
      console.log();
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3653
    }
3654
  });
3655
3656
  runner.on('pending', function (test) {
3657
    var fmt = indent() + color('pending', '  - %s');
3658
    console.log(fmt, test.title);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3659
  });
3660
3661
  runner.on('pass', function (test) {
3662
    var fmt;
3663
    if (test.speed === 'fast') {
3664
      fmt = indent() +
3665
        color('checkmark', '  ' + Base.symbols.ok) +
3666
        color('pass', ' %s');
3667
      console.log(fmt, test.title);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3668
    } else {
3669
      fmt = indent() +
3670
        color('checkmark', '  ' + Base.symbols.ok) +
3671
        color('pass', ' %s') +
3672
        color(test.speed, ' (%dms)');
3673
      console.log(fmt, test.title, test.duration);
3674
    }
3675
  });
3676
3677
  runner.on('fail', function (test) {
3678
    console.log(indent() + color('fail', '  %d) %s'), ++n, test.title);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3679
  });
3680
3681
  runner.on('end', self.epilogue.bind(self));
3682
}
3683
3684
/**
3685
 * Inherit from `Base.prototype`.
3686
 */
3687
inherits(Spec, Base);
3688
3689
},{"../utils":36,"./base":16}],30:[function(require,module,exports){
3690
'use strict';
3691
3692
/**
3693
 * Module dependencies.
3694
 */
3695
3696
var Base = require('./base');
3697
3698
/**
3699
 * Expose `TAP`.
3700
 */
3701
3702
exports = module.exports = TAP;
0 ignored issues
show
Unused Code introduced by
The assignment to variable exports seems to be never used. Consider removing it.
Loading history...
3703
3704
/**
3705
 * Initialize a new `TAP` reporter.
3706
 *
3707
 * @api public
3708
 * @param {Runner} runner
3709
 */
3710 View Code Duplication
function TAP (runner) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3711
  Base.call(this, runner);
3712
3713
  var n = 1;
3714
  var passes = 0;
3715
  var failures = 0;
3716
3717
  runner.on('start', function () {
3718
    var total = runner.grepTotal(runner.suite);
3719
    console.log('%d..%d', 1, total);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3720
  });
3721
3722
  runner.on('test end', function () {
3723
    ++n;
3724
  });
3725
3726
  runner.on('pending', function (test) {
3727
    console.log('ok %d %s # SKIP -', n, title(test));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3728
  });
3729
3730
  runner.on('pass', function (test) {
3731
    passes++;
3732
    console.log('ok %d %s', n, title(test));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3733
  });
3734
3735
  runner.on('fail', function (test, err) {
3736
    failures++;
3737
    console.log('not ok %d %s', n, title(test));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3738
    if (err.stack) {
3739
      console.log(err.stack.replace(/^/gm, '  '));
3740
    }
3741
  });
3742
3743
  runner.on('end', function () {
3744
    console.log('# tests ' + (passes + failures));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3745
    console.log('# pass ' + passes);
3746
    console.log('# fail ' + failures);
3747
  });
3748
}
3749
3750
/**
3751
 * Return a TAP-safe title of `test`
3752
 *
3753
 * @api private
3754
 * @param {Object} test
3755
 * @return {String}
3756
 */
3757
function title (test) {
3758
  return test.fullTitle().replace(/#/g, '');
3759
}
3760
3761
},{"./base":16}],31:[function(require,module,exports){
3762
(function (process,global){
3763
'use strict';
3764
3765
/**
3766
 * Module dependencies.
3767
 */
3768
3769
var Base = require('./base');
3770
var utils = require('../utils');
3771
var inherits = utils.inherits;
3772
var fs = require('fs');
3773
var escape = utils.escape;
3774
var mkdirp = require('mkdirp');
3775
var path = require('path');
3776
3777
/**
3778
 * Save timer references to avoid Sinon interfering (see GH-237).
3779
 */
3780
3781
/* eslint-disable no-unused-vars, no-native-reassign */
3782
var Date = global.Date;
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Date. This makes code hard to read, consider using a different name.
Loading history...
3783
var setTimeout = global.setTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setTimeout seems to be never used. Consider removing it.
Loading history...
3784
var setInterval = global.setInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setInterval seems to be never used. Consider removing it.
Loading history...
3785
var clearTimeout = global.clearTimeout;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearTimeout seems to be never used. Consider removing it.
Loading history...
3786
var clearInterval = global.clearInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearInterval seems to be never used. Consider removing it.
Loading history...
3787
/* eslint-enable no-unused-vars, no-native-reassign */
3788
3789
/**
3790
 * Expose `XUnit`.
3791
 */
3792
3793
exports = module.exports = XUnit;
3794
3795
/**
3796
 * Initialize a new `XUnit` reporter.
3797
 *
3798
 * @api public
3799
 * @param {Runner} runner
3800
 */
3801 View Code Duplication
function XUnit (runner, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3802
  Base.call(this, runner);
3803
3804
  var stats = this.stats;
3805
  var tests = [];
3806
  var self = this;
3807
3808
  // the name of the test suite, as it will appear in the resulting XML file
3809
  var suiteName;
3810
3811
  // the default name of the test suite if none is provided
3812
  var DEFAULT_SUITE_NAME = 'Mocha Tests';
3813
3814
  if (options && options.reporterOptions) {
3815
    if (options.reporterOptions.output) {
3816
      if (!fs.createWriteStream) {
3817
        throw new Error('file output not supported in browser');
3818
      }
3819
3820
      mkdirp.sync(path.dirname(options.reporterOptions.output));
3821
      self.fileStream = fs.createWriteStream(options.reporterOptions.output);
3822
    }
3823
3824
    // get the suite name from the reporter options (if provided)
3825
    suiteName = options.reporterOptions.suiteName;
3826
  }
3827
3828
  // fall back to the default suite name
3829
  suiteName = suiteName || DEFAULT_SUITE_NAME;
3830
3831
  runner.on('pending', function (test) {
3832
    tests.push(test);
3833
  });
3834
3835
  runner.on('pass', function (test) {
3836
    tests.push(test);
3837
  });
3838
3839
  runner.on('fail', function (test) {
3840
    tests.push(test);
3841
  });
3842
3843
  runner.on('end', function () {
3844
    self.write(tag('testsuite', {
3845
      name: suiteName,
3846
      tests: stats.tests,
3847
      failures: stats.failures,
3848
      errors: stats.failures,
3849
      skipped: stats.tests - stats.failures - stats.passes,
3850
      timestamp: (new Date()).toUTCString(),
3851
      time: (stats.duration / 1000) || 0
3852
    }, false));
3853
3854
    tests.forEach(function (t) {
3855
      self.test(t);
3856
    });
3857
3858
    self.write('</testsuite>');
3859
  });
3860
}
3861
3862
/**
3863
 * Inherit from `Base.prototype`.
3864
 */
3865
inherits(XUnit, Base);
3866
3867
/**
3868
 * Override done to close the stream (if it's a file).
3869
 *
3870
 * @param failures
3871
 * @param {Function} fn
3872
 */
3873
XUnit.prototype.done = function (failures, fn) {
3874
  if (this.fileStream) {
3875
    this.fileStream.end(function () {
3876
      fn(failures);
3877
    });
3878
  } else {
3879
    fn(failures);
3880
  }
3881
};
3882
3883
/**
3884
 * Write out the given line.
3885
 *
3886
 * @param {string} line
3887
 */
3888
XUnit.prototype.write = function (line) {
3889
  if (this.fileStream) {
3890
    this.fileStream.write(line + '\n');
3891
  } else if (typeof process === 'object' && process.stdout) {
3892
    process.stdout.write(line + '\n');
3893
  } else {
3894
    console.log(line);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
3895
  }
3896
};
3897
3898
/**
3899
 * Output tag for the given `test.`
3900
 *
3901
 * @param {Test} test
3902
 */
3903
XUnit.prototype.test = function (test) {
3904
  var attrs = {
3905
    classname: test.parent.fullTitle(),
3906
    name: test.title,
3907
    time: (test.duration / 1000) || 0
3908
  };
3909
3910
  if (test.state === 'failed') {
3911
    var err = test.err;
3912
    this.write(tag('testcase', attrs, false, tag('failure', {}, false, escape(err.message) + '\n' + escape(err.stack))));
3913
  } else if (test.isPending()) {
3914
    this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
3915
  } else {
3916
    this.write(tag('testcase', attrs, true));
3917
  }
3918
};
3919
3920
/**
3921
 * HTML tag helper.
3922
 *
3923
 * @param name
3924
 * @param attrs
3925
 * @param close
3926
 * @param content
3927
 * @return {string}
3928
 */
3929 View Code Duplication
function tag (name, attrs, close, content) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3930
  var end = close ? '/>' : '>';
3931
  var pairs = [];
3932
  var tag;
3933
3934
  for (var key in attrs) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
3935
    if (Object.prototype.hasOwnProperty.call(attrs, key)) {
3936
      pairs.push(key + '="' + escape(attrs[key]) + '"');
3937
    }
3938
  }
3939
3940
  tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
3941
  if (content) {
3942
    tag += content + '</' + name + end;
3943
  }
3944
  return tag;
3945
}
3946
3947
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
3948
},{"../utils":36,"./base":16,"_process":55,"fs":40,"mkdirp":52,"path":40}],32:[function(require,module,exports){
3949
(function (global){
3950
'use strict';
3951
3952
/**
3953
 * Module dependencies.
3954
 */
3955
3956
var EventEmitter = require('events').EventEmitter;
3957
var Pending = require('./pending');
3958
var debug = require('debug')('mocha:runnable');
3959
var milliseconds = require('./ms');
3960
var utils = require('./utils');
3961
3962
/**
3963
 * Save timer references to avoid Sinon interfering (see GH-237).
3964
 */
3965
3966
/* eslint-disable no-unused-vars, no-native-reassign */
3967
var Date = global.Date;
0 ignored issues
show
Comprehensibility introduced by
You are shadowing the built-in type Date. This makes code hard to read, consider using a different name.
Loading history...
3968
var setTimeout = global.setTimeout;
3969
var setInterval = global.setInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable setInterval seems to be never used. Consider removing it.
Loading history...
3970
var clearTimeout = global.clearTimeout;
3971
var clearInterval = global.clearInterval;
0 ignored issues
show
Unused Code introduced by
The assignment to variable clearInterval seems to be never used. Consider removing it.
Loading history...
3972
/* eslint-enable no-unused-vars, no-native-reassign */
3973
3974
/**
3975
 * Object#toString().
3976
 */
3977
3978
var toString = Object.prototype.toString;
3979
3980
/**
3981
 * Expose `Runnable`.
3982
 */
3983
3984
module.exports = Runnable;
3985
3986
/**
3987
 * Initialize a new `Runnable` with the given `title` and callback `fn`.
3988
 *
3989
 * @param {String} title
3990
 * @param {Function} fn
3991
 * @api private
3992
 * @param {string} title
3993
 * @param {Function} fn
3994
 */
3995 View Code Duplication
function Runnable (title, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3996
  this.title = title;
3997
  this.fn = fn;
3998
  this.body = (fn || '').toString();
3999
  this.async = fn && fn.length;
4000
  this.sync = !this.async;
4001
  this._timeout = 2000;
4002
  this._slow = 75;
4003
  this._enableTimeouts = true;
4004
  this.timedOut = false;
4005
  this._trace = new Error('done() called multiple times');
4006
  this._retries = -1;
4007
  this._currentRetry = 0;
4008
  this.pending = false;
4009
}
4010
4011
/**
4012
 * Inherit from `EventEmitter.prototype`.
4013
 */
4014
utils.inherits(Runnable, EventEmitter);
4015
4016
/**
4017
 * Set & get timeout `ms`.
4018
 *
4019
 * @api private
4020
 * @param {number|string} ms
4021
 * @return {Runnable|number} ms or Runnable instance.
4022
 */
4023 View Code Duplication
Runnable.prototype.timeout = function (ms) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4024
  if (!arguments.length) {
4025
    return this._timeout;
4026
  }
4027
  // see #1652 for reasoning
4028
  if (ms === 0 || ms > Math.pow(2, 31)) {
4029
    this._enableTimeouts = false;
4030
  }
4031
  if (typeof ms === 'string') {
4032
    ms = milliseconds(ms);
4033
  }
4034
  debug('timeout %d', ms);
4035
  this._timeout = ms;
4036
  if (this.timer) {
4037
    this.resetTimeout();
4038
  }
4039
  return this;
4040
};
4041
4042
/**
4043
 * Set & get slow `ms`.
4044
 *
4045
 * @api private
4046
 * @param {number|string} ms
4047
 * @return {Runnable|number} ms or Runnable instance.
4048
 */
4049
Runnable.prototype.slow = function (ms) {
4050
  if (typeof ms === 'undefined') {
4051
    return this._slow;
4052
  }
4053
  if (typeof ms === 'string') {
4054
    ms = milliseconds(ms);
4055
  }
4056
  debug('timeout %d', ms);
4057
  this._slow = ms;
4058
  return this;
4059
};
4060
4061
/**
4062
 * Set and get whether timeout is `enabled`.
4063
 *
4064
 * @api private
4065
 * @param {boolean} enabled
4066
 * @return {Runnable|boolean} enabled or Runnable instance.
4067
 */
4068
Runnable.prototype.enableTimeouts = function (enabled) {
4069
  if (!arguments.length) {
4070
    return this._enableTimeouts;
4071
  }
4072
  debug('enableTimeouts %s', enabled);
4073
  this._enableTimeouts = enabled;
4074
  return this;
4075
};
4076
4077
/**
4078
 * Halt and mark as pending.
4079
 *
4080
 * @api public
4081
 */
4082
Runnable.prototype.skip = function () {
4083
  throw new Pending('sync skip');
4084
};
4085
4086
/**
4087
 * Check if this runnable or its parent suite is marked as pending.
4088
 *
4089
 * @api private
4090
 */
4091
Runnable.prototype.isPending = function () {
4092
  return this.pending || (this.parent && this.parent.isPending());
4093
};
4094
4095
/**
4096
 * Set number of retries.
4097
 *
4098
 * @api private
4099
 */
4100
Runnable.prototype.retries = function (n) {
4101
  if (!arguments.length) {
4102
    return this._retries;
4103
  }
4104
  this._retries = n;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4105
};
4106
4107
/**
4108
 * Get current retry
4109
 *
4110
 * @api private
4111
 */
4112
Runnable.prototype.currentRetry = function (n) {
4113
  if (!arguments.length) {
4114
    return this._currentRetry;
4115
  }
4116
  this._currentRetry = n;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4117
};
4118
4119
/**
4120
 * Return the full title generated by recursively concatenating the parent's
4121
 * full title.
4122
 *
4123
 * @api public
4124
 * @return {string}
4125
 */
4126
Runnable.prototype.fullTitle = function () {
4127
  return this.titlePath().join(' ');
4128
};
4129
4130
/**
4131
 * Return the title path generated by concatenating the parent's title path with the title.
4132
 *
4133
 * @api public
4134
 * @return {string}
4135
 */
4136
Runnable.prototype.titlePath = function () {
4137
  return this.parent.titlePath().concat([this.title]);
4138
};
4139
4140
/**
4141
 * Clear the timeout.
4142
 *
4143
 * @api private
4144
 */
4145
Runnable.prototype.clearTimeout = function () {
4146
  clearTimeout(this.timer);
4147
};
4148
4149
/**
4150
 * Inspect the runnable void of private properties.
4151
 *
4152
 * @api private
4153
 * @return {string}
4154
 */
4155
Runnable.prototype.inspect = function () {
4156
  return JSON.stringify(this, function (key, val) {
4157
    if (key[0] === '_') {
4158
      return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4159
    }
4160
    if (key === 'parent') {
4161
      return '#<Suite>';
4162
    }
4163
    if (key === 'ctx') {
4164
      return '#<Context>';
4165
    }
4166
    return val;
4167
  }, 2);
4168
};
4169
4170
/**
4171
 * Reset the timeout.
4172
 *
4173
 * @api private
4174
 */
4175 View Code Duplication
Runnable.prototype.resetTimeout = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4176
  var self = this;
4177
  var ms = this.timeout() || 1e9;
4178
4179
  if (!this._enableTimeouts) {
4180
    return;
4181
  }
4182
  this.clearTimeout();
4183
  this.timer = setTimeout(function () {
4184
    if (!self._enableTimeouts) {
4185
      return;
4186
    }
4187
    self.callback(new Error('Timeout of ' + ms +
4188
      'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.'));
4189
    self.timedOut = true;
4190
  }, ms);
4191
};
4192
4193
/**
4194
 * Whitelist a list of globals for this test run.
4195
 *
4196
 * @api private
4197
 * @param {string[]} globals
4198
 */
4199
Runnable.prototype.globals = function (globals) {
4200
  if (!arguments.length) {
4201
    return this._allowedGlobals;
4202
  }
4203
  this._allowedGlobals = globals;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4204
};
4205
4206
/**
4207
 * Run the test and invoke `fn(err)`.
4208
 *
4209
 * @param {Function} fn
4210
 * @api private
4211
 */
4212 View Code Duplication
Runnable.prototype.run = function (fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4213
  var self = this;
4214
  var start = new Date();
4215
  var ctx = this.ctx;
4216
  var finished;
4217
  var emitted;
4218
4219
  // Sometimes the ctx exists, but it is not runnable
4220
  if (ctx && ctx.runnable) {
4221
    ctx.runnable(this);
4222
  }
4223
4224
  // called multiple times
4225
  function multiple (err) {
4226
    if (emitted) {
4227
      return;
4228
    }
4229
    emitted = true;
4230
    self.emit('error', err || new Error('done() called multiple times; stacktrace may be inaccurate'));
4231
  }
4232
4233
  // finished
4234
  function done (err) {
4235
    var ms = self.timeout();
4236
    if (self.timedOut) {
4237
      return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4238
    }
4239
    if (finished) {
4240
      return multiple(err || self._trace);
4241
    }
4242
4243
    self.clearTimeout();
4244
    self.duration = new Date() - start;
4245
    finished = true;
4246
    if (!err && self.duration > ms && self._enableTimeouts) {
4247
      err = new Error('Timeout of ' + ms +
4248
      'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.');
4249
    }
4250
    fn(err);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4251
  }
4252
4253
  // for .resetTimeout()
4254
  this.callback = done;
4255
4256
  // explicit async with `done` argument
4257
  if (this.async) {
4258
    this.resetTimeout();
4259
4260
    // allows skip() to be used in an explicit async context
4261
    this.skip = function asyncSkip () {
4262
      done(new Pending('async skip call'));
4263
      // halt execution.  the Runnable will be marked pending
4264
      // by the previous call, and the uncaught handler will ignore
4265
      // the failure.
4266
      throw new Pending('async skip; aborting execution');
4267
    };
4268
4269
    if (this.allowUncaught) {
4270
      return callFnAsync(this.fn);
4271
    }
4272
    try {
4273
      callFnAsync(this.fn);
4274
    } catch (err) {
4275
      emitted = true;
4276
      done(utils.getError(err));
4277
    }
4278
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4279
  }
4280
4281
  if (this.allowUncaught) {
4282
    if (this.isPending()) {
4283
      done();
4284
    } else {
4285
      callFn(this.fn);
4286
    }
4287
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4288
  }
4289
4290
  // sync or promise-returning
4291
  try {
4292
    if (this.isPending()) {
4293
      done();
4294
    } else {
4295
      callFn(this.fn);
4296
    }
4297
  } catch (err) {
4298
    emitted = true;
4299
    done(utils.getError(err));
4300
  }
4301
4302
  function callFn (fn) {
4303
    var result = fn.call(ctx);
4304
    if (result && typeof result.then === 'function') {
4305
      self.resetTimeout();
4306
      result
4307
        .then(function () {
4308
          done();
4309
          // Return null so libraries like bluebird do not warn about
4310
          // subsequently constructed Promises.
4311
          return null;
4312
        },
4313
        function (reason) {
4314
          done(reason || new Error('Promise rejected with no or falsy reason'));
4315
        });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4316
    } else {
4317
      if (self.asyncOnly) {
4318
        return done(new Error('--async-only option in use without declaring `done()` or returning a promise'));
4319
      }
4320
4321
      done();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4322
    }
4323
  }
4324
4325
  function callFnAsync (fn) {
4326
    var result = fn.call(ctx, function (err) {
4327
      if (err instanceof Error || toString.call(err) === '[object Error]') {
4328
        return done(err);
4329
      }
4330
      if (err) {
4331
        if (Object.prototype.toString.call(err) === '[object Object]') {
4332
          return done(new Error('done() invoked with non-Error: ' +
4333
            JSON.stringify(err)));
4334
        }
4335
        return done(new Error('done() invoked with non-Error: ' + err));
4336
      }
4337
      if (result && utils.isPromise(result)) {
4338
        return done(new Error('Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'));
4339
      }
4340
4341
      done();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4342
    });
4343
  }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4344
};
4345
4346
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4347
},{"./ms":14,"./pending":15,"./utils":36,"debug":42,"events":46}],33:[function(require,module,exports){
4348
(function (process,global){
4349
'use strict';
4350
4351
/**
4352
 * Module dependencies.
4353
 */
4354
4355
var EventEmitter = require('events').EventEmitter;
4356
var Pending = require('./pending');
4357
var utils = require('./utils');
4358
var inherits = utils.inherits;
4359
var debug = require('debug')('mocha:runner');
4360
var Runnable = require('./runnable');
4361
var stackFilter = utils.stackTraceFilter();
4362
var stringify = utils.stringify;
4363
var type = utils.type;
4364
var undefinedError = utils.undefinedError;
4365
4366
/**
4367
 * Non-enumerable globals.
4368
 */
4369
4370
var globals = [
4371
  'setTimeout',
4372
  'clearTimeout',
4373
  'setInterval',
4374
  'clearInterval',
4375
  'XMLHttpRequest',
4376
  'Date',
4377
  'setImmediate',
4378
  'clearImmediate'
4379
];
4380
4381
/**
4382
 * Expose `Runner`.
4383
 */
4384
4385
module.exports = Runner;
4386
4387
/**
4388
 * Initialize a `Runner` for the given `suite`.
4389
 *
4390
 * Events:
4391
 *
4392
 *   - `start`  execution started
4393
 *   - `end`  execution complete
4394
 *   - `suite`  (suite) test suite execution started
4395
 *   - `suite end`  (suite) all tests (and sub-suites) have finished
4396
 *   - `test`  (test) test execution started
4397
 *   - `test end`  (test) test completed
4398
 *   - `hook`  (hook) hook execution started
4399
 *   - `hook end`  (hook) hook complete
4400
 *   - `pass`  (test) test passed
4401
 *   - `fail`  (test, err) test failed
4402
 *   - `pending`  (test) test pending
4403
 *
4404
 * @api public
4405
 * @param {Suite} suite Root suite
4406
 * @param {boolean} [delay] Whether or not to delay execution of root suite
4407
 * until ready.
4408
 */
4409
function Runner (suite, delay) {
4410
  var self = this;
4411
  this._globals = [];
4412
  this._abort = false;
4413
  this._delay = delay;
4414
  this.suite = suite;
4415
  this.started = false;
4416
  this.total = suite.total();
4417
  this.failures = 0;
4418
  this.on('test end', function (test) {
4419
    self.checkGlobals(test);
4420
  });
4421
  this.on('hook end', function (hook) {
4422
    self.checkGlobals(hook);
4423
  });
4424
  this._defaultGrep = /.*/;
4425
  this.grep(this._defaultGrep);
4426
  this.globals(this.globalProps().concat(extraGlobals()));
4427
}
4428
4429
/**
4430
 * Wrapper for setImmediate, process.nextTick, or browser polyfill.
4431
 *
4432
 * @param {Function} fn
4433
 * @api private
4434
 */
4435
Runner.immediately = global.setImmediate || process.nextTick;
4436
4437
/**
4438
 * Inherit from `EventEmitter.prototype`.
4439
 */
4440
inherits(Runner, EventEmitter);
4441
4442
/**
4443
 * Run tests with full titles matching `re`. Updates runner.total
4444
 * with number of tests matched.
4445
 *
4446
 * @param {RegExp} re
4447
 * @param {Boolean} invert
4448
 * @return {Runner} for chaining
4449
 * @api public
4450
 * @param {RegExp} re
4451
 * @param {boolean} invert
4452
 * @return {Runner} Runner instance.
4453
 */
4454
Runner.prototype.grep = function (re, invert) {
4455
  debug('grep %s', re);
4456
  this._grep = re;
4457
  this._invert = invert;
4458
  this.total = this.grepTotal(this.suite);
4459
  return this;
4460
};
4461
4462
/**
4463
 * Returns the number of tests matching the grep search for the
4464
 * given suite.
4465
 *
4466
 * @param {Suite} suite
4467
 * @return {Number}
4468
 * @api public
4469
 * @param {Suite} suite
4470
 * @return {number}
4471
 */
4472
Runner.prototype.grepTotal = function (suite) {
4473
  var self = this;
4474
  var total = 0;
4475
4476
  suite.eachTest(function (test) {
4477
    var match = self._grep.test(test.fullTitle());
4478
    if (self._invert) {
4479
      match = !match;
4480
    }
4481
    if (match) {
4482
      total++;
4483
    }
4484
  });
4485
4486
  return total;
4487
};
4488
4489
/**
4490
 * Return a list of global properties.
4491
 *
4492
 * @return {Array}
4493
 * @api private
4494
 */
4495
Runner.prototype.globalProps = function () {
4496
  var props = Object.keys(global);
4497
4498
  // non-enumerables
4499
  for (var i = 0; i < globals.length; ++i) {
4500
    if (~props.indexOf(globals[i])) {
4501
      continue;
4502
    }
4503
    props.push(globals[i]);
4504
  }
4505
4506
  return props;
4507
};
4508
4509
/**
4510
 * Allow the given `arr` of globals.
4511
 *
4512
 * @param {Array} arr
4513
 * @return {Runner} for chaining
4514
 * @api public
4515
 * @param {Array} arr
4516
 * @return {Runner} Runner instance.
4517
 */
4518
Runner.prototype.globals = function (arr) {
4519
  if (!arguments.length) {
4520
    return this._globals;
4521
  }
4522
  debug('globals %j', arr);
4523
  this._globals = this._globals.concat(arr);
4524
  return this;
4525
};
4526
4527
/**
4528
 * Check for global variable leaks.
4529
 *
4530
 * @api private
4531
 */
4532 View Code Duplication
Runner.prototype.checkGlobals = function (test) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4533
  if (this.ignoreLeaks) {
4534
    return;
4535
  }
4536
  var ok = this._globals;
4537
4538
  var globals = this.globalProps();
4539
  var leaks;
4540
4541
  if (test) {
4542
    ok = ok.concat(test._allowedGlobals || []);
4543
  }
4544
4545
  if (this.prevGlobalsLength === globals.length) {
4546
    return;
4547
  }
4548
  this.prevGlobalsLength = globals.length;
4549
4550
  leaks = filterLeaks(ok, globals);
4551
  this._globals = this._globals.concat(leaks);
4552
4553
  if (leaks.length > 1) {
4554
    this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));
4555
  } else if (leaks.length) {
4556
    this.fail(test, new Error('global leak detected: ' + leaks[0]));
4557
  }
4558
};
4559
4560
/**
4561
 * Fail the given `test`.
4562
 *
4563
 * @api private
4564
 * @param {Test} test
4565
 * @param {Error} err
4566
 */
4567 View Code Duplication
Runner.prototype.fail = function (test, err) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4568
  if (test.isPending()) {
4569
    return;
4570
  }
4571
4572
  ++this.failures;
4573
  test.state = 'failed';
4574
4575
  if (!(err instanceof Error || (err && typeof err.message === 'string'))) {
4576
    err = new Error('the ' + type(err) + ' ' + stringify(err) + ' was thrown, throw an Error :)');
4577
  }
4578
4579
  try {
4580
    err.stack = (this.fullStackTrace || !err.stack)
4581
      ? err.stack
4582
      : stackFilter(err.stack);
4583
  } catch (ignored) {
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
4584
    // some environments do not take kindly to monkeying with the stack
4585
  }
4586
4587
  this.emit('fail', test, err);
4588
};
4589
4590
/**
4591
 * Fail the given `hook` with `err`.
4592
 *
4593
 * Hook failures work in the following pattern:
4594
 * - If bail, then exit
4595
 * - Failed `before` hook skips all tests in a suite and subsuites,
4596
 *   but jumps to corresponding `after` hook
4597
 * - Failed `before each` hook skips remaining tests in a
4598
 *   suite and jumps to corresponding `after each` hook,
4599
 *   which is run only once
4600
 * - Failed `after` hook does not alter
4601
 *   execution order
4602
 * - Failed `after each` hook skips remaining tests in a
4603
 *   suite and subsuites, but executes other `after each`
4604
 *   hooks
4605
 *
4606
 * @api private
4607
 * @param {Hook} hook
4608
 * @param {Error} err
4609
 */
4610
Runner.prototype.failHook = function (hook, err) {
4611
  if (hook.ctx && hook.ctx.currentTest) {
4612
    hook.originalTitle = hook.originalTitle || hook.title;
4613
    hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
4614
  }
4615
4616
  this.fail(hook, err);
4617
  if (this.suite.bail()) {
4618
    this.emit('end');
4619
  }
4620
};
4621
4622
/**
4623
 * Run hook `name` callbacks and then invoke `fn()`.
4624
 *
4625
 * @api private
4626
 * @param {string} name
4627
 * @param {Function} fn
4628
 */
4629
4630 View Code Duplication
Runner.prototype.hook = function (name, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4631
  var suite = this.suite;
4632
  var hooks = suite['_' + name];
4633
  var self = this;
4634
4635
  function next (i) {
4636
    var hook = hooks[i];
4637
    if (!hook) {
4638
      return fn();
4639
    }
4640
    self.currentRunnable = hook;
4641
4642
    hook.ctx.currentTest = self.test;
4643
4644
    self.emit('hook', hook);
4645
4646
    if (!hook.listeners('error').length) {
4647
      hook.on('error', function (err) {
4648
        self.failHook(hook, err);
4649
      });
4650
    }
4651
4652
    hook.run(function (err) {
4653
      var testError = hook.error();
4654
      if (testError) {
4655
        self.fail(self.test, testError);
4656
      }
4657
      if (err) {
4658
        if (err instanceof Pending) {
4659
          if (name === 'beforeEach' || name === 'afterEach') {
4660
            self.test.pending = true;
4661
          } else {
4662
            suite.tests.forEach(function (test) {
4663
              test.pending = true;
4664
            });
4665
            // a pending hook won't be executed twice.
4666
            hook.pending = true;
4667
          }
4668
        } else {
4669
          self.failHook(hook, err);
4670
4671
          // stop executing hooks, notify callee of hook err
4672
          return fn(err);
4673
        }
4674
      }
4675
      self.emit('hook end', hook);
4676
      delete hook.ctx.currentTest;
4677
      next(++i);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4678
    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4679
  }
4680
4681
  Runner.immediately(function () {
4682
    next(0);
4683
  });
4684
};
4685
4686
/**
4687
 * Run hook `name` for the given array of `suites`
4688
 * in order, and callback `fn(err, errSuite)`.
4689
 *
4690
 * @api private
4691
 * @param {string} name
4692
 * @param {Array} suites
4693
 * @param {Function} fn
4694
 */
4695
Runner.prototype.hooks = function (name, suites, fn) {
4696
  var self = this;
4697
  var orig = this.suite;
4698
4699
  function next (suite) {
4700
    self.suite = suite;
4701
4702
    if (!suite) {
4703
      self.suite = orig;
4704
      return fn();
4705
    }
4706
4707
    self.hook(name, function (err) {
4708
      if (err) {
4709
        var errSuite = self.suite;
4710
        self.suite = orig;
4711
        return fn(err, errSuite);
4712
      }
4713
4714
      next(suites.pop());
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4715
    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4716
  }
4717
4718
  next(suites.pop());
4719
};
4720
4721
/**
4722
 * Run hooks from the top level down.
4723
 *
4724
 * @param {String} name
4725
 * @param {Function} fn
4726
 * @api private
4727
 */
4728
Runner.prototype.hookUp = function (name, fn) {
4729
  var suites = [this.suite].concat(this.parents()).reverse();
4730
  this.hooks(name, suites, fn);
4731
};
4732
4733
/**
4734
 * Run hooks from the bottom up.
4735
 *
4736
 * @param {String} name
4737
 * @param {Function} fn
4738
 * @api private
4739
 */
4740
Runner.prototype.hookDown = function (name, fn) {
4741
  var suites = [this.suite].concat(this.parents());
4742
  this.hooks(name, suites, fn);
4743
};
4744
4745
/**
4746
 * Return an array of parent Suites from
4747
 * closest to furthest.
4748
 *
4749
 * @return {Array}
4750
 * @api private
4751
 */
4752
Runner.prototype.parents = function () {
4753
  var suite = this.suite;
4754
  var suites = [];
4755
  while (suite.parent) {
4756
    suite = suite.parent;
4757
    suites.push(suite);
4758
  }
4759
  return suites;
4760
};
4761
4762
/**
4763
 * Run the current test and callback `fn(err)`.
4764
 *
4765
 * @param {Function} fn
4766
 * @api private
4767
 */
4768 View Code Duplication
Runner.prototype.runTest = function (fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4769
  var self = this;
4770
  var test = this.test;
4771
4772
  if (!test) {
4773
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4774
  }
4775
  if (this.forbidOnly && hasOnly(this.parents().reverse()[0] || this.suite)) {
4776
    fn(new Error('`.only` forbidden'));
4777
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4778
  }
4779
  if (this.asyncOnly) {
4780
    test.asyncOnly = true;
4781
  }
4782
  test.on('error', function (err) {
4783
    self.fail(test, err);
4784
  });
4785
  if (this.allowUncaught) {
4786
    test.allowUncaught = true;
4787
    return test.run(fn);
4788
  }
4789
  try {
4790
    test.run(fn);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4791
  } catch (err) {
4792
    fn(err);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4793
  }
4794
};
4795
4796
/**
4797
 * Run tests in the given `suite` and invoke the callback `fn()` when complete.
4798
 *
4799
 * @api private
4800
 * @param {Suite} suite
4801
 * @param {Function} fn
4802
 */
4803 View Code Duplication
Runner.prototype.runTests = function (suite, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4804
  var self = this;
4805
  var tests = suite.tests.slice();
4806
  var test;
4807
4808
  function hookErr (_, errSuite, after) {
4809
    // before/after Each hook for errSuite failed:
4810
    var orig = self.suite;
4811
4812
    // for failed 'after each' hook start from errSuite parent,
4813
    // otherwise start from errSuite itself
4814
    self.suite = after ? errSuite.parent : errSuite;
4815
4816
    if (self.suite) {
4817
      // call hookUp afterEach
4818
      self.hookUp('afterEach', function (err2, errSuite2) {
4819
        self.suite = orig;
4820
        // some hooks may fail even now
4821
        if (err2) {
4822
          return hookErr(err2, errSuite2, true);
4823
        }
4824
        // report error suite
4825
        fn(errSuite);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4826
      });
4827
    } else {
4828
      // there is no need calling other 'after each' hooks
4829
      self.suite = orig;
4830
      fn(errSuite);
4831
    }
4832
  }
4833
4834
  function next (err, errSuite) {
4835
    // if we bail after first err
4836
    if (self.failures && suite._bail) {
4837
      return fn();
4838
    }
4839
4840
    if (self._abort) {
4841
      return fn();
4842
    }
4843
4844
    if (err) {
4845
      return hookErr(err, errSuite, true);
4846
    }
4847
4848
    // next test
4849
    test = tests.shift();
4850
4851
    // all done
4852
    if (!test) {
4853
      return fn();
4854
    }
4855
4856
    // grep
4857
    var match = self._grep.test(test.fullTitle());
4858
    if (self._invert) {
4859
      match = !match;
4860
    }
4861
    if (!match) {
4862
      // Run immediately only if we have defined a grep. When we
4863
      // define a grep — It can cause maximum callstack error if
4864
      // the grep is doing a large recursive loop by neglecting
4865
      // all tests. The run immediately function also comes with
4866
      // a performance cost. So we don't want to run immediately
4867
      // if we run the whole test suite, because running the whole
4868
      // test suite don't do any immediate recursive loops. Thus,
4869
      // allowing a JS runtime to breathe.
4870
      if (self._grep !== self._defaultGrep) {
4871
        Runner.immediately(next);
4872
      } else {
4873
        next();
4874
      }
4875
      return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
4876
    }
4877
4878
    if (test.isPending()) {
4879
      if (self.forbidPending) {
4880
        test.isPending = alwaysFalse;
4881
        self.fail(test, new Error('Pending test forbidden'));
4882
        delete test.isPending;
4883
      } else {
4884
        self.emit('pending', test);
4885
      }
4886
      self.emit('test end', test);
4887
      return next();
4888
    }
4889
4890
    // execute test and hook(s)
4891
    self.emit('test', self.test = test);
4892
    self.hookDown('beforeEach', function (err, errSuite) {
4893
      if (test.isPending()) {
4894
        if (self.forbidPending) {
4895
          test.isPending = alwaysFalse;
4896
          self.fail(test, new Error('Pending test forbidden'));
4897
          delete test.isPending;
4898
        } else {
4899
          self.emit('pending', test);
4900
        }
4901
        self.emit('test end', test);
4902
        return next();
4903
      }
4904
      if (err) {
4905
        return hookErr(err, errSuite, false);
4906
      }
4907
      self.currentRunnable = self.test;
4908
      self.runTest(function (err) {
4909
        test = self.test;
4910
        if (err) {
4911
          var retry = test.currentRetry();
4912
          if (err instanceof Pending && self.forbidPending) {
4913
            self.fail(test, new Error('Pending test forbidden'));
4914
          } else if (err instanceof Pending) {
4915
            test.pending = true;
4916
            self.emit('pending', test);
4917
          } else if (retry < test.retries()) {
4918
            var clonedTest = test.clone();
4919
            clonedTest.currentRetry(retry + 1);
4920
            tests.unshift(clonedTest);
4921
4922
            // Early return + hook trigger so that it doesn't
4923
            // increment the count wrong
4924
            return self.hookUp('afterEach', next);
4925
          } else {
4926
            self.fail(test, err);
4927
          }
4928
          self.emit('test end', test);
4929
4930
          if (err instanceof Pending) {
4931
            return next();
4932
          }
4933
4934
          return self.hookUp('afterEach', next);
4935
        }
4936
4937
        test.state = 'passed';
4938
        self.emit('pass', test);
4939
        self.emit('test end', test);
4940
        self.hookUp('afterEach', next);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4941
      });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4942
    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
4943
  }
4944
4945
  this.next = next;
4946
  this.hookErr = hookErr;
4947
  next();
4948
};
4949
4950
function alwaysFalse () {
4951
  return false;
4952
}
4953
4954
/**
4955
 * Run the given `suite` and invoke the callback `fn()` when complete.
4956
 *
4957
 * @api private
4958
 * @param {Suite} suite
4959
 * @param {Function} fn
4960
 */
4961 View Code Duplication
Runner.prototype.runSuite = function (suite, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
4962
  var i = 0;
4963
  var self = this;
4964
  var total = this.grepTotal(suite);
4965
  var afterAllHookCalled = false;
4966
4967
  debug('run suite %s', suite.fullTitle());
4968
4969
  if (!total || (self.failures && suite._bail)) {
4970
    return fn();
4971
  }
4972
4973
  this.emit('suite', this.suite = suite);
4974
4975
  function next (errSuite) {
4976
    if (errSuite) {
4977
      // current suite failed on a hook from errSuite
4978
      if (errSuite === suite) {
4979
        // if errSuite is current suite
4980
        // continue to the next sibling suite
4981
        return done();
4982
      }
4983
      // errSuite is among the parents of current suite
4984
      // stop execution of errSuite and all sub-suites
4985
      return done(errSuite);
4986
    }
4987
4988
    if (self._abort) {
4989
      return done();
4990
    }
4991
4992
    var curr = suite.suites[i++];
4993
    if (!curr) {
4994
      return done();
4995
    }
4996
4997
    // Avoid grep neglecting large number of tests causing a
4998
    // huge recursive loop and thus a maximum call stack error.
4999
    // See comment in `this.runTests()` for more information.
5000
    if (self._grep !== self._defaultGrep) {
5001
      Runner.immediately(function () {
5002
        self.runSuite(curr, next);
5003
      });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
5004
    } else {
5005
      self.runSuite(curr, next);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
5006
    }
5007
  }
5008
5009
  function done (errSuite) {
5010
    self.suite = suite;
5011
    self.nextSuite = next;
5012
5013
    if (afterAllHookCalled) {
5014
      fn(errSuite);
5015
    } else {
5016
      // mark that the afterAll block has been called once
5017
      // and so can be skipped if there is an error in it.
5018
      afterAllHookCalled = true;
5019
5020
      // remove reference to test
5021
      delete self.test;
5022
5023
      self.hook('afterAll', function () {
5024
        self.emit('suite end', suite);
5025
        fn(errSuite);
5026
      });
5027
    }
5028
  }
5029
5030
  this.nextSuite = next;
5031
5032
  this.hook('beforeAll', function (err) {
5033
    if (err) {
5034
      return done();
5035
    }
5036
    self.runTests(suite, next);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
5037
  });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
5038
};
5039
5040
/**
5041
 * Handle uncaught exceptions.
5042
 *
5043
 * @param {Error} err
5044
 * @api private
5045
 */
5046 View Code Duplication
Runner.prototype.uncaught = function (err) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5047
  if (err) {
5048
    debug('uncaught exception %s', err === (function () {
5049
      return this;
5050
    }.call(err)) ? (err.message || err) : err);
5051
  } else {
5052
    debug('uncaught undefined exception');
5053
    err = undefinedError();
5054
  }
5055
  err.uncaught = true;
5056
5057
  var runnable = this.currentRunnable;
5058
5059
  if (!runnable) {
5060
    runnable = new Runnable('Uncaught error outside test suite');
5061
    runnable.parent = this.suite;
5062
5063
    if (this.started) {
5064
      this.fail(runnable, err);
5065
    } else {
5066
      // Can't recover from this failure
5067
      this.emit('start');
5068
      this.fail(runnable, err);
5069
      this.emit('end');
5070
    }
5071
5072
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
5073
  }
5074
5075
  runnable.clearTimeout();
5076
5077
  // Ignore errors if complete or pending
5078
  if (runnable.state || runnable.isPending()) {
5079
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
5080
  }
5081
  this.fail(runnable, err);
5082
5083
  // recover from test
5084
  if (runnable.type === 'test') {
5085
    this.emit('test end', runnable);
5086
    this.hookUp('afterEach', this.next);
5087
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
5088
  }
5089
5090
  // recover from hooks
5091
  if (runnable.type === 'hook') {
5092
    var errSuite = this.suite;
5093
    // if hook failure is in afterEach block
5094
    if (runnable.fullTitle().indexOf('after each') > -1) {
5095
      return this.hookErr(err, errSuite, true);
5096
    }
5097
    // if hook failure is in beforeEach block
5098
    if (runnable.fullTitle().indexOf('before each') > -1) {
5099
      return this.hookErr(err, errSuite, false);
5100
    }
5101
    // if hook failure is in after or before blocks
5102
    return this.nextSuite(errSuite);
5103
  }
5104
5105
  // bail
5106
  this.emit('end');
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
5107
};
5108
5109
/**
5110
 * Cleans up the references to all the deferred functions
5111
 * (before/after/beforeEach/afterEach) and tests of a Suite.
5112
 * These must be deleted otherwise a memory leak can happen,
5113
 * as those functions may reference variables from closures,
5114
 * thus those variables can never be garbage collected as long
5115
 * as the deferred functions exist.
5116
 *
5117
 * @param {Suite} suite
5118
 */
5119 View Code Duplication
function cleanSuiteReferences (suite) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5120
  function cleanArrReferences (arr) {
5121
    for (var i = 0; i < arr.length; i++) {
5122
      delete arr[i].fn;
5123
    }
5124
  }
5125
5126
  if (Array.isArray(suite._beforeAll)) {
5127
    cleanArrReferences(suite._beforeAll);
5128
  }
5129
5130
  if (Array.isArray(suite._beforeEach)) {
5131
    cleanArrReferences(suite._beforeEach);
5132
  }
5133
5134
  if (Array.isArray(suite._afterAll)) {
5135
    cleanArrReferences(suite._afterAll);
5136
  }
5137
5138
  if (Array.isArray(suite._afterEach)) {
5139
    cleanArrReferences(suite._afterEach);
5140
  }
5141
5142
  for (var i = 0; i < suite.tests.length; i++) {
5143
    delete suite.tests[i].fn;
5144
  }
5145
}
5146
5147
/**
5148
 * Run the root suite and invoke `fn(failures)`
5149
 * on completion.
5150
 *
5151
 * @param {Function} fn
5152
 * @return {Runner} for chaining
5153
 * @api public
5154
 * @param {Function} fn
5155
 * @return {Runner} Runner instance.
5156
 */
5157
Runner.prototype.run = function (fn) {
5158
  var self = this;
5159
  var rootSuite = this.suite;
5160
5161
  // If there is an `only` filter
5162
  if (hasOnly(rootSuite)) {
5163
    filterOnly(rootSuite);
5164
  }
5165
5166
  fn = fn || function () {};
5167
5168
  function uncaught (err) {
5169
    self.uncaught(err);
5170
  }
5171
5172
  function start () {
5173
    self.started = true;
5174
    self.emit('start');
5175
    self.runSuite(rootSuite, function () {
5176
      debug('finished running');
5177
      self.emit('end');
5178
    });
5179
  }
5180
5181
  debug('start');
5182
5183
  // references cleanup to avoid memory leaks
5184
  this.on('suite end', cleanSuiteReferences);
5185
5186
  // callback
5187
  this.on('end', function () {
5188
    debug('end');
5189
    process.removeListener('uncaughtException', uncaught);
5190
    fn(self.failures);
5191
  });
5192
5193
  // uncaught exception
5194
  process.on('uncaughtException', uncaught);
5195
5196
  if (this._delay) {
5197
    // for reporters, I guess.
5198
    // might be nice to debounce some dots while we wait.
5199
    this.emit('waiting', rootSuite);
5200
    rootSuite.once('run', start);
5201
  } else {
5202
    start();
5203
  }
5204
5205
  return this;
5206
};
5207
5208
/**
5209
 * Cleanly abort execution.
5210
 *
5211
 * @api public
5212
 * @return {Runner} Runner instance.
5213
 */
5214
Runner.prototype.abort = function () {
5215
  debug('aborting');
5216
  this._abort = true;
5217
5218
  return this;
5219
};
5220
5221
/**
5222
 * Filter suites based on `isOnly` logic.
5223
 *
5224
 * @param {Array} suite
5225
 * @returns {Boolean}
5226
 * @api private
5227
 */
5228 View Code Duplication
function filterOnly (suite) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5229
  if (suite._onlyTests.length) {
5230
    // If the suite contains `only` tests, run those and ignore any nested suites.
5231
    suite.tests = suite._onlyTests;
5232
    suite.suites = [];
5233
  } else {
5234
    // Otherwise, do not run any of the tests in this suite.
5235
    suite.tests = [];
5236
    suite._onlySuites.forEach(function (onlySuite) {
5237
      // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
5238
      // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
5239
      if (hasOnly(onlySuite)) {
5240
        filterOnly(onlySuite);
5241
      }
5242
    });
5243
    // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
5244
    suite.suites = suite.suites.filter(function (childSuite) {
5245
      return suite._onlySuites.indexOf(childSuite) !== -1 || filterOnly(childSuite);
5246
    });
5247
  }
5248
  // Keep the suite only if there is something to run
5249
  return suite.tests.length || suite.suites.length;
5250
}
5251
5252
/**
5253
 * Determines whether a suite has an `only` test or suite as a descendant.
5254
 *
5255
 * @param {Array} suite
5256
 * @returns {Boolean}
5257
 * @api private
5258
 */
5259
function hasOnly (suite) {
5260
  return suite._onlyTests.length || suite._onlySuites.length || suite.suites.some(hasOnly);
5261
}
5262
5263
/**
5264
 * Filter leaks with the given globals flagged as `ok`.
5265
 *
5266
 * @api private
5267
 * @param {Array} ok
5268
 * @param {Array} globals
5269
 * @return {Array}
5270
 */
5271 View Code Duplication
function filterLeaks (ok, globals) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5272
  return globals.filter(function (key) {
5273
    // Firefox and Chrome exposes iframes as index inside the window object
5274
    if (/^\d+/.test(key)) {
5275
      return false;
5276
    }
5277
5278
    // in firefox
5279
    // if runner runs in an iframe, this iframe's window.getInterface method
5280
    // not init at first it is assigned in some seconds
5281
    if (global.navigator && (/^getInterface/).test(key)) {
5282
      return false;
5283
    }
5284
5285
    // an iframe could be approached by window[iframeIndex]
5286
    // in ie6,7,8 and opera, iframeIndex is enumerable, this could cause leak
5287
    if (global.navigator && (/^\d+/).test(key)) {
5288
      return false;
5289
    }
5290
5291
    // Opera and IE expose global variables for HTML element IDs (issue #243)
5292
    if (/^mocha-/.test(key)) {
5293
      return false;
5294
    }
5295
5296
    var matched = ok.filter(function (ok) {
5297
      if (~ok.indexOf('*')) {
5298
        return key.indexOf(ok.split('*')[0]) === 0;
5299
      }
5300
      return key === ok;
5301
    });
5302
    return !matched.length && (!global.navigator || key !== 'onerror');
5303
  });
5304
}
5305
5306
/**
5307
 * Array of globals dependent on the environment.
5308
 *
5309
 * @return {Array}
5310
 * @api private
5311
 */
5312 View Code Duplication
function extraGlobals () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5313
  if (typeof process === 'object' && typeof process.version === 'string') {
5314
    var parts = process.version.split('.');
5315
    var nodeVersion = parts.reduce(function (a, v) {
5316
      return a << 8 | v;
5317
    });
5318
5319
    // 'errno' was renamed to process._errno in v0.9.11.
5320
5321
    if (nodeVersion < 0x00090B) {
5322
      return ['errno'];
5323
    }
5324
  }
5325
5326
  return [];
5327
}
5328
5329
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
5330
},{"./pending":15,"./runnable":32,"./utils":36,"_process":55,"debug":42,"events":46}],34:[function(require,module,exports){
5331
'use strict';
5332
5333
/**
5334
 * Module dependencies.
5335
 */
5336
5337
var EventEmitter = require('events').EventEmitter;
5338
var Hook = require('./hook');
5339
var utils = require('./utils');
5340
var inherits = utils.inherits;
5341
var debug = require('debug')('mocha:suite');
5342
var milliseconds = require('./ms');
5343
5344
/**
5345
 * Expose `Suite`.
5346
 */
5347
5348
exports = module.exports = Suite;
5349
5350
/**
5351
 * Create a new `Suite` with the given `title` and parent `Suite`. When a suite
5352
 * with the same title is already present, that suite is returned to provide
5353
 * nicer reporter and more flexible meta-testing.
5354
 *
5355
 * @api public
5356
 * @param {Suite} parent
5357
 * @param {string} title
5358
 * @return {Suite}
5359
 */
5360
exports.create = function (parent, title) {
5361
  var suite = new Suite(title, parent.ctx);
5362
  suite.parent = parent;
5363
  title = suite.fullTitle();
0 ignored issues
show
Unused Code introduced by
The assignment to variable title seems to be never used. Consider removing it.
Loading history...
5364
  parent.addSuite(suite);
5365
  return suite;
5366
};
5367
5368
/**
5369
 * Initialize a new `Suite` with the given `title` and `ctx`.
5370
 *
5371
 * @api private
5372
 * @param {string} title
5373
 * @param {Context} parentContext
5374
 */
5375 View Code Duplication
function Suite (title, parentContext) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5376
  if (!utils.isString(title)) {
5377
    throw new Error('Suite `title` should be a "string" but "' + typeof title + '" was given instead.');
5378
  }
5379
  this.title = title;
5380
  function Context () {}
5381
  Context.prototype = parentContext;
5382
  this.ctx = new Context();
5383
  this.suites = [];
5384
  this.tests = [];
5385
  this.pending = false;
5386
  this._beforeEach = [];
5387
  this._beforeAll = [];
5388
  this._afterEach = [];
5389
  this._afterAll = [];
5390
  this.root = !title;
5391
  this._timeout = 2000;
5392
  this._enableTimeouts = true;
5393
  this._slow = 75;
5394
  this._bail = false;
5395
  this._retries = -1;
5396
  this._onlyTests = [];
5397
  this._onlySuites = [];
5398
  this.delayed = false;
5399
}
5400
5401
/**
5402
 * Inherit from `EventEmitter.prototype`.
5403
 */
5404
inherits(Suite, EventEmitter);
5405
5406
/**
5407
 * Return a clone of this `Suite`.
5408
 *
5409
 * @api private
5410
 * @return {Suite}
5411
 */
5412
Suite.prototype.clone = function () {
5413
  var suite = new Suite(this.title);
5414
  debug('clone');
5415
  suite.ctx = this.ctx;
5416
  suite.timeout(this.timeout());
5417
  suite.retries(this.retries());
5418
  suite.enableTimeouts(this.enableTimeouts());
5419
  suite.slow(this.slow());
5420
  suite.bail(this.bail());
5421
  return suite;
5422
};
5423
5424
/**
5425
 * Set timeout `ms` or short-hand such as "2s".
5426
 *
5427
 * @api private
5428
 * @param {number|string} ms
5429
 * @return {Suite|number} for chaining
5430
 */
5431
Suite.prototype.timeout = function (ms) {
5432
  if (!arguments.length) {
5433
    return this._timeout;
5434
  }
5435
  if (ms.toString() === '0') {
5436
    this._enableTimeouts = false;
5437
  }
5438
  if (typeof ms === 'string') {
5439
    ms = milliseconds(ms);
5440
  }
5441
  debug('timeout %d', ms);
5442
  this._timeout = parseInt(ms, 10);
5443
  return this;
5444
};
5445
5446
/**
5447
 * Set number of times to retry a failed test.
5448
 *
5449
 * @api private
5450
 * @param {number|string} n
5451
 * @return {Suite|number} for chaining
5452
 */
5453
Suite.prototype.retries = function (n) {
5454
  if (!arguments.length) {
5455
    return this._retries;
5456
  }
5457
  debug('retries %d', n);
5458
  this._retries = parseInt(n, 10) || 0;
5459
  return this;
5460
};
5461
5462
/**
5463
  * Set timeout to `enabled`.
5464
  *
5465
  * @api private
5466
  * @param {boolean} enabled
5467
  * @return {Suite|boolean} self or enabled
5468
  */
5469
Suite.prototype.enableTimeouts = function (enabled) {
5470
  if (!arguments.length) {
5471
    return this._enableTimeouts;
5472
  }
5473
  debug('enableTimeouts %s', enabled);
5474
  this._enableTimeouts = enabled;
5475
  return this;
5476
};
5477
5478
/**
5479
 * Set slow `ms` or short-hand such as "2s".
5480
 *
5481
 * @api private
5482
 * @param {number|string} ms
5483
 * @return {Suite|number} for chaining
5484
 */
5485
Suite.prototype.slow = function (ms) {
5486
  if (!arguments.length) {
5487
    return this._slow;
5488
  }
5489
  if (typeof ms === 'string') {
5490
    ms = milliseconds(ms);
5491
  }
5492
  debug('slow %d', ms);
5493
  this._slow = ms;
5494
  return this;
5495
};
5496
5497
/**
5498
 * Sets whether to bail after first error.
5499
 *
5500
 * @api private
5501
 * @param {boolean} bail
5502
 * @return {Suite|number} for chaining
5503
 */
5504
Suite.prototype.bail = function (bail) {
5505
  if (!arguments.length) {
5506
    return this._bail;
5507
  }
5508
  debug('bail %s', bail);
5509
  this._bail = bail;
5510
  return this;
5511
};
5512
5513
/**
5514
 * Check if this suite or its parent suite is marked as pending.
5515
 *
5516
 * @api private
5517
 */
5518
Suite.prototype.isPending = function () {
5519
  return this.pending || (this.parent && this.parent.isPending());
5520
};
5521
5522
/**
5523
 * Run `fn(test[, done])` before running tests.
5524
 *
5525
 * @api private
5526
 * @param {string} title
5527
 * @param {Function} fn
5528
 * @return {Suite} for chaining
5529
 */
5530 View Code Duplication
Suite.prototype.beforeAll = function (title, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5531
  if (this.isPending()) {
5532
    return this;
5533
  }
5534
  if (typeof title === 'function') {
5535
    fn = title;
5536
    title = fn.name;
5537
  }
5538
  title = '"before all" hook' + (title ? ': ' + title : '');
5539
5540
  var hook = new Hook(title, fn);
5541
  hook.parent = this;
5542
  hook.timeout(this.timeout());
5543
  hook.retries(this.retries());
5544
  hook.enableTimeouts(this.enableTimeouts());
5545
  hook.slow(this.slow());
5546
  hook.ctx = this.ctx;
5547
  this._beforeAll.push(hook);
5548
  this.emit('beforeAll', hook);
5549
  return this;
5550
};
5551
5552
/**
5553
 * Run `fn(test[, done])` after running tests.
5554
 *
5555
 * @api private
5556
 * @param {string} title
5557
 * @param {Function} fn
5558
 * @return {Suite} for chaining
5559
 */
5560 View Code Duplication
Suite.prototype.afterAll = function (title, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5561
  if (this.isPending()) {
5562
    return this;
5563
  }
5564
  if (typeof title === 'function') {
5565
    fn = title;
5566
    title = fn.name;
5567
  }
5568
  title = '"after all" hook' + (title ? ': ' + title : '');
5569
5570
  var hook = new Hook(title, fn);
5571
  hook.parent = this;
5572
  hook.timeout(this.timeout());
5573
  hook.retries(this.retries());
5574
  hook.enableTimeouts(this.enableTimeouts());
5575
  hook.slow(this.slow());
5576
  hook.ctx = this.ctx;
5577
  this._afterAll.push(hook);
5578
  this.emit('afterAll', hook);
5579
  return this;
5580
};
5581
5582
/**
5583
 * Run `fn(test[, done])` before each test case.
5584
 *
5585
 * @api private
5586
 * @param {string} title
5587
 * @param {Function} fn
5588
 * @return {Suite} for chaining
5589
 */
5590 View Code Duplication
Suite.prototype.beforeEach = function (title, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5591
  if (this.isPending()) {
5592
    return this;
5593
  }
5594
  if (typeof title === 'function') {
5595
    fn = title;
5596
    title = fn.name;
5597
  }
5598
  title = '"before each" hook' + (title ? ': ' + title : '');
5599
5600
  var hook = new Hook(title, fn);
5601
  hook.parent = this;
5602
  hook.timeout(this.timeout());
5603
  hook.retries(this.retries());
5604
  hook.enableTimeouts(this.enableTimeouts());
5605
  hook.slow(this.slow());
5606
  hook.ctx = this.ctx;
5607
  this._beforeEach.push(hook);
5608
  this.emit('beforeEach', hook);
5609
  return this;
5610
};
5611
5612
/**
5613
 * Run `fn(test[, done])` after each test case.
5614
 *
5615
 * @api private
5616
 * @param {string} title
5617
 * @param {Function} fn
5618
 * @return {Suite} for chaining
5619
 */
5620 View Code Duplication
Suite.prototype.afterEach = function (title, fn) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5621
  if (this.isPending()) {
5622
    return this;
5623
  }
5624
  if (typeof title === 'function') {
5625
    fn = title;
5626
    title = fn.name;
5627
  }
5628
  title = '"after each" hook' + (title ? ': ' + title : '');
5629
5630
  var hook = new Hook(title, fn);
5631
  hook.parent = this;
5632
  hook.timeout(this.timeout());
5633
  hook.retries(this.retries());
5634
  hook.enableTimeouts(this.enableTimeouts());
5635
  hook.slow(this.slow());
5636
  hook.ctx = this.ctx;
5637
  this._afterEach.push(hook);
5638
  this.emit('afterEach', hook);
5639
  return this;
5640
};
5641
5642
/**
5643
 * Add a test `suite`.
5644
 *
5645
 * @api private
5646
 * @param {Suite} suite
5647
 * @return {Suite} for chaining
5648
 */
5649
Suite.prototype.addSuite = function (suite) {
5650
  suite.parent = this;
5651
  suite.timeout(this.timeout());
5652
  suite.retries(this.retries());
5653
  suite.enableTimeouts(this.enableTimeouts());
5654
  suite.slow(this.slow());
5655
  suite.bail(this.bail());
5656
  this.suites.push(suite);
5657
  this.emit('suite', suite);
5658
  return this;
5659
};
5660
5661
/**
5662
 * Add a `test` to this suite.
5663
 *
5664
 * @api private
5665
 * @param {Test} test
5666
 * @return {Suite} for chaining
5667
 */
5668
Suite.prototype.addTest = function (test) {
5669
  test.parent = this;
5670
  test.timeout(this.timeout());
5671
  test.retries(this.retries());
5672
  test.enableTimeouts(this.enableTimeouts());
5673
  test.slow(this.slow());
5674
  test.ctx = this.ctx;
5675
  this.tests.push(test);
5676
  this.emit('test', test);
5677
  return this;
5678
};
5679
5680
/**
5681
 * Return the full title generated by recursively concatenating the parent's
5682
 * full title.
5683
 *
5684
 * @api public
5685
 * @return {string}
5686
 */
5687
Suite.prototype.fullTitle = function () {
5688
  return this.titlePath().join(' ');
5689
};
5690
5691
/**
5692
 * Return the title path generated by recursively concatenating the parent's
5693
 * title path.
5694
 *
5695
 * @api public
5696
 * @return {string}
5697
 */
5698
Suite.prototype.titlePath = function () {
5699
  var result = [];
5700
  if (this.parent) {
5701
    result = result.concat(this.parent.titlePath());
5702
  }
5703
  if (!this.root) {
5704
    result.push(this.title);
5705
  }
5706
  return result;
5707
};
5708
5709
/**
5710
 * Return the total number of tests.
5711
 *
5712
 * @api public
5713
 * @return {number}
5714
 */
5715
Suite.prototype.total = function () {
5716
  return this.suites.reduce(function (sum, suite) {
5717
    return sum + suite.total();
5718
  }, 0) + this.tests.length;
5719
};
5720
5721
/**
5722
 * Iterates through each suite recursively to find all tests. Applies a
5723
 * function in the format `fn(test)`.
5724
 *
5725
 * @api private
5726
 * @param {Function} fn
5727
 * @return {Suite}
5728
 */
5729
Suite.prototype.eachTest = function (fn) {
5730
  this.tests.forEach(fn);
5731
  this.suites.forEach(function (suite) {
5732
    suite.eachTest(fn);
5733
  });
5734
  return this;
5735
};
5736
5737
/**
5738
 * This will run the root suite if we happen to be running in delayed mode.
5739
 */
5740
Suite.prototype.run = function run () {
5741
  if (this.root) {
5742
    this.emit('run');
5743
  }
5744
};
5745
5746
},{"./hook":6,"./ms":14,"./utils":36,"debug":42,"events":46}],35:[function(require,module,exports){
5747
'use strict';
5748
5749
/**
5750
 * Module dependencies.
5751
 */
5752
5753
var Runnable = require('./runnable');
5754
var utils = require('./utils');
5755
var isString = utils.isString;
5756
5757
/**
5758
 * Expose `Test`.
5759
 */
5760
5761
module.exports = Test;
5762
5763
/**
5764
 * Initialize a new `Test` with the given `title` and callback `fn`.
5765
 *
5766
 * @api private
5767
 * @param {String} title
5768
 * @param {Function} fn
5769
 */
5770
function Test (title, fn) {
5771
  if (!isString(title)) {
5772
    throw new Error('Test `title` should be a "string" but "' + typeof title + '" was given instead.');
5773
  }
5774
  Runnable.call(this, title, fn);
5775
  this.pending = !fn;
5776
  this.type = 'test';
5777
}
5778
5779
/**
5780
 * Inherit from `Runnable.prototype`.
5781
 */
5782
utils.inherits(Test, Runnable);
5783
5784
Test.prototype.clone = function () {
5785
  var test = new Test(this.title, this.fn);
5786
  test.timeout(this.timeout());
5787
  test.slow(this.slow());
5788
  test.enableTimeouts(this.enableTimeouts());
5789
  test.retries(this.retries());
5790
  test.currentRetry(this.currentRetry());
5791
  test.globals(this.globals());
5792
  test.parent = this.parent;
5793
  test.file = this.file;
5794
  test.ctx = this.ctx;
5795
  return test;
5796
};
5797
5798
},{"./runnable":32,"./utils":36}],36:[function(require,module,exports){
5799
(function (process,Buffer){
5800
'use strict';
5801
5802
/* eslint-env browser */
5803
5804
/**
5805
 * Module dependencies.
5806
 */
5807
5808
var basename = require('path').basename;
5809
var debug = require('debug')('mocha:watch');
5810
var exists = require('fs').existsSync;
5811
var glob = require('glob');
5812
var path = require('path');
5813
var join = path.join;
5814
var readdirSync = require('fs').readdirSync;
5815
var statSync = require('fs').statSync;
5816
var watchFile = require('fs').watchFile;
5817
var lstatSync = require('fs').lstatSync;
5818
var he = require('he');
5819
5820
/**
5821
 * Ignored directories.
5822
 */
5823
5824
var ignore = ['node_modules', '.git'];
5825
5826
exports.inherits = require('util').inherits;
5827
5828
/**
5829
 * Escape special characters in the given string of html.
5830
 *
5831
 * @api private
5832
 * @param  {string} html
5833
 * @return {string}
5834
 */
5835
exports.escape = function (html) {
5836
  return he.encode(String(html), { useNamedReferences: false });
5837
};
5838
5839
/**
5840
 * Test if the given obj is type of string.
5841
 *
5842
 * @api private
5843
 * @param {Object} obj
5844
 * @return {boolean}
5845
 */
5846
exports.isString = function (obj) {
5847
  return typeof obj === 'string';
5848
};
5849
5850
/**
5851
 * Watch the given `files` for changes
5852
 * and invoke `fn(file)` on modification.
5853
 *
5854
 * @api private
5855
 * @param {Array} files
5856
 * @param {Function} fn
5857
 */
5858
exports.watch = function (files, fn) {
5859
  var options = { interval: 100 };
5860
  files.forEach(function (file) {
5861
    debug('file %s', file);
5862
    watchFile(file, options, function (curr, prev) {
5863
      if (prev.mtime < curr.mtime) {
5864
        fn(file);
5865
      }
5866
    });
5867
  });
5868
};
5869
5870
/**
5871
 * Ignored files.
5872
 *
5873
 * @api private
5874
 * @param {string} path
5875
 * @return {boolean}
5876
 */
5877
function ignored (path) {
5878
  return !~ignore.indexOf(path);
5879
}
5880
5881
/**
5882
 * Lookup files in the given `dir`.
5883
 *
5884
 * @api private
5885
 * @param {string} dir
5886
 * @param {string[]} [ext=['.js']]
5887
 * @param {Array} [ret=[]]
5888
 * @return {Array}
5889
 */
5890 View Code Duplication
exports.files = function (dir, ext, ret) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
5891
  ret = ret || [];
5892
  ext = ext || ['js'];
5893
5894
  var re = new RegExp('\\.(' + ext.join('|') + ')$');
5895
5896
  readdirSync(dir)
5897
    .filter(ignored)
5898
    .forEach(function (path) {
5899
      path = join(dir, path);
5900
      if (lstatSync(path).isDirectory()) {
5901
        exports.files(path, ext, ret);
5902
      } else if (path.match(re)) {
5903
        ret.push(path);
5904
      }
5905
    });
5906
5907
  return ret;
5908
};
5909
5910
/**
5911
 * Compute a slug from the given `str`.
5912
 *
5913
 * @api private
5914
 * @param {string} str
5915
 * @return {string}
5916
 */
5917
exports.slug = function (str) {
5918
  return str
5919
    .toLowerCase()
5920
    .replace(/ +/g, '-')
5921
    .replace(/[^-\w]/g, '');
5922
};
5923
5924
/**
5925
 * Strip the function definition from `str`, and re-indent for pre whitespace.
5926
 *
5927
 * @param {string} str
5928
 * @return {string}
5929
 */
5930
exports.clean = function (str) {
5931
  str = str
5932
    .replace(/\r\n?|[\n\u2028\u2029]/g, '\n').replace(/^\uFEFF/, '')
5933
    // (traditional)->  space/name     parameters    body     (lambda)-> parameters       body   multi-statement/single          keep body content
5934
    .replace(/^function(?:\s*|\s+[^(]*)\([^)]*\)\s*\{((?:.|\n)*?)\s*\}$|^\([^)]*\)\s*=>\s*(?:\{((?:.|\n)*?)\s*\}|((?:.|\n)*))$/, '$1$2$3');
5935
5936
  var spaces = str.match(/^\n?( *)/)[1].length;
5937
  var tabs = str.match(/^\n?(\t*)/)[1].length;
5938
  var re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs || spaces) + '}', 'gm');
5939
5940
  str = str.replace(re, '');
5941
5942
  return str.trim();
5943
};
5944
5945
/**
5946
 * Parse the given `qs`.
5947
 *
5948
 * @api private
5949
 * @param {string} qs
5950
 * @return {Object}
5951
 */
5952
exports.parseQuery = function (qs) {
5953
  return qs.replace('?', '').split('&').reduce(function (obj, pair) {
5954
    var i = pair.indexOf('=');
5955
    var key = pair.slice(0, i);
5956
    var val = pair.slice(++i);
5957
5958
    // Due to how the URLSearchParams API treats spaces
5959
    obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
5960
5961
    return obj;
5962
  }, {});
5963
};
5964
5965
/**
5966
 * Highlight the given string of `js`.
5967
 *
5968
 * @api private
5969
 * @param {string} js
5970
 * @return {string}
5971
 */
5972
function highlight (js) {
5973
  return js
5974
    .replace(/</g, '&lt;')
5975
    .replace(/>/g, '&gt;')
5976
    .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
5977
    .replace(/('.*?')/gm, '<span class="string">$1</span>')
5978
    .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
5979
    .replace(/(\d+)/gm, '<span class="number">$1</span>')
5980
    .replace(/\bnew[ \t]+(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
5981
    .replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>');
5982
}
5983
5984
/**
5985
 * Highlight the contents of tag `name`.
5986
 *
5987
 * @api private
5988
 * @param {string} name
5989
 */
5990
exports.highlightTags = function (name) {
5991
  var code = document.getElementById('mocha').getElementsByTagName(name);
5992
  for (var i = 0, len = code.length; i < len; ++i) {
5993
    code[i].innerHTML = highlight(code[i].innerHTML);
5994
  }
5995
};
5996
5997
/**
5998
 * If a value could have properties, and has none, this function is called,
5999
 * which returns a string representation of the empty value.
6000
 *
6001
 * Functions w/ no properties return `'[Function]'`
6002
 * Arrays w/ length === 0 return `'[]'`
6003
 * Objects w/ no properties return `'{}'`
6004
 * All else: return result of `value.toString()`
6005
 *
6006
 * @api private
6007
 * @param {*} value The value to inspect.
6008
 * @param {string} typeHint The type of the value
6009
 * @returns {string}
6010
 */
6011
function emptyRepresentation (value, typeHint) {
6012
  switch (typeHint) {
6013
    case 'function':
6014
      return '[Function]';
6015
    case 'object':
6016
      return '{}';
6017
    case 'array':
6018
      return '[]';
6019
    default:
6020
      return value.toString();
6021
  }
6022
}
6023
6024
/**
6025
 * Takes some variable and asks `Object.prototype.toString()` what it thinks it
6026
 * is.
6027
 *
6028
 * @api private
6029
 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString
6030
 * @param {*} value The value to test.
6031
 * @returns {string} Computed type
6032
 * @example
6033
 * type({}) // 'object'
6034
 * type([]) // 'array'
6035
 * type(1) // 'number'
6036
 * type(false) // 'boolean'
6037
 * type(Infinity) // 'number'
6038
 * type(null) // 'null'
6039
 * type(new Date()) // 'date'
6040
 * type(/foo/) // 'regexp'
6041
 * type('type') // 'string'
6042
 * type(global) // 'global'
6043
 * type(new String('foo') // 'object'
6044
 */
6045
var type = exports.type = function type (value) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable type already seems to be declared on line 6045. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
6046
  if (value === undefined) {
6047
    return 'undefined';
6048
  } else if (value === null) {
6049
    return 'null';
6050
  } else if (Buffer.isBuffer(value)) {
6051
    return 'buffer';
6052
  }
6053
  return Object.prototype.toString.call(value)
6054
    .replace(/^\[.+\s(.+?)]$/, '$1')
6055
    .toLowerCase();
6056
};
6057
6058
/**
6059
 * Stringify `value`. Different behavior depending on type of value:
6060
 *
6061
 * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
6062
 * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
6063
 * - If `value` is an *empty* object, function, or array, return result of function
6064
 *   {@link emptyRepresentation}.
6065
 * - If `value` has properties, call {@link exports.canonicalize} on it, then return result of
6066
 *   JSON.stringify().
6067
 *
6068
 * @api private
6069
 * @see exports.type
6070
 * @param {*} value
6071
 * @return {string}
6072
 */
6073 View Code Duplication
exports.stringify = function (value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6074
  var typeHint = type(value);
6075
6076
  if (!~['object', 'array', 'function'].indexOf(typeHint)) {
6077
    if (typeHint === 'buffer') {
6078
      var json = Buffer.prototype.toJSON.call(value);
6079
      // Based on the toJSON result
6080
      return jsonStringify(json.data && json.type ? json.data : json, 2)
6081
        .replace(/,(\n|$)/g, '$1');
6082
    }
6083
6084
    // IE7/IE8 has a bizarre String constructor; needs to be coerced
6085
    // into an array and back to obj.
6086
    if (typeHint === 'string' && typeof value === 'object') {
6087
      value = value.split('').reduce(function (acc, char, idx) {
6088
        acc[idx] = char;
6089
        return acc;
6090
      }, {});
6091
      typeHint = 'object';
6092
    } else {
6093
      return jsonStringify(value);
6094
    }
6095
  }
6096
6097
  for (var prop in value) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
6098
    if (Object.prototype.hasOwnProperty.call(value, prop)) {
6099
      return jsonStringify(exports.canonicalize(value, null, typeHint), 2).replace(/,(\n|$)/g, '$1');
6100
    }
6101
  }
6102
6103
  return emptyRepresentation(value, typeHint);
6104
};
6105
6106
/**
6107
 * like JSON.stringify but more sense.
6108
 *
6109
 * @api private
6110
 * @param {Object}  object
6111
 * @param {number=} spaces
6112
 * @param {number=} depth
6113
 * @returns {*}
6114
 */
6115 View Code Duplication
function jsonStringify (object, spaces, depth) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6116
  if (typeof spaces === 'undefined') {
6117
    // primitive types
6118
    return _stringify(object);
6119
  }
6120
6121
  depth = depth || 1;
6122
  var space = spaces * depth;
6123
  var str = Array.isArray(object) ? '[' : '{';
6124
  var end = Array.isArray(object) ? ']' : '}';
6125
  var length = typeof object.length === 'number' ? object.length : Object.keys(object).length;
6126
  // `.repeat()` polyfill
6127
  function repeat (s, n) {
6128
    return new Array(n).join(s);
6129
  }
6130
6131
  function _stringify (val) {
6132
    switch (type(val)) {
6133
      case 'null':
6134
      case 'undefined':
6135
        val = '[' + val + ']';
6136
        break;
6137
      case 'array':
6138
      case 'object':
6139
        val = jsonStringify(val, spaces, depth + 1);
6140
        break;
6141
      case 'boolean':
6142
      case 'regexp':
6143
      case 'symbol':
6144
      case 'number':
6145
        val = val === 0 && (1 / val) === -Infinity // `-0`
6146
          ? '-0'
6147
          : val.toString();
6148
        break;
6149
      case 'date':
6150
        var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
6151
        val = '[Date: ' + sDate + ']';
6152
        break;
6153
      case 'buffer':
6154
        var json = val.toJSON();
6155
        // Based on the toJSON result
6156
        json = json.data && json.type ? json.data : json;
6157
        val = '[Buffer: ' + jsonStringify(json, 2, depth + 1) + ']';
6158
        break;
6159
      default:
6160
        val = (val === '[Function]' || val === '[Circular]')
6161
          ? val
6162
          : JSON.stringify(val); // string
6163
    }
6164
    return val;
6165
  }
6166
6167
  for (var i in object) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
6168
    if (!Object.prototype.hasOwnProperty.call(object, i)) {
6169
      continue; // not my business
6170
    }
6171
    --length;
6172
    str += '\n ' + repeat(' ', space) +
6173
      (Array.isArray(object) ? '' : '"' + i + '": ') + // key
6174
      _stringify(object[i]) + // value
6175
      (length ? ',' : ''); // comma
6176
  }
6177
6178
  return str +
6179
    // [], {}
6180
    (str.length !== 1 ? '\n' + repeat(' ', --space) + end : end);
6181
}
6182
6183
/**
6184
 * Return a new Thing that has the keys in sorted order. Recursive.
6185
 *
6186
 * If the Thing...
6187
 * - has already been seen, return string `'[Circular]'`
6188
 * - is `undefined`, return string `'[undefined]'`
6189
 * - is `null`, return value `null`
6190
 * - is some other primitive, return the value
6191
 * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
6192
 * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
6193
 * - is an empty `Array`, `Object`, or `Function`, return the result of calling `emptyRepresentation()`
6194
 *
6195
 * @api private
6196
 * @see {@link exports.stringify}
6197
 * @param {*} value Thing to inspect.  May or may not have properties.
6198
 * @param {Array} [stack=[]] Stack of seen values
6199
 * @param {string} [typeHint] Type hint
6200
 * @return {(Object|Array|Function|string|undefined)}
6201
 */
6202 View Code Duplication
exports.canonicalize = function canonicalize (value, stack, typeHint) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6203
  var canonicalizedObj;
6204
  /* eslint-disable no-unused-vars */
6205
  var prop;
6206
  /* eslint-enable no-unused-vars */
6207
  typeHint = typeHint || type(value);
6208
  function withStack (value, fn) {
6209
    stack.push(value);
6210
    fn();
6211
    stack.pop();
6212
  }
6213
6214
  stack = stack || [];
6215
6216
  if (stack.indexOf(value) !== -1) {
6217
    return '[Circular]';
6218
  }
6219
6220
  switch (typeHint) {
6221
    case 'undefined':
6222
    case 'buffer':
6223
    case 'null':
6224
      canonicalizedObj = value;
6225
      break;
6226
    case 'array':
6227
      withStack(value, function () {
6228
        canonicalizedObj = value.map(function (item) {
6229
          return exports.canonicalize(item, stack);
6230
        });
6231
      });
6232
      break;
6233
    case 'function':
6234
      /* eslint-disable guard-for-in */
6235
      for (prop in value) {
0 ignored issues
show
Unused Code introduced by
The variable prop seems to be never used. Consider removing it.
Loading history...
6236
        canonicalizedObj = {};
6237
        break;
6238
      }
6239
      /* eslint-enable guard-for-in */
6240
      if (!canonicalizedObj) {
6241
        canonicalizedObj = emptyRepresentation(value, typeHint);
6242
        break;
6243
      }
0 ignored issues
show
introduced by
This node falls through to the next case due to this statement. Please add a comment either directly below this line or between the cases to explain.
Loading history...
6244
    /* falls through */
6245
    case 'object':
6246
      canonicalizedObj = canonicalizedObj || {};
6247
      withStack(value, function () {
6248
        Object.keys(value).sort().forEach(function (key) {
6249
          canonicalizedObj[key] = exports.canonicalize(value[key], stack);
6250
        });
6251
      });
6252
      break;
6253
    case 'date':
6254
    case 'number':
6255
    case 'regexp':
6256
    case 'boolean':
6257
    case 'symbol':
6258
      canonicalizedObj = value;
6259
      break;
6260
    default:
6261
      canonicalizedObj = value + '';
6262
  }
6263
6264
  return canonicalizedObj;
0 ignored issues
show
Bug introduced by
The variable canonicalizedObj seems to not be initialized for all possible execution paths.
Loading history...
6265
};
6266
6267
/**
6268
 * Lookup file names at the given `path`.
6269
 *
6270
 * @api public
6271
 * @param {string} path Base path to start searching from.
6272
 * @param {string[]} extensions File extensions to look for.
6273
 * @param {boolean} recursive Whether or not to recurse into subdirectories.
6274
 * @return {string[]} An array of paths.
6275
 */
6276 View Code Duplication
exports.lookupFiles = function lookupFiles (path, extensions, recursive) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6277
  var files = [];
6278
  var re = new RegExp('\\.(' + extensions.join('|') + ')$');
6279
6280
  if (!exists(path)) {
6281
    if (exists(path + '.js')) {
6282
      path += '.js';
6283
    } else {
6284
      files = glob.sync(path);
6285
      if (!files.length) {
6286
        throw new Error("cannot resolve path (or pattern) '" + path + "'");
6287
      }
6288
      return files;
6289
    }
6290
  }
6291
6292
  try {
6293
    var stat = statSync(path);
6294
    if (stat.isFile()) {
6295
      return path;
6296
    }
6297
  } catch (err) {
6298
    // ignore error
6299
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
6300
  }
6301
6302
  readdirSync(path).forEach(function (file) {
6303
    file = join(path, file);
6304
    try {
6305
      var stat = statSync(file);
6306
      if (stat.isDirectory()) {
6307
        if (recursive) {
6308
          files = files.concat(lookupFiles(file, extensions, recursive));
6309
        }
6310
        return;
6311
      }
6312
    } catch (err) {
6313
      // ignore error
6314
      return;
6315
    }
6316
    if (!stat.isFile() || !re.test(file) || basename(file)[0] === '.') {
6317
      return;
6318
    }
6319
    files.push(file);
6320
  });
6321
6322
  return files;
6323
};
6324
6325
/**
6326
 * Generate an undefined error with a message warning the user.
6327
 *
6328
 * @return {Error}
6329
 */
6330
6331
exports.undefinedError = function () {
6332
  return new Error('Caught undefined error, did you throw without specifying what?');
6333
};
6334
6335
/**
6336
 * Generate an undefined error if `err` is not defined.
6337
 *
6338
 * @param {Error} err
6339
 * @return {Error}
6340
 */
6341
6342
exports.getError = function (err) {
6343
  return err || exports.undefinedError();
6344
};
6345
6346
/**
6347
 * @summary
6348
 * This Filter based on `mocha-clean` module.(see: `github.com/rstacruz/mocha-clean`)
6349
 * @description
6350
 * When invoking this function you get a filter function that get the Error.stack as an input,
6351
 * and return a prettify output.
6352
 * (i.e: strip Mocha and internal node functions from stack trace).
6353
 * @returns {Function}
6354
 */
6355 View Code Duplication
exports.stackTraceFilter = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6356
  // TODO: Replace with `process.browser`
6357
  var is = typeof document === 'undefined' ? { node: true } : { browser: true };
6358
  var slash = path.sep;
6359
  var cwd;
6360
  if (is.node) {
6361
    cwd = process.cwd() + slash;
6362
  } else {
6363
    cwd = (typeof location === 'undefined'
6364
      ? window.location
6365
      : location).href.replace(/\/[^/]*$/, '/');
6366
    slash = '/';
6367
  }
6368
6369
  function isMochaInternal (line) {
6370
    return (~line.indexOf('node_modules' + slash + 'mocha' + slash)) ||
6371
      (~line.indexOf('node_modules' + slash + 'mocha.js')) ||
6372
      (~line.indexOf('bower_components' + slash + 'mocha.js')) ||
6373
      (~line.indexOf(slash + 'mocha.js'));
6374
  }
6375
6376
  function isNodeInternal (line) {
6377
    return (~line.indexOf('(timers.js:')) ||
6378
      (~line.indexOf('(events.js:')) ||
6379
      (~line.indexOf('(node.js:')) ||
6380
      (~line.indexOf('(module.js:')) ||
6381
      (~line.indexOf('GeneratorFunctionPrototype.next (native)')) ||
6382
      false;
6383
  }
6384
6385
  return function (stack) {
6386
    stack = stack.split('\n');
6387
6388
    stack = stack.reduce(function (list, line) {
6389
      if (isMochaInternal(line)) {
6390
        return list;
6391
      }
6392
6393
      if (is.node && isNodeInternal(line)) {
6394
        return list;
6395
      }
6396
6397
      // Clean up cwd(absolute)
6398
      if (/\(?.+:\d+:\d+\)?$/.test(line)) {
6399
        line = line.replace(cwd, '');
6400
      }
6401
6402
      list.push(line);
6403
      return list;
6404
    }, []);
6405
6406
    return stack.join('\n');
6407
  };
6408
};
6409
6410
/**
6411
 * Crude, but effective.
6412
 * @api
6413
 * @param {*} value
6414
 * @returns {boolean} Whether or not `value` is a Promise
6415
 */
6416
exports.isPromise = function isPromise (value) {
6417
  return typeof value === 'object' && typeof value.then === 'function';
6418
};
6419
6420
/**
6421
 * It's a noop.
6422
 * @api
6423
 */
6424
exports.noop = function () {};
6425
6426
}).call(this,require('_process'),require("buffer").Buffer)
6427
},{"_process":55,"buffer":"buffer","debug":42,"fs":40,"glob":40,"he":47,"path":40,"util":75}],37:[function(require,module,exports){
6428
'use strict'
6429
6430
exports.byteLength = byteLength
6431
exports.toByteArray = toByteArray
6432
exports.fromByteArray = fromByteArray
6433
6434
var lookup = []
6435
var revLookup = []
6436
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
6437
6438
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
6439
for (var i = 0, len = code.length; i < len; ++i) {
6440
  lookup[i] = code[i]
6441
  revLookup[code.charCodeAt(i)] = i
6442
}
6443
6444
revLookup['-'.charCodeAt(0)] = 62
6445
revLookup['_'.charCodeAt(0)] = 63
6446
6447
function placeHoldersCount (b64) {
6448
  var len = b64.length
6449
  if (len % 4 > 0) {
6450
    throw new Error('Invalid string. Length must be a multiple of 4')
6451
  }
6452
6453
  // the number of equal signs (place holders)
6454
  // if there are two placeholders, than the two characters before it
6455
  // represent one byte
6456
  // if there is only one, then the three characters before it represent 2 bytes
6457
  // this is just a cheap hack to not do indexOf twice
6458
  return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
6459
}
6460
6461
function byteLength (b64) {
6462
  // base64 is 4/3 + up to two characters of the original data
6463
  return (b64.length * 3 / 4) - placeHoldersCount(b64)
6464
}
6465
6466
function toByteArray (b64) {
6467
  var i, l, tmp, placeHolders, arr
6468
  var len = b64.length
6469
  placeHolders = placeHoldersCount(b64)
6470
6471
  arr = new Arr((len * 3 / 4) - placeHolders)
6472
6473
  // if there are placeholders, only get up to the last complete 4 chars
6474
  l = placeHolders > 0 ? len - 4 : len
6475
6476
  var L = 0
6477
6478
  for (i = 0; i < l; i += 4) {
6479
    tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
6480
    arr[L++] = (tmp >> 16) & 0xFF
6481
    arr[L++] = (tmp >> 8) & 0xFF
6482
    arr[L++] = tmp & 0xFF
6483
  }
6484
6485
  if (placeHolders === 2) {
6486
    tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
6487
    arr[L++] = tmp & 0xFF
0 ignored issues
show
Unused Code introduced by
The assignment to variable L seems to be never used. Consider removing it.
Loading history...
6488
  } else if (placeHolders === 1) {
6489
    tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
6490
    arr[L++] = (tmp >> 8) & 0xFF
6491
    arr[L++] = tmp & 0xFF
6492
  }
6493
6494
  return arr
6495
}
6496
6497
function tripletToBase64 (num) {
6498
  return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
6499
}
6500
6501
function encodeChunk (uint8, start, end) {
6502
  var tmp
6503
  var output = []
6504
  for (var i = start; i < end; i += 3) {
6505
    tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
6506
    output.push(tripletToBase64(tmp))
6507
  }
6508
  return output.join('')
6509
}
6510
6511
function fromByteArray (uint8) {
6512
  var tmp
6513
  var len = uint8.length
6514
  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
6515
  var output = ''
6516
  var parts = []
6517
  var maxChunkLength = 16383 // must be multiple of 3
6518
6519
  // go through the array every three bytes, we'll deal with trailing stuff later
6520
  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
6521
    parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
6522
  }
6523
6524
  // pad the end with zeros, but make sure to not forget the extra bytes
6525
  if (extraBytes === 1) {
6526
    tmp = uint8[len - 1]
6527
    output += lookup[tmp >> 2]
6528
    output += lookup[(tmp << 4) & 0x3F]
6529
    output += '=='
6530
  } else if (extraBytes === 2) {
6531
    tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
6532
    output += lookup[tmp >> 10]
6533
    output += lookup[(tmp >> 4) & 0x3F]
6534
    output += lookup[(tmp << 2) & 0x3F]
6535
    output += '='
6536
  }
6537
6538
  parts.push(output)
6539
6540
  return parts.join('')
6541
}
6542
6543
},{}],38:[function(require,module,exports){
0 ignored issues
show
Unused Code introduced by
The parameter module is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter exports is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter require is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
6544
6545
},{}],39:[function(require,module,exports){
6546
(function (process){
6547
var WritableStream = require('stream').Writable
6548
var inherits = require('util').inherits
6549
6550
module.exports = BrowserStdout
6551
6552
6553
inherits(BrowserStdout, WritableStream)
6554
6555
function BrowserStdout(opts) {
6556
  if (!(this instanceof BrowserStdout)) return new BrowserStdout(opts)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
6557
6558
  opts = opts || {}
6559
  WritableStream.call(this, opts)
6560
  this.label = (opts.label !== undefined) ? opts.label : 'stdout'
6561
}
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
6562
6563
BrowserStdout.prototype._write = function(chunks, encoding, cb) {
6564
  var output = chunks.toString ? chunks.toString() : chunks
6565
  if (this.label === false) {
6566
    console.log(output)
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6567
  } else {
6568
    console.log(this.label+':', output)
6569
  }
6570
  process.nextTick(cb)
6571
}
6572
6573
}).call(this,require('_process'))
6574
},{"_process":55,"stream":70,"util":75}],40:[function(require,module,exports){
6575
arguments[4][38][0].apply(exports,arguments)
6576
},{"dup":38}],41:[function(require,module,exports){
6577
(function (Buffer){
6578
// Copyright Joyent, Inc. and other Node contributors.
6579
//
6580
// Permission is hereby granted, free of charge, to any person obtaining a
6581
// copy of this software and associated documentation files (the
6582
// "Software"), to deal in the Software without restriction, including
6583
// without limitation the rights to use, copy, modify, merge, publish,
6584
// distribute, sublicense, and/or sell copies of the Software, and to permit
6585
// persons to whom the Software is furnished to do so, subject to the
6586
// following conditions:
6587
//
6588
// The above copyright notice and this permission notice shall be included
6589
// in all copies or substantial portions of the Software.
6590
//
6591
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
6592
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6593
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
6594
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
6595
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
6596
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
6597
// USE OR OTHER DEALINGS IN THE SOFTWARE.
6598
6599
// NOTE: These type checking functions intentionally don't use `instanceof`
6600
// because it is fragile and can be easily faked with `Object.create()`.
6601
6602
function isArray(arg) {
6603
  if (Array.isArray) {
6604
    return Array.isArray(arg);
6605
  }
6606
  return objectToString(arg) === '[object Array]';
6607
}
6608
exports.isArray = isArray;
6609
6610
function isBoolean(arg) {
6611
  return typeof arg === 'boolean';
6612
}
6613
exports.isBoolean = isBoolean;
6614
6615
function isNull(arg) {
6616
  return arg === null;
6617
}
6618
exports.isNull = isNull;
6619
6620
function isNullOrUndefined(arg) {
6621
  return arg == null;
0 ignored issues
show
Best Practice introduced by
Comparing arg to null using the == operator is not safe. Consider using === instead.
Loading history...
6622
}
6623
exports.isNullOrUndefined = isNullOrUndefined;
6624
6625
function isNumber(arg) {
6626
  return typeof arg === 'number';
6627
}
6628
exports.isNumber = isNumber;
6629
6630
function isString(arg) {
6631
  return typeof arg === 'string';
6632
}
6633
exports.isString = isString;
6634
6635
function isSymbol(arg) {
6636
  return typeof arg === 'symbol';
6637
}
6638
exports.isSymbol = isSymbol;
6639
6640
function isUndefined(arg) {
6641
  return arg === void 0;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
6642
}
6643
exports.isUndefined = isUndefined;
6644
6645
function isRegExp(re) {
6646
  return objectToString(re) === '[object RegExp]';
6647
}
6648
exports.isRegExp = isRegExp;
6649
6650
function isObject(arg) {
6651
  return typeof arg === 'object' && arg !== null;
6652
}
6653
exports.isObject = isObject;
6654
6655
function isDate(d) {
6656
  return objectToString(d) === '[object Date]';
6657
}
6658
exports.isDate = isDate;
6659
6660
function isError(e) {
6661
  return (objectToString(e) === '[object Error]' || e instanceof Error);
6662
}
6663
exports.isError = isError;
6664
6665
function isFunction(arg) {
6666
  return typeof arg === 'function';
6667
}
6668
exports.isFunction = isFunction;
6669
6670 View Code Duplication
function isPrimitive(arg) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6671
  return arg === null ||
6672
         typeof arg === 'boolean' ||
6673
         typeof arg === 'number' ||
6674
         typeof arg === 'string' ||
6675
         typeof arg === 'symbol' ||  // ES6 symbol
6676
         typeof arg === 'undefined';
6677
}
6678
exports.isPrimitive = isPrimitive;
6679
6680
exports.isBuffer = Buffer.isBuffer;
6681
6682
function objectToString(o) {
6683
  return Object.prototype.toString.call(o);
6684
}
6685
6686
}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
6687
},{"../../is-buffer/index.js":50}],42:[function(require,module,exports){
6688
(function (process){
6689
/**
6690
 * This is the web browser implementation of `debug()`.
6691
 *
6692
 * Expose `debug()` as the module.
6693
 */
6694
6695
exports = module.exports = require('./debug');
6696
exports.log = log;
6697
exports.formatArgs = formatArgs;
6698
exports.save = save;
6699
exports.load = load;
6700
exports.useColors = useColors;
6701
exports.storage = 'undefined' != typeof chrome
0 ignored issues
show
Bug introduced by
The variable chrome seems to be never declared. If this is a global, consider adding a /** global: chrome */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
6702
               && 'undefined' != typeof chrome.storage
6703
                  ? chrome.storage.local
6704
                  : localstorage();
6705
6706
/**
6707
 * Colors.
6708
 */
6709
6710
exports.colors = [
6711
  '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
6712
  '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
6713
  '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
6714
  '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
6715
  '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
6716
  '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
6717
  '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
6718
  '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
6719
  '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
6720
  '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
6721
  '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
6722
];
6723
6724
/**
6725
 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
6726
 * and the Firebug extension (any Firefox version) are known
6727
 * to support "%c" CSS customizations.
6728
 *
6729
 * TODO: add a `localStorage` variable to explicitly enable/disable colors
6730
 */
6731
6732 View Code Duplication
function useColors() {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6733
  // NB: In an Electron preload script, document will be defined but not fully
6734
  // initialized. Since we know we're in Chrome, we'll just detect this case
6735
  // explicitly
6736
  if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
6737
    return true;
6738
  }
6739
6740
  // Internet Explorer and Edge do not support colors.
6741
  if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
6742
    return false;
6743
  }
6744
6745
  // is webkit? http://stackoverflow.com/a/16459606/376773
6746
  // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
6747
  return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
6748
    // is firebug? http://stackoverflow.com/a/398120/376773
6749
    (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
6750
    // is firefox >= v31?
6751
    // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
6752
    (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
6753
    // double check webkit in userAgent just in case we are in a worker
6754
    (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
6755
}
6756
6757
/**
6758
 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
6759
 */
6760
6761
exports.formatters.j = function(v) {
6762
  try {
6763
    return JSON.stringify(v);
6764
  } catch (err) {
6765
    return '[UnexpectedJSONParseError]: ' + err.message;
6766
  }
6767
};
6768
6769
6770
/**
6771
 * Colorize log arguments if enabled.
6772
 *
6773
 * @api public
6774
 */
6775
6776 View Code Duplication
function formatArgs(args) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6777
  var useColors = this.useColors;
6778
6779
  args[0] = (useColors ? '%c' : '')
6780
    + this.namespace
6781
    + (useColors ? ' %c' : ' ')
6782
    + args[0]
6783
    + (useColors ? '%c ' : ' ')
6784
    + '+' + exports.humanize(this.diff);
6785
6786
  if (!useColors) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
6787
6788
  var c = 'color: ' + this.color;
6789
  args.splice(1, 0, c, 'color: inherit')
6790
6791
  // the final "%c" is somewhat tricky, because there could be other
6792
  // arguments passed either before or after the %c, so we need to
6793
  // figure out the correct index to insert the CSS into
6794
  var index = 0;
6795
  var lastC = 0;
6796
  args[0].replace(/%[a-zA-Z%]/g, function(match) {
6797
    if ('%%' === match) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
6798
    index++;
6799
    if ('%c' === match) {
6800
      // we only are interested in the *last* %c
6801
      // (the user may have provided their own)
6802
      lastC = index;
6803
    }
6804
  });
6805
6806
  args.splice(lastC, 0, c);
6807
}
6808
6809
/**
6810
 * Invokes `console.log()` when available.
6811
 * No-op when `console.log` is not a "function".
6812
 *
6813
 * @api public
6814
 */
6815
6816
function log() {
6817
  // this hackery is required for IE8/9, where
6818
  // the `console.log` function doesn't have 'apply'
6819
  return 'object' === typeof console
6820
    && console.log
6821
    && Function.prototype.apply.call(console.log, console, arguments);
6822
}
6823
6824
/**
6825
 * Save `namespaces`.
6826
 *
6827
 * @param {String} namespaces
6828
 * @api private
6829
 */
6830
6831
function save(namespaces) {
6832
  try {
6833
    if (null == namespaces) {
0 ignored issues
show
Best Practice introduced by
Comparing null to namespaces using the == operator is not safe. Consider using === instead.
Loading history...
6834
      exports.storage.removeItem('debug');
6835
    } else {
6836
      exports.storage.debug = namespaces;
6837
    }
6838
  } catch(e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
6839
}
6840
6841
/**
6842
 * Load `namespaces`.
6843
 *
6844
 * @return {String} returns the previously persisted debug modes
6845
 * @api private
6846
 */
6847
6848
function load() {
6849
  var r;
6850
  try {
6851
    r = exports.storage.debug;
6852
  } catch(e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
6853
6854
  // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
6855
  if (!r && typeof process !== 'undefined' && 'env' in process) {
6856
    r = process.env.DEBUG;
6857
  }
6858
6859
  return r;
6860
}
6861
6862
/**
6863
 * Enable namespaces listed in `localStorage.debug` initially.
6864
 */
6865
6866
exports.enable(load());
6867
6868
/**
6869
 * Localstorage attempts to return the localstorage.
6870
 *
6871
 * This is necessary because safari throws
6872
 * when a user disables cookies/localstorage
6873
 * and you attempt to access it.
6874
 *
6875
 * @return {LocalStorage}
6876
 * @api private
6877
 */
6878
6879
function localstorage() {
6880
  try {
6881
    return window.localStorage;
6882
  } catch (e) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
6883
}
6884
6885
}).call(this,require('_process'))
6886
},{"./debug":43,"_process":55}],43:[function(require,module,exports){
6887
6888
/**
6889
 * This is the common logic for both the Node.js and web browser
6890
 * implementations of `debug()`.
6891
 *
6892
 * Expose `debug()` as the module.
6893
 */
6894
6895
exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
6896
exports.coerce = coerce;
6897
exports.disable = disable;
6898
exports.enable = enable;
6899
exports.enabled = enabled;
6900
exports.humanize = require('ms');
6901
6902
/**
6903
 * Active `debug` instances.
6904
 */
6905
exports.instances = [];
6906
6907
/**
6908
 * The currently active debug mode names, and names to skip.
6909
 */
6910
6911
exports.names = [];
6912
exports.skips = [];
6913
6914
/**
6915
 * Map of special "%n" handling functions, for the debug "format" argument.
6916
 *
6917
 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
6918
 */
6919
6920
exports.formatters = {};
6921
6922
/**
6923
 * Select a color.
6924
 * @param {String} namespace
6925
 * @return {Number}
6926
 * @api private
6927
 */
6928
6929
function selectColor(namespace) {
6930
  var hash = 0, i;
6931
6932
  for (i in namespace) {
6933
    hash  = ((hash << 5) - hash) + namespace.charCodeAt(i);
6934
    hash |= 0; // Convert to 32bit integer
6935
  }
6936
6937
  return exports.colors[Math.abs(hash) % exports.colors.length];
6938
}
6939
6940
/**
6941
 * Create a debugger with the given `namespace`.
6942
 *
6943
 * @param {String} namespace
6944
 * @return {Function}
6945
 * @api public
6946
 */
6947
6948 View Code Duplication
function createDebug(namespace) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6949
6950
  var prevTime;
6951
6952
  function debug() {
6953
    // disabled?
6954
    if (!debug.enabled) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
6955
6956
    var self = debug;
6957
6958
    // set `diff` timestamp
6959
    var curr = +new Date();
6960
    var ms = curr - (prevTime || curr);
6961
    self.diff = ms;
6962
    self.prev = prevTime;
0 ignored issues
show
Bug introduced by
The variable prevTime seems to not be initialized for all possible execution paths.
Loading history...
6963
    self.curr = curr;
6964
    prevTime = curr;
6965
6966
    // turn the `arguments` into a proper Array
6967
    var args = new Array(arguments.length);
6968
    for (var i = 0; i < args.length; i++) {
6969
      args[i] = arguments[i];
6970
    }
6971
6972
    args[0] = exports.coerce(args[0]);
6973
6974
    if ('string' !== typeof args[0]) {
6975
      // anything else let's inspect with %O
6976
      args.unshift('%O');
6977
    }
6978
6979
    // apply any `formatters` transformations
6980
    var index = 0;
6981
    args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
6982
      // if we encounter an escaped % then don't increase the array index
6983
      if (match === '%%') return match;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
6984
      index++;
6985
      var formatter = exports.formatters[format];
6986
      if ('function' === typeof formatter) {
6987
        var val = args[index];
6988
        match = formatter.call(self, val);
6989
6990
        // now we need to remove `args[index]` since it's inlined in the `format`
6991
        args.splice(index, 1);
6992
        index--;
6993
      }
6994
      return match;
6995
    });
6996
6997
    // apply env-specific formatting (colors, etc.)
6998
    exports.formatArgs.call(self, args);
6999
7000
    var logFn = debug.log || exports.log || console.log.bind(console);
7001
    logFn.apply(self, args);
7002
  }
7003
7004
  debug.namespace = namespace;
7005
  debug.enabled = exports.enabled(namespace);
7006
  debug.useColors = exports.useColors();
7007
  debug.color = selectColor(namespace);
7008
  debug.destroy = destroy;
7009
7010
  // env-specific initialization logic for debug instances
7011
  if ('function' === typeof exports.init) {
7012
    exports.init(debug);
7013
  }
7014
7015
  exports.instances.push(debug);
7016
7017
  return debug;
7018
}
7019
7020
function destroy () {
7021
  var index = exports.instances.indexOf(this);
7022
  if (index !== -1) {
7023
    exports.instances.splice(index, 1);
7024
    return true;
7025
  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
7026
    return false;
7027
  }
7028
}
7029
7030
/**
7031
 * Enables a debug mode by namespaces. This can include modes
7032
 * separated by a colon and wildcards.
7033
 *
7034
 * @param {String} namespaces
7035
 * @api public
7036
 */
7037
7038 View Code Duplication
function enable(namespaces) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7039
  exports.save(namespaces);
7040
7041
  exports.names = [];
7042
  exports.skips = [];
7043
7044
  var i;
7045
  var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
7046
  var len = split.length;
7047
7048
  for (i = 0; i < len; i++) {
7049
    if (!split[i]) continue; // ignore empty strings
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7050
    namespaces = split[i].replace(/\*/g, '.*?');
7051
    if (namespaces[0] === '-') {
7052
      exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
7053
    } else {
7054
      exports.names.push(new RegExp('^' + namespaces + '$'));
7055
    }
7056
  }
7057
7058
  for (i = 0; i < exports.instances.length; i++) {
7059
    var instance = exports.instances[i];
7060
    instance.enabled = exports.enabled(instance.namespace);
7061
  }
7062
}
7063
7064
/**
7065
 * Disable debug output.
7066
 *
7067
 * @api public
7068
 */
7069
7070
function disable() {
7071
  exports.enable('');
7072
}
7073
7074
/**
7075
 * Returns true if the given mode name is enabled, false otherwise.
7076
 *
7077
 * @param {String} name
7078
 * @return {Boolean}
7079
 * @api public
7080
 */
7081
7082 View Code Duplication
function enabled(name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7083
  if (name[name.length - 1] === '*') {
7084
    return true;
7085
  }
7086
  var i, len;
7087
  for (i = 0, len = exports.skips.length; i < len; i++) {
7088
    if (exports.skips[i].test(name)) {
7089
      return false;
7090
    }
7091
  }
7092
  for (i = 0, len = exports.names.length; i < len; i++) {
7093
    if (exports.names[i].test(name)) {
7094
      return true;
7095
    }
7096
  }
7097
  return false;
7098
}
7099
7100
/**
7101
 * Coerce `val`.
7102
 *
7103
 * @param {Mixed} val
7104
 * @return {Mixed}
7105
 * @api private
7106
 */
7107
7108
function coerce(val) {
7109
  if (val instanceof Error) return val.stack || val.message;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7110
  return val;
7111
}
7112
7113
},{"ms":53}],44:[function(require,module,exports){
7114
/*!
7115
7116
 diff v3.3.1
7117
7118
Software License Agreement (BSD License)
7119
7120
Copyright (c) 2009-2015, Kevin Decker <[email protected]>
7121
7122
All rights reserved.
7123
7124
Redistribution and use of this software in source and binary forms, with or without modification,
7125
are permitted provided that the following conditions are met:
7126
7127
* Redistributions of source code must retain the above
7128
  copyright notice, this list of conditions and the
7129
  following disclaimer.
7130
7131
* Redistributions in binary form must reproduce the above
7132
  copyright notice, this list of conditions and the
7133
  following disclaimer in the documentation and/or other
7134
  materials provided with the distribution.
7135
7136
* Neither the name of Kevin Decker nor the names of its
7137
  contributors may be used to endorse or promote products
7138
  derived from this software without specific prior
7139
  written permission.
7140
7141
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
7142
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
7143
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
7144
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
7145
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
7146
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
7147
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
7148
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7149
@license
7150
*/
7151
(function webpackUniversalModuleDefinition(root, factory) {
7152
	if(typeof exports === 'object' && typeof module === 'object')
7153
		module.exports = factory();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7154
	else if(false)
7155
		define([], factory);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7156
	else if(typeof exports === 'object')
7157
		exports["JsDiff"] = factory();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7158
	else
7159
		root["JsDiff"] = factory();
7160
})(this, function() {
7161
return /******/ (function(modules) { // webpackBootstrap
7162
/******/ 	// The module cache
7163
/******/ 	var installedModules = {};
7164
7165
/******/ 	// The require function
7166
/******/ 	function __webpack_require__(moduleId) {
7167
7168
/******/ 		// Check if module is in cache
7169
/******/ 		if(installedModules[moduleId])
7170
/******/ 			return installedModules[moduleId].exports;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
7171
7172
/******/ 		// Create a new module (and put it into the cache)
7173
/******/ 		var module = installedModules[moduleId] = {
7174
/******/ 			exports: {},
7175
/******/ 			id: moduleId,
7176
/******/ 			loaded: false
7177
/******/ 		};
7178
7179
/******/ 		// Execute the module function
7180
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
7181
7182
/******/ 		// Flag the module as loaded
7183
/******/ 		module.loaded = true;
7184
7185
/******/ 		// Return the exports of the module
7186
/******/ 		return module.exports;
7187
/******/ 	}
7188
7189
7190
/******/ 	// expose the modules object (__webpack_modules__)
7191
/******/ 	__webpack_require__.m = modules;
7192
7193
/******/ 	// expose the module cache
7194
/******/ 	__webpack_require__.c = installedModules;
7195
7196
/******/ 	// __webpack_public_path__
7197
/******/ 	__webpack_require__.p = "";
7198
7199
/******/ 	// Load entry module and return exports
7200
/******/ 	return __webpack_require__(0);
7201
/******/ })
7202
/************************************************************************/
7203
/******/ ([
7204
/* 0 */
7205
/***/ (function(module, exports, __webpack_require__) {
7206
7207
	/*istanbul ignore start*/'use strict';
7208
7209
	exports.__esModule = true;
7210
	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;
7211
7212
	/*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7213
7214
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7215
7216
	/*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/;
7217
7218
	var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/;
7219
7220
	var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
7221
7222
	var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/;
7223
7224
	var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/;
7225
7226
	var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/;
7227
7228
	var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/;
7229
7230
	var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/;
7231
7232
	var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
7233
7234
	var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/;
7235
7236
	var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
7237
7238
	var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/;
7239
7240
	var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/;
7241
7242
	/*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7243
7244
	/* See LICENSE file for terms of use */
7245
7246
	/*
7247
	 * Text diff implementation.
7248
	 *
7249
	 * This library supports the following APIS:
7250
	 * JsDiff.diffChars: Character by character diff
7251
	 * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
7252
	 * JsDiff.diffLines: Line based diff
7253
	 *
7254
	 * JsDiff.diffCss: Diff targeted at CSS content
7255
	 *
7256
	 * These methods are based on the implementation proposed in
7257
	 * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
7258
	 * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
7259
	 */
7260
	exports. /*istanbul ignore end*/Diff = _base2['default'];
7261
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
7262
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
7263
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
7264
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
7265
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
7266
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
7267
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
7268
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
7269
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
7270
	/*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
7271
	/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
7272
	/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
7273
	/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
7274
	/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
7275
	/*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
7276
	/*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge;
7277
	/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
7278
	/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
7279
	/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize;
7280
7281
7282
7283
/***/ }),
7284
/* 1 */
7285
/***/ (function(module, exports) {
7286
7287
	/*istanbul ignore start*/'use strict';
7288
7289
	exports.__esModule = true;
7290
	exports['default'] = /*istanbul ignore end*/Diff;
7291
	function Diff() {}
7292
7293
	Diff.prototype = {
7294 View Code Duplication
	  /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7295
	    /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7296
7297
	    var callback = options.callback;
7298
	    if (typeof options === 'function') {
7299
	      callback = options;
7300
	      options = {};
7301
	    }
7302
	    this.options = options;
7303
7304
	    var self = this;
7305
7306
	    function done(value) {
7307
	      if (callback) {
7308
	        setTimeout(function () {
7309
	          callback(undefined, value);
7310
	        }, 0);
7311
	        return true;
7312
	      } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
7313
	        return value;
7314
	      }
7315
	    }
7316
7317
	    // Allow subclasses to massage the input prior to running
7318
	    oldString = this.castInput(oldString);
7319
	    newString = this.castInput(newString);
7320
7321
	    oldString = this.removeEmpty(this.tokenize(oldString));
7322
	    newString = this.removeEmpty(this.tokenize(newString));
7323
7324
	    var newLen = newString.length,
7325
	        oldLen = oldString.length;
7326
	    var editLength = 1;
7327
	    var maxEditLength = newLen + oldLen;
7328
	    var bestPath = [{ newPos: -1, components: [] }];
7329
7330
	    // Seed editLength = 0, i.e. the content starts with the same values
7331
	    var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
7332
	    if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
7333
	      // Identity per the equality and tokenizer
7334
	      return done([{ value: this.join(newString), count: newString.length }]);
7335
	    }
7336
7337
	    // Main worker method. checks all permutations of a given edit length for acceptance.
7338
	    function execEditLength() {
7339
	      for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
7340
	        var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable basePath seems to be never used. Consider removing it.
Loading history...
7341
	        var addPath = bestPath[diagonalPath - 1],
7342
	            removePath = bestPath[diagonalPath + 1],
7343
	            _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
7344
	        if (addPath) {
7345
	          // No one else is going to attempt to use this value, clear it
7346
	          bestPath[diagonalPath - 1] = undefined;
7347
	        }
7348
7349
	        var canAdd = addPath && addPath.newPos + 1 < newLen,
7350
	            canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
7351
	        if (!canAdd && !canRemove) {
7352
	          // If this path is a terminal then prune
7353
	          bestPath[diagonalPath] = undefined;
7354
	          continue;
7355
	        }
7356
7357
	        // Select the diagonal that we want to branch from. We select the prior
7358
	        // path whose position in the new string is the farthest from the origin
7359
	        // and does not pass the bounds of the diff graph
7360
	        if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
7361
	          basePath = clonePath(removePath);
7362
	          self.pushComponent(basePath.components, undefined, true);
7363
	        } else {
7364
	          basePath = addPath; // No need to clone, we've pulled it from the list
7365
	          basePath.newPos++;
7366
	          self.pushComponent(basePath.components, true, undefined);
7367
	        }
7368
7369
	        _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
7370
7371
	        // If we have hit the end of both strings, then we are done
7372
	        if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
7373
	          return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
7374
	        } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
7375
	          // Otherwise track this path as a potential candidate and continue.
7376
	          bestPath[diagonalPath] = basePath;
7377
	        }
7378
	      }
7379
7380
	      editLength++;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
7381
	    }
7382
7383
	    // Performs the length of edit iteration. Is a bit fugly as this has to support the
7384
	    // sync and async mode which is never fun. Loops over execEditLength until a value
7385
	    // is produced.
7386
	    if (callback) {
7387
	      (function exec() {
7388
	        setTimeout(function () {
7389
	          // This should not happen, but we want to be safe.
7390
	          /* istanbul ignore next */
7391
	          if (editLength > maxEditLength) {
7392
	            return callback();
7393
	          }
7394
7395
	          if (!execEditLength()) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !execEditLength() is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
7396
	            exec();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
7397
	          }
7398
	        }, 0);
7399
	      })();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
7400
	    } else {
7401
	      while (editLength <= maxEditLength) {
7402
	        var ret = execEditLength();
7403
	        if (ret) {
7404
	          return ret;
7405
	        }
7406
	      }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
7407
	    }
7408
	  },
7409 View Code Duplication
	  /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7410
	    var last = components[components.length - 1];
7411
	    if (last && last.added === added && last.removed === removed) {
7412
	      // We need to clone here as the component clone operation is just
7413
	      // as shallow array clone
7414
	      components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
7415
	    } else {
7416
	      components.push({ count: 1, added: added, removed: removed });
7417
	    }
7418
	  },
7419 View Code Duplication
	  /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7420
	    var newLen = newString.length,
7421
	        oldLen = oldString.length,
7422
	        newPos = basePath.newPos,
7423
	        oldPos = newPos - diagonalPath,
7424
	        commonCount = 0;
7425
	    while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
7426
	      newPos++;
7427
	      oldPos++;
7428
	      commonCount++;
7429
	    }
7430
7431
	    if (commonCount) {
7432
	      basePath.components.push({ count: commonCount });
7433
	    }
7434
7435
	    basePath.newPos = newPos;
7436
	    return oldPos;
7437
	  },
7438
	  /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
7439
	    return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
7440
	  },
7441
	  /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
7442
	    var ret = [];
7443
	    for (var i = 0; i < array.length; i++) {
7444
	      if (array[i]) {
7445
	        ret.push(array[i]);
7446
	      }
7447
	    }
7448
	    return ret;
7449
	  },
7450
	  /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
7451
	    return value;
7452
	  },
7453
	  /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
7454
	    return value.split('');
7455
	  },
7456
	  /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
7457
	    return chars.join('');
7458
	  }
7459
	};
7460
7461 View Code Duplication
	function buildValues(diff, components, newString, oldString, useLongestToken) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7462
	  var componentPos = 0,
7463
	      componentLen = components.length,
7464
	      newPos = 0,
7465
	      oldPos = 0;
7466
7467
	  for (; componentPos < componentLen; componentPos++) {
7468
	    var component = components[componentPos];
7469
	    if (!component.removed) {
7470
	      if (!component.added && useLongestToken) {
7471
	        var value = newString.slice(newPos, newPos + component.count);
7472
	        value = value.map(function (value, i) {
7473
	          var oldValue = oldString[oldPos + i];
0 ignored issues
show
Bug introduced by
The variable oldPos is changed as part of the for loop for example by component.count on line 7485. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
7474
	          return oldValue.length > value.length ? oldValue : value;
7475
	        });
7476
7477
	        component.value = diff.join(value);
7478
	      } else {
7479
	        component.value = diff.join(newString.slice(newPos, newPos + component.count));
7480
	      }
7481
	      newPos += component.count;
7482
7483
	      // Common case
7484
	      if (!component.added) {
7485
	        oldPos += component.count;
7486
	      }
7487
	    } else {
7488
	      component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
7489
	      oldPos += component.count;
7490
7491
	      // Reverse add and remove so removes are output first to match common convention
7492
	      // The diffing algorithm is tied to add then remove output and this is the simplest
7493
	      // route to get the desired output with minimal overhead.
7494
	      if (componentPos && components[componentPos - 1].added) {
7495
	        var tmp = components[componentPos - 1];
7496
	        components[componentPos - 1] = components[componentPos];
7497
	        components[componentPos] = tmp;
7498
	      }
7499
	    }
7500
	  }
7501
7502
	  // Special case handle for when one terminal is ignored. For this case we merge the
7503
	  // terminal into the prior string and drop the change.
7504
	  var lastComponent = components[componentLen - 1];
7505
	  if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
7506
	    components[componentLen - 2].value += lastComponent.value;
7507
	    components.pop();
7508
	  }
7509
7510
	  return components;
7511
	}
7512
7513
	function clonePath(path) {
7514
	  return { newPos: path.newPos, components: path.components.slice(0) };
7515
	}
7516
7517
7518
7519
/***/ }),
7520
/* 2 */
7521
/***/ (function(module, exports, __webpack_require__) {
7522
7523
	/*istanbul ignore start*/'use strict';
7524
7525
	exports.__esModule = true;
7526
	exports.characterDiff = undefined;
7527
	exports. /*istanbul ignore end*/diffChars = diffChars;
7528
7529
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7530
7531
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7532
7533
	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7534
7535
	/*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7536
	function diffChars(oldStr, newStr, options) {
7537
	  return characterDiff.diff(oldStr, newStr, options);
7538
	}
7539
7540
7541
7542
/***/ }),
7543
/* 3 */
7544
/***/ (function(module, exports, __webpack_require__) {
7545
7546
	/*istanbul ignore start*/'use strict';
7547
7548
	exports.__esModule = true;
7549
	exports.wordDiff = undefined;
7550
	exports. /*istanbul ignore end*/diffWords = diffWords;
7551
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
7552
7553
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7554
7555
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7556
7557
	/*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
7558
7559
	/*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7560
7561
	/*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
7562
	//
7563
	// Ranges and exceptions:
7564
	// Latin-1 Supplement, 0080–00FF
7565
	//  - U+00D7  × Multiplication sign
7566
	//  - U+00F7  ÷ Division sign
7567
	// Latin Extended-A, 0100–017F
7568
	// Latin Extended-B, 0180–024F
7569
	// IPA Extensions, 0250–02AF
7570
	// Spacing Modifier Letters, 02B0–02FF
7571
	//  - U+02C7  ˇ &#711;  Caron
7572
	//  - U+02D8  ˘ &#728;  Breve
7573
	//  - U+02D9  ˙ &#729;  Dot Above
7574
	//  - U+02DA  ˚ &#730;  Ring Above
7575
	//  - U+02DB  ˛ &#731;  Ogonek
7576
	//  - U+02DC  ˜ &#732;  Small Tilde
7577
	//  - U+02DD  ˝ &#733;  Double Acute Accent
7578
	// Latin Extended Additional, 1E00–1EFF
7579
	var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
7580
7581
	var reWhitespace = /\S/;
7582
7583
	var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7584
	wordDiff.equals = function (left, right) {
7585
	  if (this.options.ignoreCase) {
7586
	    left = left.toLowerCase();
7587
	    right = right.toLowerCase();
7588
	  }
7589
	  return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
7590
	};
7591 View Code Duplication
	wordDiff.tokenize = function (value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7592
	  var tokens = value.split(/(\s+|\b)/);
7593
7594
	  // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
7595
	  for (var i = 0; i < tokens.length - 1; i++) {
7596
	    // If we have an empty string in the next field and we have only word chars before and after, merge
7597
	    if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
7598
	      tokens[i] += tokens[i + 2];
7599
	      tokens.splice(i + 1, 2);
7600
	      i--;
0 ignored issues
show
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable i here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
7601
	    }
7602
	  }
7603
7604
	  return tokens;
7605
	};
7606
7607
	function diffWords(oldStr, newStr, options) {
7608
	  options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true });
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
7609
	  return wordDiff.diff(oldStr, newStr, options);
7610
	}
7611
7612
	function diffWordsWithSpace(oldStr, newStr, options) {
7613
	  return wordDiff.diff(oldStr, newStr, options);
7614
	}
7615
7616
7617
7618
/***/ }),
7619
/* 4 */
7620
/***/ (function(module, exports) {
7621
7622
	/*istanbul ignore start*/'use strict';
7623
7624
	exports.__esModule = true;
7625
	exports. /*istanbul ignore end*/generateOptions = generateOptions;
7626
	function generateOptions(options, defaults) {
7627
	  if (typeof options === 'function') {
7628
	    defaults.callback = options;
7629
	  } else if (options) {
7630
	    for (var name in options) {
7631
	      /* istanbul ignore else */
7632
	      if (options.hasOwnProperty(name)) {
7633
	        defaults[name] = options[name];
7634
	      }
7635
	    }
7636
	  }
7637
	  return defaults;
7638
	}
7639
7640
7641
7642
/***/ }),
7643
/* 5 */
7644
/***/ (function(module, exports, __webpack_require__) {
7645
7646
	/*istanbul ignore start*/'use strict';
7647
7648
	exports.__esModule = true;
7649
	exports.lineDiff = undefined;
7650
	exports. /*istanbul ignore end*/diffLines = diffLines;
7651
	/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
7652
7653
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7654
7655
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7656
7657
	/*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/;
7658
7659
	/*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7660
7661
	/*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7662 View Code Duplication
	lineDiff.tokenize = function (value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7663
	  var retLines = [],
7664
	      linesAndNewlines = value.split(/(\n|\r\n)/);
7665
7666
	  // Ignore the final empty token that occurs if the string ends with a new line
7667
	  if (!linesAndNewlines[linesAndNewlines.length - 1]) {
7668
	    linesAndNewlines.pop();
7669
	  }
7670
7671
	  // Merge the content and line separators into single tokens
7672
	  for (var i = 0; i < linesAndNewlines.length; i++) {
7673
	    var line = linesAndNewlines[i];
7674
7675
	    if (i % 2 && !this.options.newlineIsToken) {
7676
	      retLines[retLines.length - 1] += line;
7677
	    } else {
7678
	      if (this.options.ignoreWhitespace) {
7679
	        line = line.trim();
7680
	      }
7681
	      retLines.push(line);
7682
	    }
7683
	  }
7684
7685
	  return retLines;
7686
	};
7687
7688
	function diffLines(oldStr, newStr, callback) {
7689
	  return lineDiff.diff(oldStr, newStr, callback);
7690
	}
7691
	function diffTrimmedLines(oldStr, newStr, callback) {
7692
	  var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
7693
	  return lineDiff.diff(oldStr, newStr, options);
7694
	}
7695
7696
7697
7698
/***/ }),
7699
/* 6 */
7700
/***/ (function(module, exports, __webpack_require__) {
7701
7702
	/*istanbul ignore start*/'use strict';
7703
7704
	exports.__esModule = true;
7705
	exports.sentenceDiff = undefined;
7706
	exports. /*istanbul ignore end*/diffSentences = diffSentences;
7707
7708
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7709
7710
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7711
7712
	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7713
7714
	/*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7715
	sentenceDiff.tokenize = function (value) {
7716
	  return value.split(/(\S.+?[.!?])(?=\s+|$)/);
7717
	};
7718
7719
	function diffSentences(oldStr, newStr, callback) {
7720
	  return sentenceDiff.diff(oldStr, newStr, callback);
7721
	}
7722
7723
7724
7725
/***/ }),
7726
/* 7 */
7727
/***/ (function(module, exports, __webpack_require__) {
7728
7729
	/*istanbul ignore start*/'use strict';
7730
7731
	exports.__esModule = true;
7732
	exports.cssDiff = undefined;
7733
	exports. /*istanbul ignore end*/diffCss = diffCss;
7734
7735
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7736
7737
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7738
7739
	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7740
7741
	/*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7742
	cssDiff.tokenize = function (value) {
7743
	  return value.split(/([{}:;,]|\s+)/);
7744
	};
7745
7746
	function diffCss(oldStr, newStr, callback) {
7747
	  return cssDiff.diff(oldStr, newStr, callback);
7748
	}
7749
7750
7751
7752
/***/ }),
7753
/* 8 */
7754
/***/ (function(module, exports, __webpack_require__) {
7755
7756
	/*istanbul ignore start*/'use strict';
7757
7758
	exports.__esModule = true;
7759
	exports.jsonDiff = undefined;
7760
7761 View Code Duplication
	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; };
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7762
7763
	exports. /*istanbul ignore end*/diffJson = diffJson;
7764
	/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
7765
7766
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7767
7768
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7769
7770
	/*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
7771
7772
	/*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7773
7774
	/*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString;
7775
7776
	var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7777
	// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
7778
	// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
7779
	jsonDiff.useLongestToken = true;
7780
7781
	jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
7782
	jsonDiff.castInput = function (value) {
7783
	  /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement;
7784
7785
7786
	  return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
7787
	    if (typeof v === 'undefined') {
7788
	      return undefinedReplacement;
7789
	    }
7790
7791
	    return v;
7792
	  }, '  ');
7793
	};
7794
	jsonDiff.equals = function (left, right) {
7795
	  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'))
7796
	  );
7797
	};
7798
7799
	function diffJson(oldObj, newObj, options) {
7800
	  return jsonDiff.diff(oldObj, newObj, options);
7801
	}
7802
7803
	// This function handles the presence of circular references by bailing out when encountering an
7804
	// object that is already on the "stack" of items being processed.
7805 View Code Duplication
	function canonicalize(obj, stack, replacementStack) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7806
	  stack = stack || [];
7807
	  replacementStack = replacementStack || [];
7808
7809
	  var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable i seems to be never used. Consider removing it.
Loading history...
7810
7811
	  for (i = 0; i < stack.length; i += 1) {
7812
	    if (stack[i] === obj) {
7813
	      return replacementStack[i];
7814
	    }
7815
	  }
7816
7817
	  var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable canonicalizedObj seems to be never used. Consider removing it.
Loading history...
7818
7819
	  if ('[object Array]' === objectPrototypeToString.call(obj)) {
7820
	    stack.push(obj);
7821
	    canonicalizedObj = new Array(obj.length);
7822
	    replacementStack.push(canonicalizedObj);
7823
	    for (i = 0; i < obj.length; i += 1) {
7824
	      canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
7825
	    }
7826
	    stack.pop();
7827
	    replacementStack.pop();
7828
	    return canonicalizedObj;
7829
	  }
7830
7831
	  if (obj && obj.toJSON) {
7832
	    obj = obj.toJSON();
7833
	  }
7834
7835
	  if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
7836
	    stack.push(obj);
7837
	    canonicalizedObj = {};
7838
	    replacementStack.push(canonicalizedObj);
7839
	    var sortedKeys = [],
7840
	        key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable key seems to be never used. Consider removing it.
Loading history...
7841
	    for (key in obj) {
7842
	      /* istanbul ignore else */
7843
	      if (obj.hasOwnProperty(key)) {
7844
	        sortedKeys.push(key);
7845
	      }
7846
	    }
7847
	    sortedKeys.sort();
7848
	    for (i = 0; i < sortedKeys.length; i += 1) {
7849
	      key = sortedKeys[i];
7850
	      canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
7851
	    }
7852
	    stack.pop();
7853
	    replacementStack.pop();
7854
	  } else {
7855
	    canonicalizedObj = obj;
7856
	  }
7857
	  return canonicalizedObj;
7858
	}
7859
7860
7861
7862
/***/ }),
7863
/* 9 */
7864
/***/ (function(module, exports, __webpack_require__) {
7865
7866
	/*istanbul ignore start*/'use strict';
7867
7868
	exports.__esModule = true;
7869
	exports.arrayDiff = undefined;
7870
	exports. /*istanbul ignore end*/diffArrays = diffArrays;
7871
7872
	var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/;
7873
7874
	/*istanbul ignore start*/var _base2 = _interopRequireDefault(_base);
7875
7876
	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7877
7878
	/*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
7879
	arrayDiff.tokenize = arrayDiff.join = function (value) {
7880
	  return value.slice();
7881
	};
7882
7883
	function diffArrays(oldArr, newArr, callback) {
7884
	  return arrayDiff.diff(oldArr, newArr, callback);
7885
	}
7886
7887
7888
7889
/***/ }),
7890
/* 10 */
7891
/***/ (function(module, exports, __webpack_require__) {
7892
7893
	/*istanbul ignore start*/'use strict';
7894
7895
	exports.__esModule = true;
7896
	exports. /*istanbul ignore end*/applyPatch = applyPatch;
7897
	/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
7898
7899
	var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
7900
7901
	var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/;
7902
7903
	/*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
7904
7905
	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
7906
7907 View Code Duplication
	/*istanbul ignore end*/function applyPatch(source, uniDiff) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
7908
	  /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7909
7910
	  if (typeof uniDiff === 'string') {
7911
	    uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
7912
	  }
7913
7914
	  if (Array.isArray(uniDiff)) {
7915
	    if (uniDiff.length > 1) {
7916
	      throw new Error('applyPatch only works with a single input.');
7917
	    }
7918
7919
	    uniDiff = uniDiff[0];
7920
	  }
7921
7922
	  // Apply the diff to the input
7923
	  var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
7924
	      delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
7925
	      hunks = uniDiff.hunks,
7926
	      compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
7927
	    return (/*istanbul ignore end*/line === patchContent
7928
	    );
7929
	  },
7930
	      errorCount = 0,
7931
	      fuzzFactor = options.fuzzFactor || 0,
7932
	      minLine = 0,
7933
	      offset = 0,
7934
	      removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
7935
	      addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
7936
7937
	  /**
7938
	   * Checks if the hunk exactly fits on the provided location
7939
	   */
7940
	  function hunkFits(hunk, toPos) {
7941
	    for (var j = 0; j < hunk.lines.length; j++) {
7942
	      var line = hunk.lines[j],
7943
	          operation = line[0],
7944
	          content = line.substr(1);
7945
7946
	      if (operation === ' ' || operation === '-') {
7947
	        // Context sanity check
7948
	        if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
7949
	          errorCount++;
0 ignored issues
show
Bug introduced by
The variable errorCount is changed as part of the for loop for example by errorCount++ on line 7949. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
7950
7951
	          if (errorCount > fuzzFactor) {
7952
	            return false;
7953
	          }
7954
	        }
7955
	        toPos++;
7956
	      }
7957
	    }
7958
7959
	    return true;
7960
	  }
7961
7962
	  // Search best fit offsets for each hunk based on the previous ones
7963
	  for (var i = 0; i < hunks.length; i++) {
7964
	    var hunk = hunks[i],
7965
	        maxLine = lines.length - hunk.oldLines,
7966
	        localOffset = 0,
7967
	        toPos = offset + hunk.oldStart - 1;
7968
7969
	    var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
7970
7971
	    for (; localOffset !== undefined; localOffset = iterator()) {
7972
	      if (hunkFits(hunk, toPos + localOffset)) {
7973
	        hunk.offset = offset += localOffset;
7974
	        break;
7975
	      }
7976
	    }
7977
7978
	    if (localOffset === undefined) {
7979
	      return false;
7980
	    }
7981
7982
	    // Set lower text limit to end of the current hunk, so next ones don't try
7983
	    // to fit over already patched text
7984
	    minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
7985
	  }
7986
7987
	  // Apply patch hunks
7988
	  var diffOffset = 0;
7989
	  for (var _i = 0; _i < hunks.length; _i++) {
7990
	    var _hunk = hunks[_i],
7991
	        _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
7992
	    diffOffset += _hunk.newLines - _hunk.oldLines;
7993
7994
	    if (_toPos < 0) {
7995
	      // Creating a new file
7996
	      _toPos = 0;
7997
	    }
7998
7999
	    for (var j = 0; j < _hunk.lines.length; j++) {
8000
	      var line = _hunk.lines[j],
8001
	          operation = line[0],
8002
	          content = line.substr(1),
8003
	          delimiter = _hunk.linedelimiters[j];
8004
8005
	      if (operation === ' ') {
8006
	        _toPos++;
8007
	      } else if (operation === '-') {
8008
	        lines.splice(_toPos, 1);
8009
	        delimiters.splice(_toPos, 1);
8010
	        /* istanbul ignore else */
8011
	      } else if (operation === '+') {
8012
	        lines.splice(_toPos, 0, content);
8013
	        delimiters.splice(_toPos, 0, delimiter);
8014
	        _toPos++;
8015
	      } else if (operation === '\\') {
8016
	        var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
8017
	        if (previousOperation === '+') {
8018
	          removeEOFNL = true;
8019
	        } else if (previousOperation === '-') {
8020
	          addEOFNL = true;
8021
	        }
8022
	      }
8023
	    }
8024
	  }
8025
8026
	  // Handle EOFNL insertion/removal
8027
	  if (removeEOFNL) {
8028
	    while (!lines[lines.length - 1]) {
8029
	      lines.pop();
8030
	      delimiters.pop();
8031
	    }
8032
	  } else if (addEOFNL) {
8033
	    lines.push('');
8034
	    delimiters.push('\n');
8035
	  }
8036
	  for (var _k = 0; _k < lines.length - 1; _k++) {
8037
	    lines[_k] = lines[_k] + delimiters[_k];
8038
	  }
8039
	  return lines.join('');
8040
	}
8041
8042
	// Wrapper that supports multiple file patches via callbacks.
8043 View Code Duplication
	function applyPatches(uniDiff, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8044
	  if (typeof uniDiff === 'string') {
8045
	    uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8046
	  }
8047
8048
	  var currentIndex = 0;
8049
	  function processIndex() {
8050
	    var index = uniDiff[currentIndex++];
8051
	    if (!index) {
8052
	      return options.complete();
8053
	    }
8054
8055
	    options.loadFile(index, function (err, data) {
8056
	      if (err) {
8057
	        return options.complete(err);
8058
	      }
8059
8060
	      var updatedContent = applyPatch(data, index, options);
8061
	      options.patched(index, updatedContent, function (err) {
8062
	        if (err) {
8063
	          return options.complete(err);
8064
	        }
8065
8066
	        processIndex();
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
8067
	      });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
8068
	    });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
8069
	  }
8070
	  processIndex();
8071
	}
8072
8073
8074
8075
/***/ }),
8076
/* 11 */
8077
/***/ (function(module, exports) {
8078
8079
	/*istanbul ignore start*/'use strict';
8080
8081
	exports.__esModule = true;
8082
	exports. /*istanbul ignore end*/parsePatch = parsePatch;
8083 View Code Duplication
	function parsePatch(uniDiff) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8084
	  /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
8085
8086
	  var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
8087
	      delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
8088
	      list = [],
8089
	      i = 0;
8090
8091
	  function parseIndex() {
8092
	    var index = {};
8093
	    list.push(index);
8094
8095
	    // Parse diff metadata
8096
	    while (i < diffstr.length) {
0 ignored issues
show
Bug introduced by
The variable i is changed as part of the while loop for example by i++ on line 8110. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
8097
	      var line = diffstr[i];
8098
8099
	      // File header found, end parsing diff metadata
8100
	      if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
8101
	        break;
8102
	      }
8103
8104
	      // Diff index
8105
	      var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
8106
	      if (header) {
8107
	        index.index = header[1];
8108
	      }
8109
8110
	      i++;
8111
	    }
8112
8113
	    // Parse file headers if they are defined. Unified diff requires them, but
8114
	    // there's no technical issues to have an isolated hunk without file header
8115
	    parseFileHeader(index);
8116
	    parseFileHeader(index);
8117
8118
	    // Parse hunks
8119
	    index.hunks = [];
8120
8121
	    while (i < diffstr.length) {
8122
	      var _line = diffstr[i];
8123
8124
	      if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
8125
	        break;
8126
	      } else if (/^@@/.test(_line)) {
8127
	        index.hunks.push(parseHunk());
8128
	      } else if (_line && options.strict) {
8129
	        // Ignore unexpected content unless in strict mode
8130
	        throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
8131
	      } else {
8132
	        i++;
8133
	      }
8134
	    }
8135
	  }
8136
8137
	  // Parses the --- and +++ headers, if none are found, no lines
8138
	  // are consumed.
8139
	  function parseFileHeader(index) {
8140
	    var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
8141
	    var fileHeader = headerPattern.exec(diffstr[i]);
8142
	    if (fileHeader) {
8143
	      var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
8144
	      var fileName = fileHeader[2].replace(/\\\\/g, '\\');
8145
	      if (/^".*"$/.test(fileName)) {
8146
	        fileName = fileName.substr(1, fileName.length - 2);
8147
	      }
8148
	      index[keyPrefix + 'FileName'] = fileName;
8149
	      index[keyPrefix + 'Header'] = fileHeader[3];
8150
8151
	      i++;
8152
	    }
8153
	  }
8154
8155
	  // Parses a hunk
8156
	  // This assumes that we are at the start of a hunk.
8157
	  function parseHunk() {
8158
	    var chunkHeaderIndex = i,
8159
	        chunkHeaderLine = diffstr[i++],
8160
	        chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
8161
8162
	    var hunk = {
8163
	      oldStart: +chunkHeader[1],
8164
	      oldLines: +chunkHeader[2] || 1,
8165
	      newStart: +chunkHeader[3],
8166
	      newLines: +chunkHeader[4] || 1,
8167
	      lines: [],
8168
	      linedelimiters: []
8169
	    };
8170
8171
	    var addCount = 0,
8172
	        removeCount = 0;
8173
	    for (; i < diffstr.length; i++) {
0 ignored issues
show
Bug introduced by
The variable i is changed as part of the for loop for example by i++ on line 8173. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
8174
	      // Lines starting with '---' could be mistaken for the "remove line" operation
8175
	      // But they could be the header for the next file. Therefore prune such cases out.
8176
	      if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
8177
	        break;
8178
	      }
8179
	      var operation = diffstr[i][0];
8180
8181
	      if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
8182
	        hunk.lines.push(diffstr[i]);
8183
	        hunk.linedelimiters.push(delimiters[i] || '\n');
8184
8185
	        if (operation === '+') {
8186
	          addCount++;
8187
	        } else if (operation === '-') {
8188
	          removeCount++;
8189
	        } else if (operation === ' ') {
8190
	          addCount++;
8191
	          removeCount++;
8192
	        }
8193
	      } else {
8194
	        break;
8195
	      }
8196
	    }
8197
8198
	    // Handle the empty block count case
8199
	    if (!addCount && hunk.newLines === 1) {
8200
	      hunk.newLines = 0;
8201
	    }
8202
	    if (!removeCount && hunk.oldLines === 1) {
8203
	      hunk.oldLines = 0;
8204
	    }
8205
8206
	    // Perform optional sanity checking
8207
	    if (options.strict) {
8208
	      if (addCount !== hunk.newLines) {
8209
	        throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
8210
	      }
8211
	      if (removeCount !== hunk.oldLines) {
8212
	        throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
8213
	      }
8214
	    }
8215
8216
	    return hunk;
8217
	  }
8218
8219
	  while (i < diffstr.length) {
8220
	    parseIndex();
8221
	  }
8222
8223
	  return list;
8224
	}
8225
8226
8227
8228
/***/ }),
8229
/* 12 */
8230
/***/ (function(module, exports) {
8231
8232
	/*istanbul ignore start*/"use strict";
8233
8234
	exports.__esModule = true;
8235
8236 View Code Duplication
	exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8237
	  var wantForward = true,
8238
	      backwardExhausted = false,
8239
	      forwardExhausted = false,
8240
	      localOffset = 1;
8241
8242
	  return function iterator() {
8243
	    if (wantForward && !forwardExhausted) {
8244
	      if (backwardExhausted) {
8245
	        localOffset++;
8246
	      } else {
8247
	        wantForward = false;
8248
	      }
8249
8250
	      // Check if trying to fit beyond text length, and if not, check it fits
8251
	      // after offset location (or desired location on first iteration)
8252
	      if (start + localOffset <= maxLine) {
8253
	        return localOffset;
8254
	      }
8255
8256
	      forwardExhausted = true;
8257
	    }
8258
8259
	    if (!backwardExhausted) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if !backwardExhausted is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
8260
	      if (!forwardExhausted) {
8261
	        wantForward = true;
8262
	      }
8263
8264
	      // Check if trying to fit before text beginning, and if not, check it fits
8265
	      // before offset location
8266
	      if (minLine <= start - localOffset) {
8267
	        return -localOffset++;
8268
	      }
8269
8270
	      backwardExhausted = true;
8271
	      return iterator();
8272
	    }
8273
8274
	    // We tried to fit hunk before text beginning and beyond text length, then
8275
	    // hunk can't fit on the text. Return undefined
8276
	  };
8277
	};
8278
8279
8280
8281
/***/ }),
8282
/* 13 */
8283
/***/ (function(module, exports, __webpack_require__) {
8284
8285
	/*istanbul ignore start*/'use strict';
8286
8287
	exports.__esModule = true;
8288
	exports. /*istanbul ignore end*/calcLineCount = calcLineCount;
8289
	/*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge;
8290
8291
	var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/;
8292
8293
	var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/;
8294
8295
	var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/;
8296
8297
	/*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); } }
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
8298
8299 View Code Duplication
	/*istanbul ignore end*/function calcLineCount(hunk) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8300
	  var conflicted = false;
8301
8302
	  hunk.oldLines = 0;
8303
	  hunk.newLines = 0;
8304
8305
	  hunk.lines.forEach(function (line) {
8306
	    if (typeof line !== 'string') {
8307
	      conflicted = true;
8308
	      return;
8309
	    }
8310
8311
	    if (line[0] === '+' || line[0] === ' ') {
8312
	      hunk.newLines++;
8313
	    }
8314
	    if (line[0] === '-' || line[0] === ' ') {
8315
	      hunk.oldLines++;
8316
	    }
8317
	  });
8318
8319
	  if (conflicted) {
8320
	    delete hunk.oldLines;
8321
	    delete hunk.newLines;
8322
	  }
8323
	}
8324
8325 View Code Duplication
	function merge(mine, theirs, base) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8326
	  mine = loadPatch(mine, base);
8327
	  theirs = loadPatch(theirs, base);
8328
8329
	  var ret = {};
8330
8331
	  // For index we just let it pass through as it doesn't have any necessary meaning.
8332
	  // Leaving sanity checks on this to the API consumer that may know more about the
8333
	  // meaning in their own context.
8334
	  if (mine.index || theirs.index) {
8335
	    ret.index = mine.index || theirs.index;
8336
	  }
8337
8338
	  if (mine.newFileName || theirs.newFileName) {
8339
	    if (!fileNameChanged(mine)) {
8340
	      // No header or no change in ours, use theirs (and ours if theirs does not exist)
8341
	      ret.oldFileName = theirs.oldFileName || mine.oldFileName;
8342
	      ret.newFileName = theirs.newFileName || mine.newFileName;
8343
	      ret.oldHeader = theirs.oldHeader || mine.oldHeader;
8344
	      ret.newHeader = theirs.newHeader || mine.newHeader;
8345
	    } else if (!fileNameChanged(theirs)) {
8346
	      // No header or no change in theirs, use ours
8347
	      ret.oldFileName = mine.oldFileName;
8348
	      ret.newFileName = mine.newFileName;
8349
	      ret.oldHeader = mine.oldHeader;
8350
	      ret.newHeader = mine.newHeader;
8351
	    } else {
8352
	      // Both changed... figure it out
8353
	      ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName);
8354
	      ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName);
8355
	      ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader);
8356
	      ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
8357
	    }
8358
	  }
8359
8360
	  ret.hunks = [];
8361
8362
	  var mineIndex = 0,
8363
	      theirsIndex = 0,
8364
	      mineOffset = 0,
8365
	      theirsOffset = 0;
8366
8367
	  while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
8368
	    var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity },
8369
	        theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity };
8370
8371
	    if (hunkBefore(mineCurrent, theirsCurrent)) {
8372
	      // This patch does not overlap with any of the others, yay.
8373
	      ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
8374
	      mineIndex++;
8375
	      theirsOffset += mineCurrent.newLines - mineCurrent.oldLines;
8376
	    } else if (hunkBefore(theirsCurrent, mineCurrent)) {
8377
	      // This patch does not overlap with any of the others, yay.
8378
	      ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset));
8379
	      theirsIndex++;
8380
	      mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines;
8381
	    } else {
8382
	      // Overlap, merge as best we can
8383
	      var mergedHunk = {
8384
	        oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart),
8385
	        oldLines: 0,
8386
	        newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset),
8387
	        newLines: 0,
8388
	        lines: []
8389
	      };
8390
	      mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines);
8391
	      theirsIndex++;
8392
	      mineIndex++;
8393
8394
	      ret.hunks.push(mergedHunk);
8395
	    }
8396
	  }
8397
8398
	  return ret;
8399
	}
8400
8401
	function loadPatch(param, base) {
8402
	  if (typeof param === 'string') {
8403
	    if (/^@@/m.test(param) || /^Index:/m.test(param)) {
8404
	      return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0]
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8405
	      );
8406
	    }
8407
8408
	    if (!base) {
8409
	      throw new Error('Must provide a base reference or pass in a patch');
8410
	    }
8411
	    return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param)
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8412
	    );
8413
	  }
8414
8415
	  return param;
8416
	}
8417
8418
	function fileNameChanged(patch) {
8419
	  return patch.newFileName && patch.newFileName !== patch.oldFileName;
8420
	}
8421
8422
	function selectField(index, mine, theirs) {
8423
	  if (mine === theirs) {
8424
	    return mine;
8425
	  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
8426
	    index.conflict = true;
8427
	    return { mine: mine, theirs: theirs };
8428
	  }
8429
	}
8430
8431
	function hunkBefore(test, check) {
8432
	  return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
8433
	}
8434
8435
	function cloneHunk(hunk, offset) {
8436
	  return {
8437
	    oldStart: hunk.oldStart, oldLines: hunk.oldLines,
8438
	    newStart: hunk.newStart + offset, newLines: hunk.newLines,
8439
	    lines: hunk.lines
8440
	  };
8441
	}
8442
8443 View Code Duplication
	function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8444
	  // This will generally result in a conflicted hunk, but there are cases where the context
8445
	  // is the only overlap where we can successfully merge the content here.
8446
	  var mine = { offset: mineOffset, lines: mineLines, index: 0 },
8447
	      their = { offset: theirOffset, lines: theirLines, index: 0 };
8448
8449
	  // Handle any leading content
8450
	  insertLeading(hunk, mine, their);
8451
	  insertLeading(hunk, their, mine);
8452
8453
	  // Now in the overlap content. Scan through and select the best changes from each.
8454
	  while (mine.index < mine.lines.length && their.index < their.lines.length) {
8455
	    var mineCurrent = mine.lines[mine.index],
8456
	        theirCurrent = their.lines[their.index];
8457
8458
	    if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
8459
	      // Both modified ...
8460
	      mutualChange(hunk, mine, their);
8461
	    } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
8462
	      /*istanbul ignore start*/var _hunk$lines;
8463
8464
	      /*istanbul ignore end*/ // Mine inserted
8465
	      /*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)));
8466
	    } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
8467
	      /*istanbul ignore start*/var _hunk$lines2;
8468
8469
	      /*istanbul ignore end*/ // Theirs inserted
8470
	      /*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)));
8471
	    } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') {
8472
	      // Mine removed or edited
8473
	      removal(hunk, mine, their);
8474
	    } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') {
8475
	      // Their removed or edited
8476
	      removal(hunk, their, mine, true);
8477
	    } else if (mineCurrent === theirCurrent) {
8478
	      // Context identity
8479
	      hunk.lines.push(mineCurrent);
8480
	      mine.index++;
8481
	      their.index++;
8482
	    } else {
8483
	      // Context mismatch
8484
	      conflict(hunk, collectChange(mine), collectChange(their));
8485
	    }
8486
	  }
8487
8488
	  // Now push anything that may be remaining
8489
	  insertTrailing(hunk, mine);
8490
	  insertTrailing(hunk, their);
8491
8492
	  calcLineCount(hunk);
8493
	}
8494
8495 View Code Duplication
	function mutualChange(hunk, mine, their) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8496
	  var myChanges = collectChange(mine),
8497
	      theirChanges = collectChange(their);
8498
8499
	  if (allRemoves(myChanges) && allRemoves(theirChanges)) {
8500
	    // Special case for remove changes that are supersets of one another
8501
	    if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8502
	      /*istanbul ignore start*/var _hunk$lines3;
8503
8504
	      /*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));
8505
	      return;
8506
	    } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8507
	      /*istanbul ignore start*/var _hunk$lines4;
8508
8509
	      /*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));
8510
	      return;
8511
	    }
8512
	  } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) {
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8513
	    /*istanbul ignore start*/var _hunk$lines5;
8514
8515
	    /*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));
8516
	    return;
8517
	  }
8518
8519
	  conflict(hunk, myChanges, theirChanges);
8520
	}
8521
8522
	function removal(hunk, mine, their, swap) {
8523
	  var myChanges = collectChange(mine),
8524
	      theirChanges = collectContext(their, myChanges);
8525
	  if (theirChanges.merged) {
8526
	    /*istanbul ignore start*/var _hunk$lines6;
8527
8528
	    /*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));
8529
	  } else {
8530
	    conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
8531
	  }
8532
	}
8533
8534
	function conflict(hunk, mine, their) {
8535
	  hunk.conflict = true;
8536
	  hunk.lines.push({
8537
	    conflict: true,
8538
	    mine: mine,
8539
	    theirs: their
8540
	  });
8541
	}
8542
8543
	function insertLeading(hunk, insert, their) {
8544
	  while (insert.offset < their.offset && insert.index < insert.lines.length) {
8545
	    var line = insert.lines[insert.index++];
8546
	    hunk.lines.push(line);
8547
	    insert.offset++;
8548
	  }
8549
	}
8550
	function insertTrailing(hunk, insert) {
8551
	  while (insert.index < insert.lines.length) {
8552
	    var line = insert.lines[insert.index++];
8553
	    hunk.lines.push(line);
8554
	  }
8555
	}
8556
8557 View Code Duplication
	function collectChange(state) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8558
	  var ret = [],
8559
	      operation = state.lines[state.index][0];
8560
	  while (state.index < state.lines.length) {
8561
	    var line = state.lines[state.index];
8562
8563
	    // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
8564
	    if (operation === '-' && line[0] === '+') {
8565
	      operation = '+';
8566
	    }
8567
8568
	    if (operation === line[0]) {
8569
	      ret.push(line);
8570
	      state.index++;
8571
	    } else {
8572
	      break;
8573
	    }
8574
	  }
8575
8576
	  return ret;
8577
	}
8578 View Code Duplication
	function collectContext(state, matchChanges) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8579
	  var changes = [],
8580
	      merged = [],
8581
	      matchIndex = 0,
8582
	      contextChanges = false,
8583
	      conflicted = false;
8584
	  while (matchIndex < matchChanges.length && state.index < state.lines.length) {
8585
	    var change = state.lines[state.index],
8586
	        match = matchChanges[matchIndex];
8587
8588
	    // Once we've hit our add, then we are done
8589
	    if (match[0] === '+') {
8590
	      break;
8591
	    }
8592
8593
	    contextChanges = contextChanges || change[0] !== ' ';
8594
8595
	    merged.push(match);
8596
	    matchIndex++;
8597
8598
	    // Consume any additions in the other block as a conflict to attempt
8599
	    // to pull in the remaining context after this
8600
	    if (change[0] === '+') {
8601
	      conflicted = true;
8602
8603
	      while (change[0] === '+') {
8604
	        changes.push(change);
8605
	        change = state.lines[++state.index];
8606
	      }
8607
	    }
8608
8609
	    if (match.substr(1) === change.substr(1)) {
8610
	      changes.push(change);
8611
	      state.index++;
8612
	    } else {
8613
	      conflicted = true;
8614
	    }
8615
	  }
8616
8617
	  if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
8618
	    conflicted = true;
8619
	  }
8620
8621
	  if (conflicted) {
8622
	    return changes;
8623
	  }
8624
8625
	  while (matchIndex < matchChanges.length) {
8626
	    merged.push(matchChanges[matchIndex++]);
8627
	  }
8628
8629
	  return {
8630
	    merged: merged,
8631
	    changes: changes
8632
	  };
8633
	}
8634
8635
	function allRemoves(changes) {
8636
	  return changes.reduce(function (prev, change) {
8637
	    return prev && change[0] === '-';
8638
	  }, true);
8639
	}
8640
	function skipRemoveSuperset(state, removeChanges, delta) {
8641
	  for (var i = 0; i < delta; i++) {
8642
	    var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
8643
	    if (state.lines[state.index + i] !== ' ' + changeContent) {
8644
	      return false;
8645
	    }
8646
	  }
8647
8648
	  state.index += delta;
8649
	  return true;
8650
	}
8651
8652
8653
8654
/***/ }),
8655
/* 14 */
8656
/***/ (function(module, exports, __webpack_require__) {
8657
8658
	/*istanbul ignore start*/'use strict';
8659
8660
	exports.__esModule = true;
8661
	exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
8662
	/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
8663
	/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
8664
8665
	var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/;
8666
8667
	/*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); } }
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
8668
8669 View Code Duplication
	/*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8670
	  if (!options) {
8671
	    options = {};
8672
	  }
8673
	  if (typeof options.context === 'undefined') {
8674
	    options.context = 4;
8675
	  }
8676
8677
	  var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
0 ignored issues
show
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
8678
	  diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
8679
8680
	  function contextLines(lines) {
8681
	    return lines.map(function (entry) {
8682
	      return ' ' + entry;
8683
	    });
8684
	  }
8685
8686
	  var hunks = [];
8687
	  var oldRangeStart = 0,
8688
	      newRangeStart = 0,
8689
	      curRange = [],
8690
	      oldLine = 1,
8691
	      newLine = 1;
8692
8693
	  /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) {
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable _loop already seems to be declared on line 8693. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
8694
	    var current = diff[i],
8695
	        lines = current.lines || current.value.replace(/\n$/, '').split('\n');
8696
	    current.lines = lines;
8697
8698
	    if (current.added || current.removed) {
8699
	      /*istanbul ignore start*/var _curRange;
8700
8701
	      /*istanbul ignore end*/ // If we have previous context, start with that
8702
	      if (!oldRangeStart) {
8703
	        var prev = diff[i - 1];
8704
	        oldRangeStart = oldLine;
8705
	        newRangeStart = newLine;
8706
8707
	        if (prev) {
8708
	          curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
8709
	          oldRangeStart -= curRange.length;
8710
	          newRangeStart -= curRange.length;
8711
	        }
8712
	      }
8713
8714
	      // Output our changes
8715
	      /*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) {
8716
	        return (current.added ? '+' : '-') + entry;
8717
	      })));
8718
8719
	      // Track the updated file position
8720
	      if (current.added) {
8721
	        newLine += lines.length;
8722
	      } else {
8723
	        oldLine += lines.length;
8724
	      }
8725
	    } else {
8726
	      // Identical context lines. Track line changes
8727
	      if (oldRangeStart) {
8728
	        // Close out any changes that have been output (or join overlapping)
8729
	        if (lines.length <= options.context * 2 && i < diff.length - 2) {
8730
	          /*istanbul ignore start*/var _curRange2;
8731
8732
	          /*istanbul ignore end*/ // Overlapping
8733
	          /*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)));
8734
	        } else {
8735
	          /*istanbul ignore start*/var _curRange3;
8736
8737
	          /*istanbul ignore end*/ // end the range and output
8738
	          var contextSize = Math.min(lines.length, options.context);
8739
	          /*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))));
8740
8741
	          var hunk = {
8742
	            oldStart: oldRangeStart,
8743
	            oldLines: oldLine - oldRangeStart + contextSize,
8744
	            newStart: newRangeStart,
8745
	            newLines: newLine - newRangeStart + contextSize,
8746
	            lines: curRange
8747
	          };
8748
	          if (i >= diff.length - 2 && lines.length <= options.context) {
8749
	            // EOF is inside this hunk
8750
	            var oldEOFNewline = /\n$/.test(oldStr);
8751
	            var newEOFNewline = /\n$/.test(newStr);
8752
	            if (lines.length == 0 && !oldEOFNewline) {
0 ignored issues
show
Best Practice introduced by
Comparing lines.length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
8753
	              // special case: old has no eol and no trailing context; no-nl can end up before adds
8754
	              curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
8755
	            } else if (!oldEOFNewline || !newEOFNewline) {
8756
	              curRange.push('\\ No newline at end of file');
8757
	            }
8758
	          }
8759
	          hunks.push(hunk);
8760
8761
	          oldRangeStart = 0;
8762
	          newRangeStart = 0;
8763
	          curRange = [];
8764
	        }
8765
	      }
8766
	      oldLine += lines.length;
8767
	      newLine += lines.length;
8768
	    }
8769
	  };
8770
8771
	  for (var i = 0; i < diff.length; i++) {
8772
	    /*istanbul ignore start*/_loop( /*istanbul ignore end*/i);
8773
	  }
8774
8775
	  return {
8776
	    oldFileName: oldFileName, newFileName: newFileName,
8777
	    oldHeader: oldHeader, newHeader: newHeader,
8778
	    hunks: hunks
8779
	  };
8780
	}
8781
8782 View Code Duplication
	function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8783
	  var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
8784
8785
	  var ret = [];
8786
	  if (oldFileName == newFileName) {
8787
	    ret.push('Index: ' + oldFileName);
8788
	  }
8789
	  ret.push('===================================================================');
8790
	  ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
8791
	  ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
8792
8793
	  for (var i = 0; i < diff.hunks.length; i++) {
8794
	    var hunk = diff.hunks[i];
8795
	    ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
8796
	    ret.push.apply(ret, hunk.lines);
8797
	  }
8798
8799
	  return ret.join('\n') + '\n';
8800
	}
8801
8802
	function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
8803
	  return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
8804
	}
8805
8806
8807
8808
/***/ }),
8809
/* 15 */
8810
/***/ (function(module, exports) {
8811
8812
	/*istanbul ignore start*/"use strict";
8813
8814
	exports.__esModule = true;
8815
	exports. /*istanbul ignore end*/arrayEqual = arrayEqual;
8816
	/*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith;
8817
	function arrayEqual(a, b) {
8818
	  if (a.length !== b.length) {
8819
	    return false;
8820
	  }
8821
8822
	  return arrayStartsWith(a, b);
8823
	}
8824
8825
	function arrayStartsWith(array, start) {
8826
	  if (start.length > array.length) {
8827
	    return false;
8828
	  }
8829
8830
	  for (var i = 0; i < start.length; i++) {
8831
	    if (start[i] !== array[i]) {
8832
	      return false;
8833
	    }
8834
	  }
8835
8836
	  return true;
8837
	}
8838
8839
8840
8841
/***/ }),
8842
/* 16 */
8843
/***/ (function(module, exports) {
8844
8845
	/*istanbul ignore start*/"use strict";
8846
8847
	exports.__esModule = true;
8848
	exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
8849
	// See: http://code.google.com/p/google-diff-match-patch/wiki/API
8850 View Code Duplication
	function convertChangesToDMP(changes) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8851
	  var ret = [],
8852
	      change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable change seems to be never used. Consider removing it.
Loading history...
8853
	      operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
Unused Code introduced by
The assignment to variable operation seems to be never used. Consider removing it.
Loading history...
8854
	  for (var i = 0; i < changes.length; i++) {
8855
	    change = changes[i];
8856
	    if (change.added) {
8857
	      operation = 1;
8858
	    } else if (change.removed) {
8859
	      operation = -1;
8860
	    } else {
8861
	      operation = 0;
8862
	    }
8863
8864
	    ret.push([operation, change.value]);
8865
	  }
8866
	  return ret;
8867
	}
8868
8869
8870
8871
/***/ }),
8872
/* 17 */
8873
/***/ (function(module, exports) {
8874
8875
	/*istanbul ignore start*/'use strict';
8876
8877
	exports.__esModule = true;
8878
	exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
8879
	function convertChangesToXML(changes) {
8880
	  var ret = [];
8881
	  for (var i = 0; i < changes.length; i++) {
8882
	    var change = changes[i];
8883
	    if (change.added) {
8884
	      ret.push('<ins>');
8885
	    } else if (change.removed) {
8886
	      ret.push('<del>');
8887
	    }
8888
8889
	    ret.push(escapeHTML(change.value));
8890
8891
	    if (change.added) {
8892
	      ret.push('</ins>');
8893
	    } else if (change.removed) {
8894
	      ret.push('</del>');
8895
	    }
8896
	  }
8897
	  return ret.join('');
8898
	}
8899
8900
	function escapeHTML(s) {
8901
	  var n = s;
8902
	  n = n.replace(/&/g, '&amp;');
8903
	  n = n.replace(/</g, '&lt;');
8904
	  n = n.replace(/>/g, '&gt;');
8905
	  n = n.replace(/"/g, '&quot;');
8906
8907
	  return n;
8908
	}
8909
8910
8911
8912
/***/ })
8913
/******/ ])
8914
});
8915
;
8916
},{}],45:[function(require,module,exports){
8917
'use strict';
8918
8919
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
8920
8921
module.exports = function (str) {
8922
	if (typeof str !== 'string') {
8923
		throw new TypeError('Expected a string');
8924
	}
8925
8926
	return str.replace(matchOperatorsRe, '\\$&');
8927
};
8928
8929
},{}],46:[function(require,module,exports){
8930
// Copyright Joyent, Inc. and other Node contributors.
8931
//
8932
// Permission is hereby granted, free of charge, to any person obtaining a
8933
// copy of this software and associated documentation files (the
8934
// "Software"), to deal in the Software without restriction, including
8935
// without limitation the rights to use, copy, modify, merge, publish,
8936
// distribute, sublicense, and/or sell copies of the Software, and to permit
8937
// persons to whom the Software is furnished to do so, subject to the
8938
// following conditions:
8939
//
8940
// The above copyright notice and this permission notice shall be included
8941
// in all copies or substantial portions of the Software.
8942
//
8943
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8944
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8945
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8946
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8947
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8948
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8949
// USE OR OTHER DEALINGS IN THE SOFTWARE.
8950
8951
function EventEmitter() {
8952
  this._events = this._events || {};
8953
  this._maxListeners = this._maxListeners || undefined;
8954
}
8955
module.exports = EventEmitter;
8956
8957
// Backwards-compat with node 0.10.x
8958
EventEmitter.EventEmitter = EventEmitter;
8959
8960
EventEmitter.prototype._events = undefined;
8961
EventEmitter.prototype._maxListeners = undefined;
8962
8963
// By default EventEmitters will print a warning if more than 10 listeners are
8964
// added to it. This is a useful default which helps finding memory leaks.
8965
EventEmitter.defaultMaxListeners = 10;
8966
8967
// Obviously not all Emitters should be limited to 10. This function allows
8968
// that to be increased. Set to zero for unlimited.
8969
EventEmitter.prototype.setMaxListeners = function(n) {
8970
  if (!isNumber(n) || n < 0 || isNaN(n))
8971
    throw TypeError('n must be a positive number');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
8972
  this._maxListeners = n;
8973
  return this;
8974
};
8975
8976
EventEmitter.prototype.emit = function(type) {
8977
  var er, handler, len, args, i, listeners;
8978
8979
  if (!this._events)
8980
    this._events = {};
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
8981
8982
  // If there is no 'error' event listener then throw.
8983
  if (type === 'error') {
8984
    if (!this._events.error ||
8985
        (isObject(this._events.error) && !this._events.error.length)) {
8986
      er = arguments[1];
8987
      if (er instanceof Error) {
8988
        throw er; // Unhandled 'error' event
8989
      } else {
8990
        // At least give some kind of context to the user
8991
        var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
8992
        err.context = er;
8993
        throw err;
8994
      }
8995
    }
8996
  }
8997
8998
  handler = this._events[type];
8999
9000
  if (isUndefined(handler))
9001
    return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9002
9003
  if (isFunction(handler)) {
9004
    switch (arguments.length) {
9005
      // fast cases
9006
      case 1:
9007
        handler.call(this);
9008
        break;
9009
      case 2:
9010
        handler.call(this, arguments[1]);
9011
        break;
9012
      case 3:
9013
        handler.call(this, arguments[1], arguments[2]);
9014
        break;
9015
      // slower
9016
      default:
9017
        args = Array.prototype.slice.call(arguments, 1);
9018
        handler.apply(this, args);
9019
    }
9020
  } else if (isObject(handler)) {
9021
    args = Array.prototype.slice.call(arguments, 1);
9022
    listeners = handler.slice();
9023
    len = listeners.length;
9024
    for (i = 0; i < len; i++)
9025
      listeners[i].apply(this, args);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9026
  }
9027
9028
  return true;
9029
};
9030
9031
EventEmitter.prototype.addListener = function(type, listener) {
9032
  var m;
9033
9034
  if (!isFunction(listener))
9035
    throw TypeError('listener must be a function');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9036
9037
  if (!this._events)
9038
    this._events = {};
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9039
9040
  // To avoid recursion in the case that type === "newListener"! Before
9041
  // adding it to the listeners, first emit "newListener".
9042
  if (this._events.newListener)
9043
    this.emit('newListener', type,
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9044
              isFunction(listener.listener) ?
9045
              listener.listener : listener);
9046
9047
  if (!this._events[type])
9048
    // Optimize the case of one listener. Don't need the extra array object.
9049
    this._events[type] = listener;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9050
  else if (isObject(this._events[type]))
9051
    // If we've already got an array, just append.
9052
    this._events[type].push(listener);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9053
  else
9054
    // Adding the second element, need to change to array.
9055
    this._events[type] = [this._events[type], listener];
9056
9057
  // Check for listener leak
9058
  if (isObject(this._events[type]) && !this._events[type].warned) {
9059
    if (!isUndefined(this._maxListeners)) {
9060
      m = this._maxListeners;
9061
    } else {
9062
      m = EventEmitter.defaultMaxListeners;
9063
    }
9064
9065
    if (m && m > 0 && this._events[type].length > m) {
9066
      this._events[type].warned = true;
9067
      console.error('(node) warning: possible EventEmitter memory ' +
9068
                    'leak detected. %d listeners added. ' +
9069
                    'Use emitter.setMaxListeners() to increase limit.',
9070
                    this._events[type].length);
9071
      if (typeof console.trace === 'function') {
9072
        // not supported in IE 10
9073
        console.trace();
9074
      }
9075
    }
9076
  }
9077
9078
  return this;
9079
};
9080
9081
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
9082
9083
EventEmitter.prototype.once = function(type, listener) {
9084
  if (!isFunction(listener))
9085
    throw TypeError('listener must be a function');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9086
9087
  var fired = false;
9088
9089
  function g() {
9090
    this.removeListener(type, g);
9091
9092
    if (!fired) {
9093
      fired = true;
9094
      listener.apply(this, arguments);
9095
    }
9096
  }
9097
9098
  g.listener = listener;
9099
  this.on(type, g);
9100
9101
  return this;
9102
};
9103
9104
// emits a 'removeListener' event iff the listener was removed
9105
EventEmitter.prototype.removeListener = function(type, listener) {
9106
  var list, position, length, i;
9107
9108
  if (!isFunction(listener))
9109
    throw TypeError('listener must be a function');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9110
9111
  if (!this._events || !this._events[type])
9112
    return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9113
9114
  list = this._events[type];
9115
  length = list.length;
9116
  position = -1;
9117
9118
  if (list === listener ||
9119
      (isFunction(list.listener) && list.listener === listener)) {
9120
    delete this._events[type];
9121
    if (this._events.removeListener)
9122
      this.emit('removeListener', type, listener);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9123
9124
  } else if (isObject(list)) {
9125
    for (i = length; i-- > 0;) {
9126
      if (list[i] === listener ||
9127
          (list[i].listener && list[i].listener === listener)) {
9128
        position = i;
9129
        break;
9130
      }
9131
    }
9132
9133
    if (position < 0)
9134
      return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9135
9136
    if (list.length === 1) {
9137
      list.length = 0;
9138
      delete this._events[type];
9139
    } else {
9140
      list.splice(position, 1);
9141
    }
9142
9143
    if (this._events.removeListener)
9144
      this.emit('removeListener', type, listener);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9145
  }
9146
9147
  return this;
9148
};
9149
9150
EventEmitter.prototype.removeAllListeners = function(type) {
9151
  var key, listeners;
9152
9153
  if (!this._events)
9154
    return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9155
9156
  // not listening for removeListener, no need to emit
9157
  if (!this._events.removeListener) {
9158
    if (arguments.length === 0)
9159
      this._events = {};
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9160
    else if (this._events[type])
9161
      delete this._events[type];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9162
    return this;
9163
  }
9164
9165
  // emit removeListener for all listeners on all events
9166
  if (arguments.length === 0) {
9167
    for (key in this._events) {
9168
      if (key === 'removeListener') continue;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9169
      this.removeAllListeners(key);
9170
    }
9171
    this.removeAllListeners('removeListener');
9172
    this._events = {};
9173
    return this;
9174
  }
9175
9176
  listeners = this._events[type];
9177
9178
  if (isFunction(listeners)) {
9179
    this.removeListener(type, listeners);
9180
  } else if (listeners) {
9181
    // LIFO order
9182
    while (listeners.length)
9183
      this.removeListener(type, listeners[listeners.length - 1]);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9184
  }
9185
  delete this._events[type];
9186
9187
  return this;
9188
};
9189
9190
EventEmitter.prototype.listeners = function(type) {
9191
  var ret;
9192
  if (!this._events || !this._events[type])
9193
    ret = [];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9194
  else if (isFunction(this._events[type]))
9195
    ret = [this._events[type]];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9196
  else
9197
    ret = this._events[type].slice();
9198
  return ret;
9199
};
9200
9201
EventEmitter.prototype.listenerCount = function(type) {
9202
  if (this._events) {
9203
    var evlistener = this._events[type];
9204
9205
    if (isFunction(evlistener))
9206
      return 1;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9207
    else if (evlistener)
9208
      return evlistener.length;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9209
  }
9210
  return 0;
9211
};
9212
9213
EventEmitter.listenerCount = function(emitter, type) {
9214
  return emitter.listenerCount(type);
9215
};
9216
9217
function isFunction(arg) {
9218
  return typeof arg === 'function';
9219
}
9220
9221
function isNumber(arg) {
9222
  return typeof arg === 'number';
9223
}
9224
9225
function isObject(arg) {
9226
  return typeof arg === 'object' && arg !== null;
9227
}
9228
9229
function isUndefined(arg) {
9230
  return arg === void 0;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
9231
}
9232
9233 View Code Duplication
},{}],47:[function(require,module,exports){
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9234
(function (global){
9235
/*! https://mths.be/he v1.1.1 by @mathias | MIT license */
9236
;(function(root) {
9237
9238
	// Detect free variables `exports`.
9239
	var freeExports = typeof exports == 'object' && exports;
9240
9241
	// Detect free variable `module`.
9242
	var freeModule = typeof module == 'object' && module &&
9243
		module.exports == freeExports && module;
9244
9245
	// Detect free variable `global`, from Node.js or Browserified code,
9246
	// and use it as `root`.
9247
	var freeGlobal = typeof global == 'object' && global;
9248
	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
9249
		root = freeGlobal;
9250
	}
9251
9252
	/*--------------------------------------------------------------------------*/
9253
9254
	// All astral symbols.
9255
	var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
9256
	// All ASCII symbols (not just printable ASCII) except those listed in the
9257
	// first column of the overrides table.
9258
	// https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides
9259
	var regexAsciiWhitelist = /[\x01-\x7F]/g;
9260
	// All BMP symbols that are not ASCII newlines, printable ASCII symbols, or
9261
	// code points listed in the first column of the overrides table on
9262
	// https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides.
9263
	var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g;
9264
9265
	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;
9266
	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'};
9267
9268
	var regexEscape = /["&'<>`]/g;
9269
	var escapeMap = {
9270
		'"': '&quot;',
9271
		'&': '&amp;',
9272
		'\'': '&#x27;',
9273
		'<': '&lt;',
9274
		// See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the
9275
		// following is not strictly necessary unless it’s part of a tag or an
9276
		// unquoted attribute value. We’re only escaping it to support those
9277
		// situations, and for XML support.
9278
		'>': '&gt;',
9279
		// In Internet Explorer ≤ 8, the backtick character can be used
9280
		// to break out of (un)quoted attribute values or HTML comments.
9281
		// See http://html5sec.org/#102, http://html5sec.org/#108, and
9282
		// http://html5sec.org/#133.
9283
		'`': '&#x60;'
9284
	};
9285
9286
	var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/;
9287
	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]/;
9288
	var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(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])?/g;
9289
	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'};
9290
	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'};
9291
	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'};
9292
	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];
9293
9294
	/*--------------------------------------------------------------------------*/
9295
9296
	var stringFromCharCode = String.fromCharCode;
9297
9298
	var object = {};
9299
	var hasOwnProperty = object.hasOwnProperty;
9300
	var has = function(object, propertyName) {
9301
		return hasOwnProperty.call(object, propertyName);
9302
	};
9303
9304
	var contains = function(array, value) {
9305
		var index = -1;
9306
		var length = array.length;
9307
		while (++index < length) {
9308
			if (array[index] == value) {
9309
				return true;
9310
			}
9311
		}
9312
		return false;
9313
	};
9314
9315
	var merge = function(options, defaults) {
9316
		if (!options) {
9317
			return defaults;
9318
		}
9319
		var result = {};
9320
		var key;
9321
		for (key in defaults) {
9322
			// A `hasOwnProperty` check is not needed here, since only recognized
9323
			// option names are used anyway. Any others are ignored.
9324
			result[key] = has(options, key) ? options[key] : defaults[key];
9325
		}
9326
		return result;
9327
	};
9328
9329
	// Modified version of `ucs2encode`; see https://mths.be/punycode.
9330
	var codePointToSymbol = function(codePoint, strict) {
9331
		var output = '';
9332
		if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) {
9333
			// See issue #4:
9334
			// “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is
9335
			// greater than 0x10FFFF, then this is a parse error. Return a U+FFFD
9336
			// REPLACEMENT CHARACTER.”
9337
			if (strict) {
9338
				parseError('character reference outside the permissible Unicode range');
9339
			}
9340
			return '\uFFFD';
9341
		}
9342
		if (has(decodeMapNumeric, codePoint)) {
9343
			if (strict) {
9344
				parseError('disallowed character reference');
9345
			}
9346
			return decodeMapNumeric[codePoint];
9347
		}
9348
		if (strict && contains(invalidReferenceCodePoints, codePoint)) {
9349
			parseError('disallowed character reference');
9350
		}
9351
		if (codePoint > 0xFFFF) {
9352
			codePoint -= 0x10000;
9353
			output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800);
9354
			codePoint = 0xDC00 | codePoint & 0x3FF;
9355
		}
9356
		output += stringFromCharCode(codePoint);
9357
		return output;
9358
	};
9359
9360
	var hexEscape = function(codePoint) {
9361
		return '&#x' + codePoint.toString(16).toUpperCase() + ';';
9362
	};
9363
9364
	var decEscape = function(codePoint) {
9365
		return '&#' + codePoint + ';';
9366
	};
9367
9368
	var parseError = function(message) {
9369
		throw Error('Parse error: ' + message);
9370
	};
9371
9372
	/*--------------------------------------------------------------------------*/
9373
9374
	var encode = function(string, options) {
9375
		options = merge(options, encode.options);
9376
		var strict = options.strict;
9377
		if (strict && regexInvalidRawCodePoint.test(string)) {
9378
			parseError('forbidden code point');
9379
		}
9380
		var encodeEverything = options.encodeEverything;
9381
		var useNamedReferences = options.useNamedReferences;
9382
		var allowUnsafeSymbols = options.allowUnsafeSymbols;
9383
		var escapeCodePoint = options.decimal ? decEscape : hexEscape;
9384
9385
		var escapeBmpSymbol = function(symbol) {
9386
			return escapeCodePoint(symbol.charCodeAt(0));
9387
		};
9388
9389
		if (encodeEverything) {
9390
			// Encode ASCII symbols.
9391
			string = string.replace(regexAsciiWhitelist, function(symbol) {
9392
				// Use named references if requested & possible.
9393
				if (useNamedReferences && has(encodeMap, symbol)) {
9394
					return '&' + encodeMap[symbol] + ';';
9395
				}
9396
				return escapeBmpSymbol(symbol);
9397
			});
9398
			// Shorten a few escapes that represent two symbols, of which at least one
9399
			// is within the ASCII range.
9400
			if (useNamedReferences) {
9401
				string = string
9402
					.replace(/&gt;\u20D2/g, '&nvgt;')
9403
					.replace(/&lt;\u20D2/g, '&nvlt;')
9404
					.replace(/&#x66;&#x6A;/g, '&fjlig;');
9405
			}
9406
			// Encode non-ASCII symbols.
9407
			if (useNamedReferences) {
9408
				// Encode non-ASCII symbols that can be replaced with a named reference.
9409
				string = string.replace(regexEncodeNonAscii, function(string) {
9410
					// Note: there is no need to check `has(encodeMap, string)` here.
9411
					return '&' + encodeMap[string] + ';';
9412
				});
9413
			}
9414
			// Note: any remaining non-ASCII symbols are handled outside of the `if`.
9415
		} else if (useNamedReferences) {
9416
			// Apply named character references.
9417
			// Encode `<>"'&` using named character references.
9418
			if (!allowUnsafeSymbols) {
9419
				string = string.replace(regexEscape, function(string) {
9420
					return '&' + encodeMap[string] + ';'; // no need to check `has()` here
9421
				});
9422
			}
9423
			// Shorten escapes that represent two symbols, of which at least one is
9424
			// `<>"'&`.
9425
			string = string
9426
				.replace(/&gt;\u20D2/g, '&nvgt;')
9427
				.replace(/&lt;\u20D2/g, '&nvlt;');
9428
			// Encode non-ASCII symbols that can be replaced with a named reference.
9429
			string = string.replace(regexEncodeNonAscii, function(string) {
9430
				// Note: there is no need to check `has(encodeMap, string)` here.
9431
				return '&' + encodeMap[string] + ';';
9432
			});
9433
		} else if (!allowUnsafeSymbols) {
9434
			// Encode `<>"'&` using hexadecimal escapes, now that they’re not handled
9435
			// using named character references.
9436
			string = string.replace(regexEscape, escapeBmpSymbol);
9437
		}
9438
		return string
9439
			// Encode astral symbols.
9440
			.replace(regexAstralSymbols, function($0) {
9441
				// https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
9442
				var high = $0.charCodeAt(0);
9443
				var low = $0.charCodeAt(1);
9444
				var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000;
9445
				return escapeCodePoint(codePoint);
9446
			})
9447
			// Encode any remaining BMP symbols that are not printable ASCII symbols
9448
			// using a hexadecimal escape.
9449
			.replace(regexBmpWhitelist, escapeBmpSymbol);
9450
	};
9451
	// Expose default options (so they can be overridden globally).
9452
	encode.options = {
9453
		'allowUnsafeSymbols': false,
9454
		'encodeEverything': false,
9455
		'strict': false,
9456
		'useNamedReferences': false,
9457
		'decimal' : false
9458
	};
9459
9460
	var decode = function(html, options) {
9461
		options = merge(options, decode.options);
9462
		var strict = options.strict;
9463
		if (strict && regexInvalidEntity.test(html)) {
9464
			parseError('malformed character reference');
9465
		}
9466
		return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) {
9467
			var codePoint;
9468
			var semicolon;
9469
			var decDigits;
9470
			var hexDigits;
9471
			var reference;
9472
			var next;
9473
			if ($1) {
9474
				// Decode decimal escapes, e.g. `&#119558;`.
9475
				decDigits = $1;
9476
				semicolon = $2;
9477
				if (strict && !semicolon) {
9478
					parseError('character reference was not terminated by a semicolon');
9479
				}
9480
				codePoint = parseInt(decDigits, 10);
9481
				return codePointToSymbol(codePoint, strict);
9482
			}
9483
			if ($3) {
9484
				// Decode hexadecimal escapes, e.g. `&#x1D306;`.
9485
				hexDigits = $3;
9486
				semicolon = $4;
9487
				if (strict && !semicolon) {
9488
					parseError('character reference was not terminated by a semicolon');
9489
				}
9490
				codePoint = parseInt(hexDigits, 16);
9491
				return codePointToSymbol(codePoint, strict);
9492
			}
9493
			if ($5) {
9494
				// Decode named character references with trailing `;`, e.g. `&copy;`.
9495
				reference = $5;
9496
				if (has(decodeMap, reference)) {
9497
					return decodeMap[reference];
9498
				} else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
9499
					// Ambiguous ampersand. https://mths.be/notes/ambiguous-ampersands
9500
					if (strict) {
9501
						parseError(
9502
							'named character reference was not terminated by a semicolon'
9503
						);
9504
					}
9505
					return $0;
9506
				}
9507
			}
9508
			// If we’re still here, it’s a legacy reference for sure. No need for an
9509
			// extra `if` check.
9510
			// Decode named character references without trailing `;`, e.g. `&amp`
9511
			// This is only a parse error if it gets converted to `&`, or if it is
9512
			// followed by `=` in an attribute context.
9513
			reference = $6;
9514
			next = $7;
9515
			if (next && options.isAttributeValue) {
9516
				if (strict && next == '=') {
9517
					parseError('`&` did not start a character reference');
9518
				}
9519
				return $0;
9520
			} else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
9521
				if (strict) {
9522
					parseError(
9523
						'named character reference was not terminated by a semicolon'
9524
					);
9525
				}
9526
				// Note: there is no need to check `has(decodeMapLegacy, reference)`.
9527
				return decodeMapLegacy[reference] + (next || '');
9528
			}
9529
		});
9530
	};
9531
	// Expose default options (so they can be overridden globally).
9532
	decode.options = {
9533
		'isAttributeValue': false,
9534
		'strict': false
9535
	};
9536
9537
	var escape = function(string) {
9538
		return string.replace(regexEscape, function($0) {
9539
			// Note: there is no need to check `has(escapeMap, $0)` here.
9540
			return escapeMap[$0];
9541
		});
9542
	};
9543
9544
	/*--------------------------------------------------------------------------*/
9545
9546
	var he = {
9547
		'version': '1.1.1',
9548
		'encode': encode,
9549
		'decode': decode,
9550
		'escape': escape,
9551
		'unescape': decode
9552
	};
9553
9554
	// Some AMD build optimizers, like r.js, check for specific condition patterns
9555
	// like the following:
9556
	if (
9557
		false
9558
	) {
9559
		define(function() {
9560
			return he;
9561
		});
9562
	}	else if (freeExports && !freeExports.nodeType) {
9563
		if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+
9564
			freeModule.exports = he;
9565
		} else { // in Narwhal or RingoJS v0.7.0-
9566
			for (var key in he) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
9567
				has(he, key) && (freeExports[key] = he[key]);
9568
			}
9569
		}
9570
	} else { // in Rhino or a web browser
9571
		root.he = he;
9572
	}
9573
9574
}(this));
9575
9576
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
9577
},{}],48:[function(require,module,exports){
9578
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
9579
  var e, m
9580
  var eLen = nBytes * 8 - mLen - 1
9581
  var eMax = (1 << eLen) - 1
9582
  var eBias = eMax >> 1
9583
  var nBits = -7
9584
  var i = isLE ? (nBytes - 1) : 0
9585
  var d = isLE ? -1 : 1
9586
  var s = buffer[offset + i]
9587
9588
  i += d
9589
9590
  e = s & ((1 << (-nBits)) - 1)
9591
  s >>= (-nBits)
9592
  nBits += eLen
9593
  for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
9594
9595
  m = e & ((1 << (-nBits)) - 1)
9596
  e >>= (-nBits)
9597
  nBits += mLen
9598
  for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
9599
9600
  if (e === 0) {
9601
    e = 1 - eBias
9602
  } else if (e === eMax) {
9603
    return m ? NaN : ((s ? -1 : 1) * Infinity)
9604
  } else {
9605
    m = m + Math.pow(2, mLen)
9606
    e = e - eBias
9607
  }
9608
  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
9609
}
9610
9611
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
9612
  var e, m, c
9613
  var eLen = nBytes * 8 - mLen - 1
9614
  var eMax = (1 << eLen) - 1
9615
  var eBias = eMax >> 1
9616
  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
9617
  var i = isLE ? 0 : (nBytes - 1)
9618
  var d = isLE ? 1 : -1
9619
  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
9620
9621
  value = Math.abs(value)
9622
9623
  if (isNaN(value) || value === Infinity) {
9624
    m = isNaN(value) ? 1 : 0
9625
    e = eMax
9626
  } else {
9627
    e = Math.floor(Math.log(value) / Math.LN2)
9628
    if (value * (c = Math.pow(2, -e)) < 1) {
9629
      e--
9630
      c *= 2
9631
    }
9632
    if (e + eBias >= 1) {
9633
      value += rt / c
9634
    } else {
9635
      value += rt * Math.pow(2, 1 - eBias)
9636
    }
9637
    if (value * c >= 2) {
9638
      e++
9639
      c /= 2
9640
    }
9641
9642
    if (e + eBias >= eMax) {
9643
      m = 0
9644
      e = eMax
9645
    } else if (e + eBias >= 1) {
9646
      m = (value * c - 1) * Math.pow(2, mLen)
9647
      e = e + eBias
9648
    } else {
9649
      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
9650
      e = 0
9651
    }
9652
  }
9653
9654
  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
9655
9656
  e = (e << mLen) | m
9657
  eLen += mLen
9658
  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
9659
9660
  buffer[offset + i - d] |= s * 128
9661
}
9662
9663
},{}],49:[function(require,module,exports){
9664 View Code Duplication
if (typeof Object.create === 'function') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9665
  // implementation from standard node.js 'util' module
9666
  module.exports = function inherits(ctor, superCtor) {
9667
    ctor.super_ = superCtor
9668
    ctor.prototype = Object.create(superCtor.prototype, {
9669
      constructor: {
9670
        value: ctor,
9671
        enumerable: false,
9672
        writable: true,
9673
        configurable: true
9674
      }
9675
    });
9676
  };
9677
} else {
9678
  // old school shim for old browsers
9679
  module.exports = function inherits(ctor, superCtor) {
9680
    ctor.super_ = superCtor
9681
    var TempCtor = function () {}
9682
    TempCtor.prototype = superCtor.prototype
9683
    ctor.prototype = new TempCtor()
9684
    ctor.prototype.constructor = ctor
9685
  }
9686
}
9687
9688
},{}],50:[function(require,module,exports){
9689
/*!
9690
 * Determine if an object is a Buffer
9691
 *
9692
 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
9693
 * @license  MIT
9694
 */
9695
9696
// The _isBuffer check is for Safari 5-7 support, because it's missing
9697
// Object.prototype.constructor. Remove this eventually
9698
module.exports = function (obj) {
9699
  return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
0 ignored issues
show
Best Practice introduced by
Comparing obj to null using the != operator is not safe. Consider using !== instead.
Loading history...
9700
}
9701
9702
function isBuffer (obj) {
9703
  return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
9704
}
9705
9706
// For Node v0.10 support. Remove this eventually.
9707
function isSlowBuffer (obj) {
9708
  return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
9709
}
9710
9711
},{}],51:[function(require,module,exports){
9712
var toString = {}.toString;
9713
9714
module.exports = Array.isArray || function (arr) {
9715
  return toString.call(arr) == '[object Array]';
9716
};
9717
9718
},{}],52:[function(require,module,exports){
9719
(function (process){
9720
var path = require('path');
9721
var fs = require('fs');
9722
var _0777 = parseInt('0777', 8);
9723
9724
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
9725
9726 View Code Duplication
function mkdirP (p, opts, f, made) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9727
    if (typeof opts === 'function') {
9728
        f = opts;
9729
        opts = {};
9730
    }
9731
    else if (!opts || typeof opts !== 'object') {
9732
        opts = { mode: opts };
9733
    }
9734
    
9735
    var mode = opts.mode;
9736
    var xfs = opts.fs || fs;
9737
    
9738
    if (mode === undefined) {
9739
        mode = _0777 & (~process.umask());
9740
    }
9741
    if (!made) made = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9742
    
9743
    var cb = f || function () {};
9744
    p = path.resolve(p);
9745
    
9746
    xfs.mkdir(p, mode, function (er) {
9747
        if (!er) {
9748
            made = made || p;
9749
            return cb(null, made);
9750
        }
9751
        switch (er.code) {
9752
            case 'ENOENT':
9753
                mkdirP(path.dirname(p), opts, function (er, made) {
9754
                    if (er) cb(er, made);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9755
                    else mkdirP(p, opts, cb, made);
9756
                });
9757
                break;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
9758
9759
            // In the case of any other error, just see if there's a dir
9760
            // there already.  If so, then hooray!  If not, then something
9761
            // is borked.
9762
            default:
9763
                xfs.stat(p, function (er2, stat) {
9764
                    // if the stat fails, then that's super weird.
9765
                    // let the original error be the failure reason.
9766
                    if (er2 || !stat.isDirectory()) cb(er, made)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9767
                    else cb(null, made);
9768
                });
9769
                break;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
9770
        }
9771
    });
9772
}
9773
9774 View Code Duplication
mkdirP.sync = function sync (p, opts, made) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9775
    if (!opts || typeof opts !== 'object') {
9776
        opts = { mode: opts };
9777
    }
9778
    
9779
    var mode = opts.mode;
9780
    var xfs = opts.fs || fs;
9781
    
9782
    if (mode === undefined) {
9783
        mode = _0777 & (~process.umask());
9784
    }
9785
    if (!made) made = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9786
9787
    p = path.resolve(p);
9788
9789
    try {
9790
        xfs.mkdirSync(p, mode);
9791
        made = made || p;
9792
    }
9793
    catch (err0) {
9794
        switch (err0.code) {
9795
            case 'ENOENT' :
9796
                made = sync(path.dirname(p), opts, made);
9797
                sync(p, opts, made);
9798
                break;
9799
9800
            // In the case of any other error, just see if there's a dir
9801
            // there already.  If so, then hooray!  If not, then something
9802
            // is borked.
9803
            default:
9804
                var stat;
9805
                try {
9806
                    stat = xfs.statSync(p);
9807
                }
9808
                catch (err1) {
9809
                    throw err0;
9810
                }
9811
                if (!stat.isDirectory()) throw err0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9812
                break;
9813
        }
9814
    }
9815
9816
    return made;
9817
};
9818
9819
}).call(this,require('_process'))
9820
},{"_process":55,"fs":40,"path":40}],53:[function(require,module,exports){
9821
/**
9822
 * Helpers.
9823
 */
9824
9825
var s = 1000;
9826
var m = s * 60;
9827
var h = m * 60;
9828
var d = h * 24;
9829
var y = d * 365.25;
9830
9831
/**
9832
 * Parse or format the given `val`.
9833
 *
9834
 * Options:
9835
 *
9836
 *  - `long` verbose formatting [false]
9837
 *
9838
 * @param {String|Number} val
9839
 * @param {Object} [options]
9840
 * @throws {Error} throw an error if val is not a non-empty string or a number
9841
 * @return {String|Number}
9842
 * @api public
9843
 */
9844
9845 View Code Duplication
module.exports = function(val, options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9846
  options = options || {};
9847
  var type = typeof val;
9848
  if (type === 'string' && val.length > 0) {
9849
    return parse(val);
9850
  } else if (type === 'number' && isNaN(val) === false) {
9851
    return options.long ? fmtLong(val) : fmtShort(val);
9852
  }
9853
  throw new Error(
9854
    'val is not a non-empty string or a valid number. val=' +
9855
      JSON.stringify(val)
9856
  );
9857
};
9858
9859
/**
9860
 * Parse the given `str` and return milliseconds.
9861
 *
9862
 * @param {String} str
9863
 * @return {Number}
9864
 * @api private
9865
 */
9866
9867 View Code Duplication
function parse(str) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9868
  str = String(str);
9869
  if (str.length > 100) {
9870
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
9871
  }
9872
  var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
9873
    str
9874
  );
9875
  if (!match) {
9876
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
9877
  }
9878
  var n = parseFloat(match[1]);
9879
  var type = (match[2] || 'ms').toLowerCase();
9880
  switch (type) {
9881
    case 'years':
9882
    case 'year':
9883
    case 'yrs':
9884
    case 'yr':
9885
    case 'y':
9886
      return n * y;
9887
    case 'days':
9888
    case 'day':
9889
    case 'd':
9890
      return n * d;
9891
    case 'hours':
9892
    case 'hour':
9893
    case 'hrs':
9894
    case 'hr':
9895
    case 'h':
9896
      return n * h;
9897
    case 'minutes':
9898
    case 'minute':
9899
    case 'mins':
9900
    case 'min':
9901
    case 'm':
9902
      return n * m;
9903
    case 'seconds':
9904
    case 'second':
9905
    case 'secs':
9906
    case 'sec':
9907
    case 's':
9908
      return n * s;
9909
    case 'milliseconds':
9910
    case 'millisecond':
9911
    case 'msecs':
9912
    case 'msec':
9913
    case 'ms':
9914
      return n;
9915
    default:
9916
      return undefined;
9917
  }
9918
}
9919
9920
/**
9921
 * Short format for `ms`.
9922
 *
9923
 * @param {Number} ms
9924
 * @return {String}
9925
 * @api private
9926
 */
9927
9928 View Code Duplication
function fmtShort(ms) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9929
  if (ms >= d) {
9930
    return Math.round(ms / d) + 'd';
9931
  }
9932
  if (ms >= h) {
9933
    return Math.round(ms / h) + 'h';
9934
  }
9935
  if (ms >= m) {
9936
    return Math.round(ms / m) + 'm';
9937
  }
9938
  if (ms >= s) {
9939
    return Math.round(ms / s) + 's';
9940
  }
9941
  return ms + 'ms';
9942
}
9943
9944
/**
9945
 * Long format for `ms`.
9946
 *
9947
 * @param {Number} ms
9948
 * @return {String}
9949
 * @api private
9950
 */
9951
9952
function fmtLong(ms) {
9953
  return plural(ms, d, 'day') ||
9954
    plural(ms, h, 'hour') ||
9955
    plural(ms, m, 'minute') ||
9956
    plural(ms, s, 'second') ||
9957
    ms + ' ms';
9958
}
9959
9960
/**
9961
 * Pluralization helper.
9962
 */
9963
9964 View Code Duplication
function plural(ms, n, name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9965
  if (ms < n) {
9966
    return;
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
9967
  }
9968
  if (ms < n * 1.5) {
9969
    return Math.floor(ms / n) + ' ' + name;
9970
  }
9971
  return Math.ceil(ms / n) + ' ' + name + 's';
9972
}
9973
9974
},{}],54:[function(require,module,exports){
9975
(function (process){
9976
'use strict';
9977
9978
if (!process.version ||
9979
    process.version.indexOf('v0.') === 0 ||
9980
    process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
9981
  module.exports = nextTick;
9982
} else {
9983
  module.exports = process.nextTick;
9984
}
9985
9986 View Code Duplication
function nextTick(fn, arg1, arg2, arg3) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
9987
  if (typeof fn !== 'function') {
9988
    throw new TypeError('"callback" argument must be a function');
9989
  }
9990
  var len = arguments.length;
9991
  var args, i;
9992
  switch (len) {
9993
  case 0:
9994
  case 1:
9995
    return process.nextTick(fn);
9996
  case 2:
9997
    return process.nextTick(function afterTickOne() {
9998
      fn.call(null, arg1);
9999
    });
10000
  case 3:
10001
    return process.nextTick(function afterTickTwo() {
10002
      fn.call(null, arg1, arg2);
10003
    });
10004
  case 4:
10005
    return process.nextTick(function afterTickThree() {
10006
      fn.call(null, arg1, arg2, arg3);
10007
    });
10008
  default:
10009
    args = new Array(len - 1);
10010
    i = 0;
10011
    while (i < args.length) {
10012
      args[i++] = arguments[i];
10013
    }
10014
    return process.nextTick(function afterTick() {
10015
      fn.apply(null, args);
10016
    });
10017
  }
10018
}
10019
10020
}).call(this,require('_process'))
10021
},{"_process":55}],55:[function(require,module,exports){
10022
// shim for using process in browser
10023
var process = module.exports = {};
10024
10025
// cached from whatever global is present so that test runners that stub it
10026
// don't break things.  But we need to wrap it in a try catch in case it is
10027
// wrapped in strict mode code which doesn't define any globals.  It's inside a
10028
// function because try/catches deoptimize in certain engines.
10029
10030
var cachedSetTimeout;
10031
var cachedClearTimeout;
10032
10033
function defaultSetTimout() {
10034
    throw new Error('setTimeout has not been defined');
10035
}
10036
function defaultClearTimeout () {
10037
    throw new Error('clearTimeout has not been defined');
10038
}
10039
(function () {
10040
    try {
10041
        if (typeof setTimeout === 'function') {
0 ignored issues
show
Bug introduced by
The variable setTimeout seems to be never declared. If this is a global, consider adding a /** global: setTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
10042
            cachedSetTimeout = setTimeout;
10043
        } else {
10044
            cachedSetTimeout = defaultSetTimout;
10045
        }
10046
    } catch (e) {
10047
        cachedSetTimeout = defaultSetTimout;
10048
    }
10049
    try {
10050
        if (typeof clearTimeout === 'function') {
0 ignored issues
show
Bug introduced by
The variable clearTimeout seems to be never declared. If this is a global, consider adding a /** global: clearTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
10051
            cachedClearTimeout = clearTimeout;
10052
        } else {
10053
            cachedClearTimeout = defaultClearTimeout;
10054
        }
10055
    } catch (e) {
10056
        cachedClearTimeout = defaultClearTimeout;
10057
    }
10058
} ())
10059
function runTimeout(fun) {
10060
    if (cachedSetTimeout === setTimeout) {
0 ignored issues
show
Bug introduced by
The variable setTimeout seems to be never declared. If this is a global, consider adding a /** global: setTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
10061
        //normal enviroments in sane situations
10062
        return setTimeout(fun, 0);
10063
    }
10064
    // if setTimeout wasn't available but was latter defined
10065
    if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable setTimeout is declared in the current environment, consider using typeof setTimeout === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
10066
        cachedSetTimeout = setTimeout;
10067
        return setTimeout(fun, 0);
10068
    }
10069
    try {
10070
        // when when somebody has screwed with setTimeout but no I.E. maddness
10071
        return cachedSetTimeout(fun, 0);
10072
    } catch(e){
10073
        try {
10074
            // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
10075
            return cachedSetTimeout.call(null, fun, 0);
0 ignored issues
show
Bug introduced by
The variable cachedSetTimeout does not seem to be initialized in case cachedSetTimeout === def...etTimeout && setTimeout on line 10065 is false. Are you sure this can never be the case?
Loading history...
10076
        } catch(e){
10077
            // 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
10078
            return cachedSetTimeout.call(this, fun, 0);
10079
        }
10080
    }
10081
10082
10083
}
10084
function runClearTimeout(marker) {
10085
    if (cachedClearTimeout === clearTimeout) {
0 ignored issues
show
Bug introduced by
The variable clearTimeout seems to be never declared. If this is a global, consider adding a /** global: clearTimeout */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
10086
        //normal enviroments in sane situations
10087
        return clearTimeout(marker);
10088
    }
10089
    // if clearTimeout wasn't available but was latter defined
10090
    if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable clearTimeout is declared in the current environment, consider using typeof clearTimeout === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
10091
        cachedClearTimeout = clearTimeout;
10092
        return clearTimeout(marker);
10093
    }
10094
    try {
10095
        // when when somebody has screwed with setTimeout but no I.E. maddness
10096
        return cachedClearTimeout(marker);
10097
    } catch (e){
10098
        try {
10099
            // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
10100
            return cachedClearTimeout.call(null, marker);
0 ignored issues
show
Bug introduced by
The variable cachedClearTimeout does not seem to be initialized in case cachedClearTimeout === d...Timeout && clearTimeout on line 10090 is false. Are you sure this can never be the case?
Loading history...
10101
        } catch (e){
10102
            // 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.
10103
            // Some versions of I.E. have different rules for clearTimeout vs setTimeout
10104
            return cachedClearTimeout.call(this, marker);
10105
        }
10106
    }
10107
10108
10109
10110
}
10111
var queue = [];
10112
var draining = false;
10113
var currentQueue;
10114
var queueIndex = -1;
10115
10116
function cleanUpNextTick() {
10117
    if (!draining || !currentQueue) {
10118
        return;
10119
    }
10120
    draining = false;
10121
    if (currentQueue.length) {
10122
        queue = currentQueue.concat(queue);
10123
    } else {
10124
        queueIndex = -1;
10125
    }
10126
    if (queue.length) {
10127
        drainQueue();
10128
    }
10129
}
10130
10131
function drainQueue() {
10132
    if (draining) {
10133
        return;
10134
    }
10135
    var timeout = runTimeout(cleanUpNextTick);
10136
    draining = true;
10137
10138
    var len = queue.length;
10139
    while(len) {
10140
        currentQueue = queue;
0 ignored issues
show
Bug introduced by
The variable queue is changed as part of the while loop for example by [] on line 10141. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
10141
        queue = [];
10142
        while (++queueIndex < len) {
0 ignored issues
show
Bug introduced by
The variable queueIndex is changed as part of the while loop for example by ++queueIndex on line 10142. Only the value of the last iteration will be visible in this function if it is called after the loop.
Loading history...
10143
            if (currentQueue) {
10144
                currentQueue[queueIndex].run();
10145
            }
10146
        }
10147
        queueIndex = -1;
10148
        len = queue.length;
10149
    }
10150
    currentQueue = null;
10151
    draining = false;
10152
    runClearTimeout(timeout);
10153
}
10154
10155
process.nextTick = function (fun) {
10156
    var args = new Array(arguments.length - 1);
10157
    if (arguments.length > 1) {
10158
        for (var i = 1; i < arguments.length; i++) {
10159
            args[i - 1] = arguments[i];
10160
        }
10161
    }
10162
    queue.push(new Item(fun, args));
10163
    if (queue.length === 1 && !draining) {
10164
        runTimeout(drainQueue);
10165
    }
10166
};
10167
10168
// v8 likes predictible objects
10169
function Item(fun, array) {
10170
    this.fun = fun;
10171
    this.array = array;
10172
}
10173
Item.prototype.run = function () {
10174
    this.fun.apply(null, this.array);
10175
};
10176
process.title = 'browser';
10177
process.browser = true;
10178
process.env = {};
10179
process.argv = [];
10180
process.version = ''; // empty string to avoid regexp issues
10181
process.versions = {};
10182
10183
function noop() {}
10184
10185
process.on = noop;
10186
process.addListener = noop;
10187
process.once = noop;
10188
process.off = noop;
10189
process.removeListener = noop;
10190
process.removeAllListeners = noop;
10191
process.emit = noop;
10192
process.prependListener = noop;
10193
process.prependOnceListener = noop;
10194
10195
process.listeners = function (name) { return [] }
0 ignored issues
show
Unused Code introduced by
The parameter name is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10196
10197
process.binding = function (name) {
0 ignored issues
show
Unused Code introduced by
The parameter name is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10198
    throw new Error('process.binding is not supported');
10199
};
10200
10201
process.cwd = function () { return '/' };
10202
process.chdir = function (dir) {
0 ignored issues
show
Unused Code introduced by
The parameter dir is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10203
    throw new Error('process.chdir is not supported');
10204
};
10205
process.umask = function() { return 0; };
10206
10207
},{}],56:[function(require,module,exports){
10208
module.exports = require('./lib/_stream_duplex.js');
10209
10210
},{"./lib/_stream_duplex.js":57}],57:[function(require,module,exports){
10211
// Copyright Joyent, Inc. and other Node contributors.
10212
//
10213
// Permission is hereby granted, free of charge, to any person obtaining a
10214
// copy of this software and associated documentation files (the
10215
// "Software"), to deal in the Software without restriction, including
10216
// without limitation the rights to use, copy, modify, merge, publish,
10217
// distribute, sublicense, and/or sell copies of the Software, and to permit
10218
// persons to whom the Software is furnished to do so, subject to the
10219
// following conditions:
10220
//
10221
// The above copyright notice and this permission notice shall be included
10222
// in all copies or substantial portions of the Software.
10223
//
10224
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10225
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10226
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10227
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10228
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10229
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10230
// USE OR OTHER DEALINGS IN THE SOFTWARE.
10231
10232
// a duplex stream is just a stream that is both readable and writable.
10233
// Since JS doesn't have multiple prototypal inheritance, this class
10234
// prototypally inherits from Readable, and then parasitically from
10235
// Writable.
10236
10237
'use strict';
10238
10239
/*<replacement>*/
10240
10241
var processNextTick = require('process-nextick-args');
10242
/*</replacement>*/
10243
10244
/*<replacement>*/
10245
var objectKeys = Object.keys || function (obj) {
10246
  var keys = [];
10247
  for (var key in obj) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
10248
    keys.push(key);
10249
  }return keys;
10250
};
10251
/*</replacement>*/
10252
10253
module.exports = Duplex;
10254
10255
/*<replacement>*/
10256
var util = require('core-util-is');
10257
util.inherits = require('inherits');
10258
/*</replacement>*/
10259
10260
var Readable = require('./_stream_readable');
10261
var Writable = require('./_stream_writable');
10262
10263
util.inherits(Duplex, Readable);
10264
10265
var keys = objectKeys(Writable.prototype);
10266
for (var v = 0; v < keys.length; v++) {
10267
  var method = keys[v];
10268
  if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10269
}
10270
10271 View Code Duplication
function Duplex(options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10272
  if (!(this instanceof Duplex)) return new Duplex(options);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10273
10274
  Readable.call(this, options);
10275
  Writable.call(this, options);
10276
10277
  if (options && options.readable === false) this.readable = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10278
10279
  if (options && options.writable === false) this.writable = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10280
10281
  this.allowHalfOpen = true;
10282
  if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10283
10284
  this.once('end', onend);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
10285
}
10286
10287
// the no-half-open enforcer
10288
function onend() {
10289
  // if we allow half-open state, or if the writable side ended,
10290
  // then we're ok.
10291
  if (this.allowHalfOpen || this._writableState.ended) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10292
10293
  // no more data can be written.
10294
  // But allow more writes to happen in this tick.
10295
  processNextTick(onEndNT, this);
10296
}
10297
10298
function onEndNT(self) {
10299
  self.end();
10300
}
10301
10302
Object.defineProperty(Duplex.prototype, 'destroyed', {
10303
  get: function () {
10304
    if (this._readableState === undefined || this._writableState === undefined) {
10305
      return false;
10306
    }
10307
    return this._readableState.destroyed && this._writableState.destroyed;
10308
  },
10309
  set: function (value) {
10310
    // we ignore the value if the stream
10311
    // has not been initialized yet
10312
    if (this._readableState === undefined || this._writableState === undefined) {
10313
      return;
10314
    }
10315
10316
    // backward compatibility, the user is explicitly
10317
    // managing destroyed
10318
    this._readableState.destroyed = value;
10319
    this._writableState.destroyed = value;
10320
  }
10321
});
10322
10323
Duplex.prototype._destroy = function (err, cb) {
10324
  this.push(null);
10325
  this.end();
10326
10327
  processNextTick(cb, err);
10328
};
10329
10330
function forEach(xs, f) {
0 ignored issues
show
introduced by
The function forEach does not seem to be used and can be removed.
Loading history...
10331
  for (var i = 0, l = xs.length; i < l; i++) {
10332
    f(xs[i], i);
10333
  }
10334
}
10335
},{"./_stream_readable":59,"./_stream_writable":61,"core-util-is":41,"inherits":49,"process-nextick-args":54}],58:[function(require,module,exports){
10336
// Copyright Joyent, Inc. and other Node contributors.
10337
//
10338
// Permission is hereby granted, free of charge, to any person obtaining a
10339
// copy of this software and associated documentation files (the
10340
// "Software"), to deal in the Software without restriction, including
10341
// without limitation the rights to use, copy, modify, merge, publish,
10342
// distribute, sublicense, and/or sell copies of the Software, and to permit
10343
// persons to whom the Software is furnished to do so, subject to the
10344
// following conditions:
10345
//
10346
// The above copyright notice and this permission notice shall be included
10347
// in all copies or substantial portions of the Software.
10348
//
10349
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10350
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10351
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10352
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10353
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10354
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10355
// USE OR OTHER DEALINGS IN THE SOFTWARE.
10356
10357
// a passthrough stream.
10358
// basically just the most minimal sort of Transform stream.
10359
// Every written chunk gets output as-is.
10360
10361
'use strict';
10362
10363
module.exports = PassThrough;
10364
10365
var Transform = require('./_stream_transform');
10366
10367
/*<replacement>*/
10368
var util = require('core-util-is');
10369
util.inherits = require('inherits');
10370
/*</replacement>*/
10371
10372
util.inherits(PassThrough, Transform);
10373
10374
function PassThrough(options) {
10375
  if (!(this instanceof PassThrough)) return new PassThrough(options);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10376
10377
  Transform.call(this, options);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
10378
}
10379
10380
PassThrough.prototype._transform = function (chunk, encoding, cb) {
10381
  cb(null, chunk);
10382
};
10383
},{"./_stream_transform":60,"core-util-is":41,"inherits":49}],59:[function(require,module,exports){
10384
(function (process,global){
10385
// Copyright Joyent, Inc. and other Node contributors.
10386
//
10387
// Permission is hereby granted, free of charge, to any person obtaining a
10388
// copy of this software and associated documentation files (the
10389
// "Software"), to deal in the Software without restriction, including
10390
// without limitation the rights to use, copy, modify, merge, publish,
10391
// distribute, sublicense, and/or sell copies of the Software, and to permit
10392
// persons to whom the Software is furnished to do so, subject to the
10393
// following conditions:
10394
//
10395
// The above copyright notice and this permission notice shall be included
10396
// in all copies or substantial portions of the Software.
10397
//
10398
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10399
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10400
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10401
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10402
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10403
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10404
// USE OR OTHER DEALINGS IN THE SOFTWARE.
10405
10406
'use strict';
10407
10408
/*<replacement>*/
10409
10410
var processNextTick = require('process-nextick-args');
10411
/*</replacement>*/
10412
10413
module.exports = Readable;
10414
10415
/*<replacement>*/
10416
var isArray = require('isarray');
10417
/*</replacement>*/
10418
10419
/*<replacement>*/
10420
var Duplex;
10421
/*</replacement>*/
10422
10423
Readable.ReadableState = ReadableState;
10424
10425
/*<replacement>*/
10426
var EE = require('events').EventEmitter;
0 ignored issues
show
Unused Code introduced by
The variable EE seems to be never used. Consider removing it.
Loading history...
10427
10428
var EElistenerCount = function (emitter, type) {
10429
  return emitter.listeners(type).length;
10430
};
10431
/*</replacement>*/
10432
10433
/*<replacement>*/
10434
var Stream = require('./internal/streams/stream');
10435
/*</replacement>*/
10436
10437
// TODO(bmeurer): Change this back to const once hole checks are
10438
// properly optimized away early in Ignition+TurboFan.
10439
/*<replacement>*/
10440
var Buffer = require('safe-buffer').Buffer;
10441
var OurUint8Array = global.Uint8Array || function () {};
10442
function _uint8ArrayToBuffer(chunk) {
10443
  return Buffer.from(chunk);
10444
}
10445
function _isUint8Array(obj) {
10446
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
10447
}
10448
/*</replacement>*/
10449
10450
/*<replacement>*/
10451
var util = require('core-util-is');
10452
util.inherits = require('inherits');
10453
/*</replacement>*/
10454
10455
/*<replacement>*/
10456
var debugUtil = require('util');
10457
var debug = void 0;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
10458
if (debugUtil && debugUtil.debuglog) {
10459
  debug = debugUtil.debuglog('stream');
10460
} else {
10461
  debug = function () {};
10462
}
10463
/*</replacement>*/
10464
10465
var BufferList = require('./internal/streams/BufferList');
10466
var destroyImpl = require('./internal/streams/destroy');
10467
var StringDecoder;
10468
10469
util.inherits(Readable, Stream);
10470
10471
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
10472
10473
function prependListener(emitter, event, fn) {
10474
  // Sadly this is not cacheable as some libraries bundle their own
10475
  // event emitter implementation with them.
10476
  if (typeof emitter.prependListener === 'function') {
10477
    return emitter.prependListener(event, fn);
10478
  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
10479
    // This is a hack to make sure that our error handler is attached before any
10480
    // userland ones.  NEVER DO THIS. This is here only because this code needs
10481
    // to continue to work with older versions of Node.js that do not include
10482
    // the prependListener() method. The goal is to eventually remove this hack.
10483
    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]];
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10484
  }
10485
}
10486
10487 View Code Duplication
function ReadableState(options, stream) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10488
  Duplex = Duplex || require('./_stream_duplex');
10489
10490
  options = options || {};
10491
10492
  // object stream flag. Used to make read(n) ignore n and to
10493
  // make all the buffer merging and length checks go away
10494
  this.objectMode = !!options.objectMode;
10495
10496
  if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10497
10498
  // the point at which it stops calling _read() to fill the buffer
10499
  // Note: 0 is a valid value, means "don't call _read preemptively ever"
10500
  var hwm = options.highWaterMark;
10501
  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
10502
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
10503
10504
  // cast to ints.
10505
  this.highWaterMark = Math.floor(this.highWaterMark);
10506
10507
  // A linked list is used to store data chunks instead of an array because the
10508
  // linked list can remove elements from the beginning faster than
10509
  // array.shift()
10510
  this.buffer = new BufferList();
10511
  this.length = 0;
10512
  this.pipes = null;
10513
  this.pipesCount = 0;
10514
  this.flowing = null;
10515
  this.ended = false;
10516
  this.endEmitted = false;
10517
  this.reading = false;
10518
10519
  // a flag to be able to tell if the event 'readable'/'data' is emitted
10520
  // immediately, or on a later tick.  We set this to true at first, because
10521
  // any actions that shouldn't happen until "later" should generally also
10522
  // not happen before the first read call.
10523
  this.sync = true;
10524
10525
  // whenever we return null, then we set a flag to say
10526
  // that we're awaiting a 'readable' event emission.
10527
  this.needReadable = false;
10528
  this.emittedReadable = false;
10529
  this.readableListening = false;
10530
  this.resumeScheduled = false;
10531
10532
  // has it been destroyed
10533
  this.destroyed = false;
10534
10535
  // Crypto is kind of old and crusty.  Historically, its default string
10536
  // encoding is 'binary' so we have to make this configurable.
10537
  // Everything else in the universe uses 'utf8', though.
10538
  this.defaultEncoding = options.defaultEncoding || 'utf8';
10539
10540
  // the number of writers that are awaiting a drain event in .pipe()s
10541
  this.awaitDrain = 0;
10542
10543
  // if true, a maybeReadMore has been scheduled
10544
  this.readingMore = false;
10545
10546
  this.decoder = null;
10547
  this.encoding = null;
10548
  if (options.encoding) {
10549
    if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10550
    this.decoder = new StringDecoder(options.encoding);
10551
    this.encoding = options.encoding;
10552
  }
10553
}
10554
10555 View Code Duplication
function Readable(options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10556
  Duplex = Duplex || require('./_stream_duplex');
10557
10558
  if (!(this instanceof Readable)) return new Readable(options);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10559
10560
  this._readableState = new ReadableState(options, this);
10561
10562
  // legacy
10563
  this.readable = true;
10564
10565
  if (options) {
10566
    if (typeof options.read === 'function') this._read = options.read;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10567
10568
    if (typeof options.destroy === 'function') this._destroy = options.destroy;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10569
  }
10570
10571
  Stream.call(this);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
10572
}
10573
10574
Object.defineProperty(Readable.prototype, 'destroyed', {
10575
  get: function () {
10576
    if (this._readableState === undefined) {
10577
      return false;
10578
    }
10579
    return this._readableState.destroyed;
10580
  },
10581
  set: function (value) {
10582
    // we ignore the value if the stream
10583
    // has not been initialized yet
10584
    if (!this._readableState) {
10585
      return;
10586
    }
10587
10588
    // backward compatibility, the user is explicitly
10589
    // managing destroyed
10590
    this._readableState.destroyed = value;
10591
  }
10592
});
10593
10594
Readable.prototype.destroy = destroyImpl.destroy;
10595
Readable.prototype._undestroy = destroyImpl.undestroy;
10596
Readable.prototype._destroy = function (err, cb) {
10597
  this.push(null);
10598
  cb(err);
10599
};
10600
10601
// Manually shove something into the read() buffer.
10602
// This returns true if the highWaterMark has not been hit yet,
10603
// similar to how Writable.write() returns true if you should
10604
// write() some more.
10605 View Code Duplication
Readable.prototype.push = function (chunk, encoding) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10606
  var state = this._readableState;
10607
  var skipChunkCheck;
10608
10609
  if (!state.objectMode) {
10610
    if (typeof chunk === 'string') {
10611
      encoding = encoding || state.defaultEncoding;
10612
      if (encoding !== state.encoding) {
10613
        chunk = Buffer.from(chunk, encoding);
10614
        encoding = '';
10615
      }
10616
      skipChunkCheck = true;
10617
    }
10618
  } else {
10619
    skipChunkCheck = true;
10620
  }
10621
10622
  return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
0 ignored issues
show
Bug introduced by
The variable skipChunkCheck does not seem to be initialized in case typeof chunk === "string" on line 10610 is false. Are you sure the function readableAddChunk handles undefined variables?
Loading history...
10623
};
10624
10625
// Unshift should *always* be something directly out of read()
10626
Readable.prototype.unshift = function (chunk) {
10627
  return readableAddChunk(this, chunk, null, true, false);
10628
};
10629
10630 View Code Duplication
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10631
  var state = stream._readableState;
10632
  if (chunk === null) {
10633
    state.reading = false;
10634
    onEofChunk(stream, state);
10635
  } else {
10636
    var er;
10637
    if (!skipChunkCheck) er = chunkInvalid(state, chunk);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10638
    if (er) {
10639
      stream.emit('error', er);
10640
    } else if (state.objectMode || chunk && chunk.length > 0) {
10641
      if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
10642
        chunk = _uint8ArrayToBuffer(chunk);
10643
      }
10644
10645
      if (addToFront) {
10646
        if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10647
      } else if (state.ended) {
10648
        stream.emit('error', new Error('stream.push() after EOF'));
10649
      } else {
10650
        state.reading = false;
10651
        if (state.decoder && !encoding) {
10652
          chunk = state.decoder.write(chunk);
10653
          if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10654
        } else {
10655
          addChunk(stream, state, chunk, false);
10656
        }
10657
      }
10658
    } else if (!addToFront) {
10659
      state.reading = false;
10660
    }
10661
  }
10662
10663
  return needMoreData(state);
10664
}
10665
10666
function addChunk(stream, state, chunk, addToFront) {
10667
  if (state.flowing && state.length === 0 && !state.sync) {
10668
    stream.emit('data', chunk);
10669
    stream.read(0);
10670
  } else {
10671
    // update the buffer info.
10672
    state.length += state.objectMode ? 1 : chunk.length;
10673
    if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10674
10675
    if (state.needReadable) emitReadable(stream);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10676
  }
10677
  maybeReadMore(stream, state);
10678
}
10679
10680
function chunkInvalid(state, chunk) {
10681
  var er;
10682
  if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
10683
    er = new TypeError('Invalid non-string/buffer chunk');
10684
  }
10685
  return er;
0 ignored issues
show
Bug introduced by
The variable er does not seem to be initialized in case !_isUint8Array(chunk) &&...ed && !state.objectMode on line 10682 is false. Are you sure this can never be the case?
Loading history...
10686
}
10687
10688
// if it's past the high water mark, we can push in some more.
10689
// Also, if we have no data yet, we can stand some
10690
// more bytes.  This is to work around cases where hwm=0,
10691
// such as the repl.  Also, if the push() triggered a
10692
// readable event, and the user called read(largeNumber) such that
10693
// needReadable was set, then we ought to push more, so that another
10694
// 'readable' event will be triggered.
10695
function needMoreData(state) {
10696
  return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
10697
}
10698
10699
Readable.prototype.isPaused = function () {
10700
  return this._readableState.flowing === false;
10701
};
10702
10703
// backwards compatibility.
10704
Readable.prototype.setEncoding = function (enc) {
10705
  if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10706
  this._readableState.decoder = new StringDecoder(enc);
10707
  this._readableState.encoding = enc;
10708
  return this;
10709
};
10710
10711
// Don't raise the hwm > 8MB
10712
var MAX_HWM = 0x800000;
10713 View Code Duplication
function computeNewHighWaterMark(n) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10714
  if (n >= MAX_HWM) {
10715
    n = MAX_HWM;
10716
  } else {
10717
    // Get the next highest power of 2 to prevent increasing hwm excessively in
10718
    // tiny amounts
10719
    n--;
10720
    n |= n >>> 1;
10721
    n |= n >>> 2;
10722
    n |= n >>> 4;
10723
    n |= n >>> 8;
10724
    n |= n >>> 16;
10725
    n++;
10726
  }
10727
  return n;
10728
}
10729
10730
// This function is designed to be inlinable, so please take care when making
10731
// changes to the function body.
10732 View Code Duplication
function howMuchToRead(n, state) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10733
  if (n <= 0 || state.length === 0 && state.ended) return 0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10734
  if (state.objectMode) return 1;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10735
  if (n !== n) {
10736
    // Only flow one buffer at a time
10737
    if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
10738
  }
10739
  // If we're asking for more than the current hwm, then raise the hwm.
10740
  if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10741
  if (n <= state.length) return n;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10742
  // Don't have enough
10743
  if (!state.ended) {
10744
    state.needReadable = true;
10745
    return 0;
10746
  }
10747
  return state.length;
10748
}
10749
10750
// you can override either this method, or the async _read(n) below.
10751 View Code Duplication
Readable.prototype.read = function (n) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10752
  debug('read', n);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "read".
Loading history...
10753
  n = parseInt(n, 10);
10754
  var state = this._readableState;
10755
  var nOrig = n;
10756
10757
  if (n !== 0) state.emittedReadable = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10758
10759
  // if we're doing read(0) to trigger a readable event, but we
10760
  // already have a bunch of data in the buffer, then just trigger
10761
  // the 'readable' event and move on.
10762
  if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
10763
    debug('read: emitReadable', state.length, state.ended);
10764
    if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10765
    return null;
10766
  }
10767
10768
  n = howMuchToRead(n, state);
10769
10770
  // if we've ended, and we're now clear, then finish it up.
10771
  if (n === 0 && state.ended) {
10772
    if (state.length === 0) endReadable(this);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10773
    return null;
10774
  }
10775
10776
  // All the actual chunk generation logic needs to be
10777
  // *below* the call to _read.  The reason is that in certain
10778
  // synthetic stream cases, such as passthrough streams, _read
10779
  // may be a completely synchronous operation which may change
10780
  // the state of the read buffer, providing enough data when
10781
  // before there was *not* enough.
10782
  //
10783
  // So, the steps are:
10784
  // 1. Figure out what the state of things will be after we do
10785
  // a read from the buffer.
10786
  //
10787
  // 2. If that resulting state will trigger a _read, then call _read.
10788
  // Note that this may be asynchronous, or synchronous.  Yes, it is
10789
  // deeply ugly to write APIs this way, but that still doesn't mean
10790
  // that the Readable class should behave improperly, as streams are
10791
  // designed to be sync/async agnostic.
10792
  // Take note if the _read call is sync or async (ie, if the read call
10793
  // has returned yet), so that we know whether or not it's safe to emit
10794
  // 'readable' etc.
10795
  //
10796
  // 3. Actually pull the requested chunks out of the buffer and return.
10797
10798
  // if we need a readable event, then we need to do some reading.
10799
  var doRead = state.needReadable;
10800
  debug('need readable', doRead);
10801
10802
  // if we currently have less than the highWaterMark, then also read some
10803
  if (state.length === 0 || state.length - n < state.highWaterMark) {
10804
    doRead = true;
10805
    debug('length less than watermark', doRead);
10806
  }
10807
10808
  // however, if we've ended, then there's no point, and if we're already
10809
  // reading, then it's unnecessary.
10810
  if (state.ended || state.reading) {
10811
    doRead = false;
10812
    debug('reading or ended', doRead);
10813
  } else if (doRead) {
10814
    debug('do read');
10815
    state.reading = true;
10816
    state.sync = true;
10817
    // if the length is currently zero, then we *need* a readable event.
10818
    if (state.length === 0) state.needReadable = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10819
    // call internal read method
10820
    this._read(state.highWaterMark);
10821
    state.sync = false;
10822
    // If _read pushed data synchronously, then `reading` will be false,
10823
    // and we need to re-evaluate how much data we can return to the user.
10824
    if (!state.reading) n = howMuchToRead(nOrig, state);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10825
  }
10826
10827
  var ret;
10828
  if (n > 0) ret = fromList(n, state);else ret = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10829
10830
  if (ret === null) {
10831
    state.needReadable = true;
10832
    n = 0;
10833
  } else {
10834
    state.length -= n;
10835
  }
10836
10837
  if (state.length === 0) {
10838
    // If we have nothing in the buffer, then we want to know
10839
    // as soon as we *do* get something into the buffer.
10840
    if (!state.ended) state.needReadable = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10841
10842
    // If we tried to read() past the EOF, then emit end on the next tick.
10843
    if (nOrig !== n && state.ended) endReadable(this);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10844
  }
10845
10846
  if (ret !== null) this.emit('data', ret);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10847
10848
  return ret;
10849
};
10850
10851
function onEofChunk(stream, state) {
10852
  if (state.ended) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10853
  if (state.decoder) {
10854
    var chunk = state.decoder.end();
10855
    if (chunk && chunk.length) {
10856
      state.buffer.push(chunk);
10857
      state.length += state.objectMode ? 1 : chunk.length;
10858
    }
10859
  }
10860
  state.ended = true;
10861
10862
  // emit 'readable' now to make sure it gets picked up.
10863
  emitReadable(stream);
10864
}
10865
10866
// Don't emit readable right away in sync mode, because this can trigger
10867
// another read() call => stack overflow.  This way, it might trigger
10868
// a nextTick recursion warning, but that's not so bad.
10869
function emitReadable(stream) {
10870
  var state = stream._readableState;
10871
  state.needReadable = false;
10872
  if (!state.emittedReadable) {
10873
    debug('emitReadable', state.flowing);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "emitReadable".
Loading history...
10874
    state.emittedReadable = true;
10875
    if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10876
  }
10877
}
10878
10879
function emitReadable_(stream) {
10880
  debug('emit readable');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "emit readable".
Loading history...
10881
  stream.emit('readable');
10882
  flow(stream);
10883
}
10884
10885
// at this point, the user has presumably seen the 'readable' event,
10886
// and called read() to consume some data.  that may have triggered
10887
// in turn another _read(n) call, in which case reading = true if
10888
// it's in progress.
10889
// However, if we're not ended, or reading, and the length < hwm,
10890
// then go ahead and try to read some more preemptively.
10891
function maybeReadMore(stream, state) {
10892
  if (!state.readingMore) {
10893
    state.readingMore = true;
10894
    processNextTick(maybeReadMore_, stream, state);
10895
  }
10896
}
10897
10898
function maybeReadMore_(stream, state) {
10899
  var len = state.length;
10900
  while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
10901
    debug('maybeReadMore read 0');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "maybeReadMore read 0".
Loading history...
10902
    stream.read(0);
10903
    if (len === state.length)
10904
      // didn't get any data, stop spinning.
10905
      break;else len = state.length;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10906
  }
10907
  state.readingMore = false;
10908
}
10909
10910
// abstract method.  to be overridden in specific implementation classes.
10911
// call cb(er, data) where data is <= n in length.
10912
// for virtual (non-string, non-buffer) streams, "length" is somewhat
10913
// arbitrary, and perhaps not very meaningful.
10914
Readable.prototype._read = function (n) {
0 ignored issues
show
Unused Code introduced by
The parameter n is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
10915
  this.emit('error', new Error('_read() is not implemented'));
10916
};
10917
10918 View Code Duplication
Readable.prototype.pipe = function (dest, pipeOpts) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
10919
  var src = this;
10920
  var state = this._readableState;
10921
10922
  switch (state.pipesCount) {
10923
    case 0:
10924
      state.pipes = dest;
10925
      break;
10926
    case 1:
10927
      state.pipes = [state.pipes, dest];
10928
      break;
10929
    default:
10930
      state.pipes.push(dest);
10931
      break;
10932
  }
10933
  state.pipesCount += 1;
10934
  debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "pipe count=%d opts=%j".
Loading history...
10935
10936
  var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
10937
10938
  var endFn = doEnd ? onend : unpipe;
10939
  if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10940
10941
  dest.on('unpipe', onunpipe);
10942
  function onunpipe(readable, unpipeInfo) {
10943
    debug('onunpipe');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "onunpipe".
Loading history...
10944
    if (readable === src) {
10945
      if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
10946
        unpipeInfo.hasUnpiped = true;
10947
        cleanup();
10948
      }
10949
    }
10950
  }
10951
10952
  function onend() {
10953
    debug('onend');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "onend".
Loading history...
10954
    dest.end();
10955
  }
10956
10957
  // when the dest drains, it reduces the awaitDrain counter
10958
  // on the source.  This would be more elegant with a .once()
10959
  // handler in flow(), but adding and removing repeatedly is
10960
  // too slow.
10961
  var ondrain = pipeOnDrain(src);
10962
  dest.on('drain', ondrain);
10963
10964
  var cleanedUp = false;
10965
  function cleanup() {
10966
    debug('cleanup');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "cleanup".
Loading history...
10967
    // cleanup event handlers once the pipe is broken
10968
    dest.removeListener('close', onclose);
10969
    dest.removeListener('finish', onfinish);
10970
    dest.removeListener('drain', ondrain);
10971
    dest.removeListener('error', onerror);
10972
    dest.removeListener('unpipe', onunpipe);
10973
    src.removeListener('end', onend);
10974
    src.removeListener('end', unpipe);
10975
    src.removeListener('data', ondata);
10976
10977
    cleanedUp = true;
10978
10979
    // if the reader is waiting for a drain event from this
10980
    // specific writer, then it would cause it to never start
10981
    // flowing again.
10982
    // So, if this is awaiting a drain, then we just call it now.
10983
    // If we don't know, then assume that we are waiting for one.
10984
    if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
10985
  }
10986
10987
  // If the user pushes more data while we're writing to dest then we'll end up
10988
  // in ondata again. However, we only want to increase awaitDrain once because
10989
  // dest will only emit one 'drain' event for the multiple writes.
10990
  // => Introduce a guard on increasing awaitDrain.
10991
  var increasedAwaitDrain = false;
10992
  src.on('data', ondata);
10993
  function ondata(chunk) {
10994
    debug('ondata');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "ondata".
Loading history...
10995
    increasedAwaitDrain = false;
10996
    var ret = dest.write(chunk);
10997
    if (false === ret && !increasedAwaitDrain) {
10998
      // If the user unpiped during `dest.write()`, it is possible
10999
      // to get stuck in a permanently paused state if that write
11000
      // also returned false.
11001
      // => Check whether `dest` is still a piping destination.
11002
      if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
11003
        debug('false write response, pause', src._readableState.awaitDrain);
11004
        src._readableState.awaitDrain++;
11005
        increasedAwaitDrain = true;
11006
      }
11007
      src.pause();
11008
    }
11009
  }
11010
11011
  // if the dest has an error, then stop piping into it.
11012
  // however, don't suppress the throwing behavior for this.
11013
  function onerror(er) {
11014
    debug('onerror', er);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "onerror".
Loading history...
11015
    unpipe();
11016
    dest.removeListener('error', onerror);
11017
    if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11018
  }
11019
11020
  // Make sure our error handler is attached before userland ones.
11021
  prependListener(dest, 'error', onerror);
11022
11023
  // Both close and finish should trigger unpipe, but only once.
11024
  function onclose() {
11025
    dest.removeListener('finish', onfinish);
11026
    unpipe();
11027
  }
11028
  dest.once('close', onclose);
11029
  function onfinish() {
11030
    debug('onfinish');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "onfinish".
Loading history...
11031
    dest.removeListener('close', onclose);
11032
    unpipe();
11033
  }
11034
  dest.once('finish', onfinish);
11035
11036
  function unpipe() {
11037
    debug('unpipe');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "unpipe".
Loading history...
11038
    src.unpipe(dest);
11039
  }
11040
11041
  // tell the dest that it's being piped to
11042
  dest.emit('pipe', src);
11043
11044
  // start the flow if it hasn't been started already.
11045
  if (!state.flowing) {
11046
    debug('pipe resume');
11047
    src.resume();
11048
  }
11049
11050
  return dest;
11051
};
11052
11053
function pipeOnDrain(src) {
11054
  return function () {
11055
    var state = src._readableState;
11056
    debug('pipeOnDrain', state.awaitDrain);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "pipeOnDrain".
Loading history...
11057
    if (state.awaitDrain) state.awaitDrain--;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11058
    if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
11059
      state.flowing = true;
11060
      flow(src);
11061
    }
11062
  };
11063
}
11064
11065 View Code Duplication
Readable.prototype.unpipe = function (dest) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11066
  var state = this._readableState;
11067
  var unpipeInfo = { hasUnpiped: false };
11068
11069
  // if we're not piping anywhere, then do nothing.
11070
  if (state.pipesCount === 0) return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11071
11072
  // just one destination.  most common case.
11073
  if (state.pipesCount === 1) {
11074
    // passed in one, but it's not the right one.
11075
    if (dest && dest !== state.pipes) return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11076
11077
    if (!dest) dest = state.pipes;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11078
11079
    // got a match.
11080
    state.pipes = null;
11081
    state.pipesCount = 0;
11082
    state.flowing = false;
11083
    if (dest) dest.emit('unpipe', this, unpipeInfo);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11084
    return this;
11085
  }
11086
11087
  // slow case. multiple pipe destinations.
11088
11089
  if (!dest) {
11090
    // remove all.
11091
    var dests = state.pipes;
11092
    var len = state.pipesCount;
11093
    state.pipes = null;
11094
    state.pipesCount = 0;
11095
    state.flowing = false;
11096
11097
    for (var i = 0; i < len; i++) {
11098
      dests[i].emit('unpipe', this, unpipeInfo);
11099
    }return this;
11100
  }
11101
11102
  // try to find the right one.
11103
  var index = indexOf(state.pipes, dest);
11104
  if (index === -1) return this;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11105
11106
  state.pipes.splice(index, 1);
11107
  state.pipesCount -= 1;
11108
  if (state.pipesCount === 1) state.pipes = state.pipes[0];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11109
11110
  dest.emit('unpipe', this, unpipeInfo);
11111
11112
  return this;
11113
};
11114
11115
// set up data events if they are asked for
11116
// Ensure readable listeners eventually get something
11117
Readable.prototype.on = function (ev, fn) {
11118
  var res = Stream.prototype.on.call(this, ev, fn);
11119
11120
  if (ev === 'data') {
11121
    // Start flowing on next tick if stream isn't explicitly paused
11122
    if (this._readableState.flowing !== false) this.resume();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11123
  } else if (ev === 'readable') {
11124
    var state = this._readableState;
11125
    if (!state.endEmitted && !state.readableListening) {
11126
      state.readableListening = state.needReadable = true;
11127
      state.emittedReadable = false;
11128
      if (!state.reading) {
11129
        processNextTick(nReadingNextTick, this);
11130
      } else if (state.length) {
11131
        emitReadable(this);
11132
      }
11133
    }
11134
  }
11135
11136
  return res;
11137
};
11138
Readable.prototype.addListener = Readable.prototype.on;
11139
11140
function nReadingNextTick(self) {
11141
  debug('readable nexttick read 0');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "readable nexttick read 0".
Loading history...
11142
  self.read(0);
11143
}
11144
11145
// pause() and resume() are remnants of the legacy readable stream API
11146
// If the user uses them, then switch into old mode.
11147
Readable.prototype.resume = function () {
11148
  var state = this._readableState;
11149
  if (!state.flowing) {
11150
    debug('resume');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "resume".
Loading history...
11151
    state.flowing = true;
11152
    resume(this, state);
11153
  }
11154
  return this;
11155
};
11156
11157
function resume(stream, state) {
11158
  if (!state.resumeScheduled) {
11159
    state.resumeScheduled = true;
11160
    processNextTick(resume_, stream, state);
11161
  }
11162
}
11163
11164
function resume_(stream, state) {
11165
  if (!state.reading) {
11166
    debug('resume read 0');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "resume read 0".
Loading history...
11167
    stream.read(0);
11168
  }
11169
11170
  state.resumeScheduled = false;
11171
  state.awaitDrain = 0;
11172
  stream.emit('resume');
11173
  flow(stream);
11174
  if (state.flowing && !state.reading) stream.read(0);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11175
}
11176
11177
Readable.prototype.pause = function () {
11178
  debug('call pause flowing=%j', this._readableState.flowing);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "call pause flowing=%j".
Loading history...
11179
  if (false !== this._readableState.flowing) {
11180
    debug('pause');
11181
    this._readableState.flowing = false;
11182
    this.emit('pause');
11183
  }
11184
  return this;
11185
};
11186
11187
function flow(stream) {
11188
  var state = stream._readableState;
11189
  debug('flow', state.flowing);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "flow".
Loading history...
11190
  while (state.flowing && stream.read() !== null) {}
0 ignored issues
show
Comprehensibility Documentation Best Practice introduced by
This code block is empty. Consider removing it or adding a comment to explain.
Loading history...
11191
}
11192
11193
// wrap an old-style stream as the async data source.
11194
// This is *not* part of the readable stream interface.
11195
// It is an ugly unfortunate mess of history.
11196 View Code Duplication
Readable.prototype.wrap = function (stream) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11197
  var state = this._readableState;
11198
  var paused = false;
11199
11200
  var self = this;
11201
  stream.on('end', function () {
11202
    debug('wrapped end');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "wrapped end".
Loading history...
11203
    if (state.decoder && !state.ended) {
11204
      var chunk = state.decoder.end();
11205
      if (chunk && chunk.length) self.push(chunk);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11206
    }
11207
11208
    self.push(null);
11209
  });
11210
11211
  stream.on('data', function (chunk) {
11212
    debug('wrapped data');
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "wrapped data".
Loading history...
11213
    if (state.decoder) chunk = state.decoder.write(chunk);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11214
11215
    // don't skip over falsy values in objectMode
11216
    if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11217
11218
    var ret = self.push(chunk);
11219
    if (!ret) {
11220
      paused = true;
11221
      stream.pause();
11222
    }
11223
  });
11224
11225
  // proxy all the other methods.
11226
  // important when wrapping filters and duplexes.
11227
  for (var i in stream) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
11228
    if (this[i] === undefined && typeof stream[i] === 'function') {
11229
      this[i] = function (method) {
11230
        return function () {
11231
          return stream[method].apply(stream, arguments);
11232
        };
11233
      }(i);
11234
    }
11235
  }
11236
11237
  // proxy certain important events.
11238
  for (var n = 0; n < kProxyEvents.length; n++) {
11239
    stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
11240
  }
11241
11242
  // when we try to consume some more bytes, simply unpause the
11243
  // underlying stream.
11244
  self._read = function (n) {
11245
    debug('wrapped _read', n);
0 ignored issues
show
Bug introduced by
The call to debug seems to have too many arguments starting with "wrapped _read".
Loading history...
11246
    if (paused) {
11247
      paused = false;
11248
      stream.resume();
11249
    }
11250
  };
11251
11252
  return self;
11253
};
11254
11255
// exposed for testing purposes only.
11256
Readable._fromList = fromList;
11257
11258
// Pluck off n bytes from an array of buffers.
11259
// Length is the combined lengths of all the buffers in the list.
11260
// This function is designed to be inlinable, so please take care when making
11261
// changes to the function body.
11262 View Code Duplication
function fromList(n, state) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11263
  // nothing buffered
11264
  if (state.length === 0) return null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11265
11266
  var ret;
11267
  if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11268
    // read it all, truncate the list
11269
    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);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11270
    state.buffer.clear();
11271
  } else {
11272
    // read part of list
11273
    ret = fromListPartial(n, state.buffer, state.decoder);
11274
  }
11275
11276
  return ret;
11277
}
11278
11279
// Extracts only enough buffered data to satisfy the amount requested.
11280
// This function is designed to be inlinable, so please take care when making
11281
// changes to the function body.
11282
function fromListPartial(n, list, hasStrings) {
11283
  var ret;
11284
  if (n < list.head.data.length) {
11285
    // slice is the same for buffers and strings
11286
    ret = list.head.data.slice(0, n);
11287
    list.head.data = list.head.data.slice(n);
11288
  } else if (n === list.head.data.length) {
11289
    // first chunk is a perfect match
11290
    ret = list.shift();
11291
  } else {
11292
    // result spans more than one buffer
11293
    ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
11294
  }
11295
  return ret;
11296
}
11297
11298
// Copies a specified amount of characters from the list of buffered data
11299
// chunks.
11300
// This function is designed to be inlinable, so please take care when making
11301
// changes to the function body.
11302 View Code Duplication
function copyFromBufferString(n, list) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11303
  var p = list.head;
11304
  var c = 1;
11305
  var ret = p.data;
11306
  n -= ret.length;
11307
  while (p = p.next) {
11308
    var str = p.data;
11309
    var nb = n > str.length ? str.length : n;
11310
    if (nb === str.length) ret += str;else ret += str.slice(0, n);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11311
    n -= nb;
11312
    if (n === 0) {
11313
      if (nb === str.length) {
11314
        ++c;
11315
        if (p.next) list.head = p.next;else list.head = list.tail = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11316
      } else {
11317
        list.head = p;
11318
        p.data = str.slice(nb);
11319
      }
11320
      break;
11321
    }
11322
    ++c;
11323
  }
11324
  list.length -= c;
11325
  return ret;
11326
}
11327
11328
// Copies a specified amount of bytes from the list of buffered data chunks.
11329
// This function is designed to be inlinable, so please take care when making
11330
// changes to the function body.
11331 View Code Duplication
function copyFromBuffer(n, list) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11332
  var ret = Buffer.allocUnsafe(n);
11333
  var p = list.head;
11334
  var c = 1;
11335
  p.data.copy(ret);
11336
  n -= p.data.length;
11337
  while (p = p.next) {
11338
    var buf = p.data;
11339
    var nb = n > buf.length ? buf.length : n;
11340
    buf.copy(ret, ret.length - n, 0, nb);
11341
    n -= nb;
11342
    if (n === 0) {
11343
      if (nb === buf.length) {
11344
        ++c;
11345
        if (p.next) list.head = p.next;else list.head = list.tail = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11346
      } else {
11347
        list.head = p;
11348
        p.data = buf.slice(nb);
11349
      }
11350
      break;
11351
    }
11352
    ++c;
11353
  }
11354
  list.length -= c;
11355
  return ret;
11356
}
11357
11358
function endReadable(stream) {
11359
  var state = stream._readableState;
11360
11361
  // If we get here before consuming all the bytes, then that is a
11362
  // bug in node.  Should never happen.
11363
  if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11364
11365
  if (!state.endEmitted) {
11366
    state.ended = true;
11367
    processNextTick(endReadableNT, state, stream);
11368
  }
11369
}
11370
11371
function endReadableNT(state, stream) {
11372
  // Check that we didn't get one last unshift.
11373
  if (!state.endEmitted && state.length === 0) {
11374
    state.endEmitted = true;
11375
    stream.readable = false;
11376
    stream.emit('end');
11377
  }
11378
}
11379
11380
function forEach(xs, f) {
0 ignored issues
show
introduced by
The function forEach does not seem to be used and can be removed.
Loading history...
11381
  for (var i = 0, l = xs.length; i < l; i++) {
11382
    f(xs[i], i);
11383
  }
11384
}
11385
11386
function indexOf(xs, x) {
11387
  for (var i = 0, l = xs.length; i < l; i++) {
11388
    if (xs[i] === x) return i;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11389
  }
11390
  return -1;
11391
}
11392
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
11393
},{"./_stream_duplex":57,"./internal/streams/BufferList":62,"./internal/streams/destroy":63,"./internal/streams/stream":64,"_process":55,"core-util-is":41,"events":46,"inherits":49,"isarray":51,"process-nextick-args":54,"safe-buffer":69,"string_decoder/":71,"util":38}],60:[function(require,module,exports){
11394
// Copyright Joyent, Inc. and other Node contributors.
11395
//
11396
// Permission is hereby granted, free of charge, to any person obtaining a
11397
// copy of this software and associated documentation files (the
11398
// "Software"), to deal in the Software without restriction, including
11399
// without limitation the rights to use, copy, modify, merge, publish,
11400
// distribute, sublicense, and/or sell copies of the Software, and to permit
11401
// persons to whom the Software is furnished to do so, subject to the
11402
// following conditions:
11403
//
11404
// The above copyright notice and this permission notice shall be included
11405
// in all copies or substantial portions of the Software.
11406
//
11407
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11408
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11409
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11410
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11411
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11412
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11413
// USE OR OTHER DEALINGS IN THE SOFTWARE.
11414
11415
// a transform stream is a readable/writable stream where you do
11416
// something with the data.  Sometimes it's called a "filter",
11417
// but that's not a great name for it, since that implies a thing where
11418
// some bits pass through, and others are simply ignored.  (That would
11419
// be a valid example of a transform, of course.)
11420
//
11421
// While the output is causally related to the input, it's not a
11422
// necessarily symmetric or synchronous transformation.  For example,
11423
// a zlib stream might take multiple plain-text writes(), and then
11424
// emit a single compressed chunk some time in the future.
11425
//
11426
// Here's how this works:
11427
//
11428
// The Transform stream has all the aspects of the readable and writable
11429
// stream classes.  When you write(chunk), that calls _write(chunk,cb)
11430
// internally, and returns false if there's a lot of pending writes
11431
// buffered up.  When you call read(), that calls _read(n) until
11432
// there's enough pending readable data buffered up.
11433
//
11434
// In a transform stream, the written data is placed in a buffer.  When
11435
// _read(n) is called, it transforms the queued up data, calling the
11436
// buffered _write cb's as it consumes chunks.  If consuming a single
11437
// written chunk would result in multiple output chunks, then the first
11438
// outputted bit calls the readcb, and subsequent chunks just go into
11439
// the read buffer, and will cause it to emit 'readable' if necessary.
11440
//
11441
// This way, back-pressure is actually determined by the reading side,
11442
// since _read has to be called to start processing a new chunk.  However,
11443
// a pathological inflate type of transform can cause excessive buffering
11444
// here.  For example, imagine a stream where every byte of input is
11445
// interpreted as an integer from 0-255, and then results in that many
11446
// bytes of output.  Writing the 4 bytes {ff,ff,ff,ff} would result in
11447
// 1kb of data being output.  In this case, you could write a very small
11448
// amount of input, and end up with a very large amount of output.  In
11449
// such a pathological inflating mechanism, there'd be no way to tell
11450
// the system to stop doing the transform.  A single 4MB write could
11451
// cause the system to run out of memory.
11452
//
11453
// However, even in such a pathological case, only a single written chunk
11454
// would be consumed, and then the rest would wait (un-transformed) until
11455
// the results of the previous transformed chunk were consumed.
11456
11457
'use strict';
11458
11459
module.exports = Transform;
11460
11461
var Duplex = require('./_stream_duplex');
11462
11463
/*<replacement>*/
11464
var util = require('core-util-is');
11465
util.inherits = require('inherits');
11466
/*</replacement>*/
11467
11468
util.inherits(Transform, Duplex);
11469
11470
function TransformState(stream) {
11471
  this.afterTransform = function (er, data) {
11472
    return afterTransform(stream, er, data);
11473
  };
11474
11475
  this.needTransform = false;
11476
  this.transforming = false;
11477
  this.writecb = null;
11478
  this.writechunk = null;
11479
  this.writeencoding = null;
11480
}
11481
11482 View Code Duplication
function afterTransform(stream, er, data) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11483
  var ts = stream._transformState;
11484
  ts.transforming = false;
11485
11486
  var cb = ts.writecb;
11487
11488
  if (!cb) {
11489
    return stream.emit('error', new Error('write callback called multiple times'));
11490
  }
11491
11492
  ts.writechunk = null;
11493
  ts.writecb = null;
11494
11495
  if (data !== null && data !== undefined) stream.push(data);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11496
11497
  cb(er);
11498
11499
  var rs = stream._readableState;
11500
  rs.reading = false;
11501
  if (rs.needReadable || rs.length < rs.highWaterMark) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if rs.needReadable || rs.length < rs.highWaterMark is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
11502
    stream._read(rs.highWaterMark);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
11503
  }
11504
}
11505
11506
function Transform(options) {
11507
  if (!(this instanceof Transform)) return new Transform(options);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11508
11509
  Duplex.call(this, options);
11510
11511
  this._transformState = new TransformState(this);
11512
11513
  var stream = this;
11514
11515
  // start out asking for a readable event once data is transformed.
11516
  this._readableState.needReadable = true;
11517
11518
  // we have implemented the _read method, and done the other things
11519
  // that Readable wants before the first _read call, so unset the
11520
  // sync guard flag.
11521
  this._readableState.sync = false;
11522
11523
  if (options) {
11524
    if (typeof options.transform === 'function') this._transform = options.transform;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11525
11526
    if (typeof options.flush === 'function') this._flush = options.flush;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11527
  }
11528
11529
  // When the writable side finishes, then flush out anything remaining.
11530
  this.once('prefinish', function () {
11531
    if (typeof this._flush === 'function') this._flush(function (er, data) {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11532
      done(stream, er, data);
11533
    });else done(stream);
11534
  });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
11535
}
11536
11537
Transform.prototype.push = function (chunk, encoding) {
11538
  this._transformState.needTransform = false;
11539
  return Duplex.prototype.push.call(this, chunk, encoding);
11540
};
11541
11542
// This is the part where you do stuff!
11543
// override this function in implementation classes.
11544
// 'chunk' is an input chunk.
11545
//
11546
// Call `push(newChunk)` to pass along transformed output
11547
// to the readable side.  You may call 'push' zero or more times.
11548
//
11549
// Call `cb(err)` when you are done with this chunk.  If you pass
11550
// an error, then that'll put the hurt on the whole operation.  If you
11551
// never call cb(), then you'll never get another chunk.
11552
Transform.prototype._transform = function (chunk, encoding, cb) {
0 ignored issues
show
Unused Code introduced by
The parameter cb is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter chunk is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter encoding is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
11553
  throw new Error('_transform() is not implemented');
11554
};
11555
11556
Transform.prototype._write = function (chunk, encoding, cb) {
11557
  var ts = this._transformState;
11558
  ts.writecb = cb;
11559
  ts.writechunk = chunk;
11560
  ts.writeencoding = encoding;
11561
  if (!ts.transforming) {
11562
    var rs = this._readableState;
11563
    if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11564
  }
11565
};
11566
11567
// Doesn't matter what the args are here.
11568
// _transform does all the work.
11569
// That we got here means that the readable side wants more data.
11570
Transform.prototype._read = function (n) {
0 ignored issues
show
Unused Code introduced by
The parameter n is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
11571
  var ts = this._transformState;
11572
11573
  if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
11574
    ts.transforming = true;
11575
    this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
11576
  } else {
11577
    // mark that we need a transform, so that any data that comes in
11578
    // will get processed, now that we've asked for it.
11579
    ts.needTransform = true;
11580
  }
11581
};
11582
11583
Transform.prototype._destroy = function (err, cb) {
11584
  var _this = this;
11585
11586
  Duplex.prototype._destroy.call(this, err, function (err2) {
11587
    cb(err2);
11588
    _this.emit('close');
11589
  });
11590
};
11591
11592
function done(stream, er, data) {
11593
  if (er) return stream.emit('error', er);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11594
11595
  if (data !== null && data !== undefined) stream.push(data);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11596
11597
  // if there's nothing in the write buffer, then that means
11598
  // that nothing more will ever be provided
11599
  var ws = stream._writableState;
11600
  var ts = stream._transformState;
11601
11602
  if (ws.length) throw new Error('Calling transform done when ws.length != 0');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11603
11604
  if (ts.transforming) throw new Error('Calling transform done when still transforming');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11605
11606
  return stream.push(null);
11607
}
11608
},{"./_stream_duplex":57,"core-util-is":41,"inherits":49}],61:[function(require,module,exports){
11609
(function (process,global){
11610
// Copyright Joyent, Inc. and other Node contributors.
11611
//
11612
// Permission is hereby granted, free of charge, to any person obtaining a
11613
// copy of this software and associated documentation files (the
11614
// "Software"), to deal in the Software without restriction, including
11615
// without limitation the rights to use, copy, modify, merge, publish,
11616
// distribute, sublicense, and/or sell copies of the Software, and to permit
11617
// persons to whom the Software is furnished to do so, subject to the
11618
// following conditions:
11619
//
11620
// The above copyright notice and this permission notice shall be included
11621
// in all copies or substantial portions of the Software.
11622
//
11623
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
11624
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11625
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
11626
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
11627
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
11628
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
11629
// USE OR OTHER DEALINGS IN THE SOFTWARE.
11630
11631
// A bit simpler than readable streams.
11632
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
11633
// the drain event emission and buffering.
11634
11635
'use strict';
11636
11637
/*<replacement>*/
11638
11639
var processNextTick = require('process-nextick-args');
11640
/*</replacement>*/
11641
11642
module.exports = Writable;
11643
11644
/* <replacement> */
11645
function WriteReq(chunk, encoding, cb) {
0 ignored issues
show
introduced by
The function WriteReq does not seem to be used and can be removed.
Loading history...
11646
  this.chunk = chunk;
11647
  this.encoding = encoding;
11648
  this.callback = cb;
11649
  this.next = null;
11650
}
11651
11652
// It seems a linked list but it is not
11653
// there will be only 2 of these for each stream
11654
function CorkedRequest(state) {
11655
  var _this = this;
11656
11657
  this.next = null;
11658
  this.entry = null;
11659
  this.finish = function () {
11660
    onCorkedFinish(_this, state);
11661
  };
11662
}
11663
/* </replacement> */
11664
11665
/*<replacement>*/
11666
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
0 ignored issues
show
Bug introduced by
The variable setImmediate seems to be never declared. If this is a global, consider adding a /** global: setImmediate */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
11667
/*</replacement>*/
11668
11669
/*<replacement>*/
11670
var Duplex;
11671
/*</replacement>*/
11672
11673
Writable.WritableState = WritableState;
11674
11675
/*<replacement>*/
11676
var util = require('core-util-is');
11677
util.inherits = require('inherits');
11678
/*</replacement>*/
11679
11680
/*<replacement>*/
11681
var internalUtil = {
11682
  deprecate: require('util-deprecate')
11683
};
11684
/*</replacement>*/
11685
11686
/*<replacement>*/
11687
var Stream = require('./internal/streams/stream');
11688
/*</replacement>*/
11689
11690
/*<replacement>*/
11691
var Buffer = require('safe-buffer').Buffer;
11692
var OurUint8Array = global.Uint8Array || function () {};
11693
function _uint8ArrayToBuffer(chunk) {
11694
  return Buffer.from(chunk);
11695
}
11696
function _isUint8Array(obj) {
11697
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
11698
}
11699
/*</replacement>*/
11700
11701
var destroyImpl = require('./internal/streams/destroy');
11702
11703
util.inherits(Writable, Stream);
11704
11705
function nop() {}
11706
11707 View Code Duplication
function WritableState(options, stream) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11708
  Duplex = Duplex || require('./_stream_duplex');
11709
11710
  options = options || {};
11711
11712
  // object stream flag to indicate whether or not this stream
11713
  // contains buffers or objects.
11714
  this.objectMode = !!options.objectMode;
11715
11716
  if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11717
11718
  // the point at which write() starts returning false
11719
  // Note: 0 is a valid value, means that we always return false if
11720
  // the entire buffer is not flushed immediately on write()
11721
  var hwm = options.highWaterMark;
11722
  var defaultHwm = this.objectMode ? 16 : 16 * 1024;
11723
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
11724
11725
  // cast to ints.
11726
  this.highWaterMark = Math.floor(this.highWaterMark);
11727
11728
  // if _final has been called
11729
  this.finalCalled = false;
11730
11731
  // drain event flag.
11732
  this.needDrain = false;
11733
  // at the start of calling end()
11734
  this.ending = false;
11735
  // when end() has been called, and returned
11736
  this.ended = false;
11737
  // when 'finish' is emitted
11738
  this.finished = false;
11739
11740
  // has it been destroyed
11741
  this.destroyed = false;
11742
11743
  // should we decode strings into buffers before passing to _write?
11744
  // this is here so that some node-core streams can optimize string
11745
  // handling at a lower level.
11746
  var noDecode = options.decodeStrings === false;
11747
  this.decodeStrings = !noDecode;
11748
11749
  // Crypto is kind of old and crusty.  Historically, its default string
11750
  // encoding is 'binary' so we have to make this configurable.
11751
  // Everything else in the universe uses 'utf8', though.
11752
  this.defaultEncoding = options.defaultEncoding || 'utf8';
11753
11754
  // not an actual buffer we keep track of, but a measurement
11755
  // of how much we're waiting to get pushed to some underlying
11756
  // socket or file.
11757
  this.length = 0;
11758
11759
  // a flag to see when we're in the middle of a write.
11760
  this.writing = false;
11761
11762
  // when true all writes will be buffered until .uncork() call
11763
  this.corked = 0;
11764
11765
  // a flag to be able to tell if the onwrite cb is called immediately,
11766
  // or on a later tick.  We set this to true at first, because any
11767
  // actions that shouldn't happen until "later" should generally also
11768
  // not happen before the first write call.
11769
  this.sync = true;
11770
11771
  // a flag to know if we're processing previously buffered items, which
11772
  // may call the _write() callback in the same tick, so that we don't
11773
  // end up in an overlapped onwrite situation.
11774
  this.bufferProcessing = false;
11775
11776
  // the callback that's passed to _write(chunk,cb)
11777
  this.onwrite = function (er) {
11778
    onwrite(stream, er);
11779
  };
11780
11781
  // the callback that the user supplies to write(chunk,encoding,cb)
11782
  this.writecb = null;
11783
11784
  // the amount that is being written when _write is called.
11785
  this.writelen = 0;
11786
11787
  this.bufferedRequest = null;
11788
  this.lastBufferedRequest = null;
11789
11790
  // number of pending user-supplied write callbacks
11791
  // this must be 0 before 'finish' can be emitted
11792
  this.pendingcb = 0;
11793
11794
  // emit prefinish if the only thing we're waiting for is _write cbs
11795
  // This is relevant for synchronous Transform streams
11796
  this.prefinished = false;
11797
11798
  // True if the error was already emitted and should not be thrown again
11799
  this.errorEmitted = false;
11800
11801
  // count buffered requests
11802
  this.bufferedRequestCount = 0;
11803
11804
  // allocate the first CorkedRequest, there is always
11805
  // one allocated and free to use, and we maintain at most two
11806
  this.corkedRequestsFree = new CorkedRequest(this);
11807
}
11808
11809
WritableState.prototype.getBuffer = function getBuffer() {
11810
  var current = this.bufferedRequest;
11811
  var out = [];
11812
  while (current) {
11813
    out.push(current);
11814
    current = current.next;
11815
  }
11816
  return out;
11817
};
11818
11819
(function () {
11820
  try {
11821
    Object.defineProperty(WritableState.prototype, 'buffer', {
11822
      get: internalUtil.deprecate(function () {
11823
        return this.getBuffer();
11824
      }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
11825
    });
11826
  } catch (_) {}
0 ignored issues
show
Coding Style Comprehensibility Best Practice introduced by
Empty catch clauses should be used with caution; consider adding a comment why this is needed.
Loading history...
11827
})();
11828
11829
// Test _writableState for inheritance to account for Duplex streams,
11830
// whose prototype chain only points to Readable.
11831
var realHasInstance;
11832 View Code Duplication
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11833
  realHasInstance = Function.prototype[Symbol.hasInstance];
11834
  Object.defineProperty(Writable, Symbol.hasInstance, {
11835
    value: function (object) {
11836
      if (realHasInstance.call(this, object)) return true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11837
11838
      return object && object._writableState instanceof WritableState;
11839
    }
11840
  });
11841
} else {
11842
  realHasInstance = function (object) {
11843
    return object instanceof this;
11844
  };
11845
}
11846
11847 View Code Duplication
function Writable(options) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11848
  Duplex = Duplex || require('./_stream_duplex');
11849
11850
  // Writable ctor is applied to Duplexes, too.
11851
  // `realHasInstance` is necessary because using plain `instanceof`
11852
  // would return false, as no `_writableState` property is attached.
11853
11854
  // Trying to use the custom `instanceof` for Writable here will also break the
11855
  // Node.js LazyTransform implementation, which has a non-trivial getter for
11856
  // `_writableState` that would lead to infinite recursion.
11857
  if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
11858
    return new Writable(options);
11859
  }
11860
11861
  this._writableState = new WritableState(options, this);
11862
11863
  // legacy.
11864
  this.writable = true;
11865
11866
  if (options) {
11867
    if (typeof options.write === 'function') this._write = options.write;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11868
11869
    if (typeof options.writev === 'function') this._writev = options.writev;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11870
11871
    if (typeof options.destroy === 'function') this._destroy = options.destroy;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11872
11873
    if (typeof options.final === 'function') this._final = options.final;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11874
  }
11875
11876
  Stream.call(this);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
11877
}
11878
11879
// Otherwise people can pipe Writable streams, which is just wrong.
11880
Writable.prototype.pipe = function () {
11881
  this.emit('error', new Error('Cannot pipe, not readable'));
11882
};
11883
11884
function writeAfterEnd(stream, cb) {
11885
  var er = new Error('write after end');
11886
  // TODO: defer error events consistently everywhere, not just the cb
11887
  stream.emit('error', er);
11888
  processNextTick(cb, er);
11889
}
11890
11891
// Checks that a user-supplied chunk is valid, especially for the particular
11892
// mode the stream is in. Currently this means that `null` is never accepted
11893
// and undefined/non-string values are only allowed in object mode.
11894
function validChunk(stream, state, chunk, cb) {
11895
  var valid = true;
11896
  var er = false;
11897
11898
  if (chunk === null) {
11899
    er = new TypeError('May not write null values to stream');
11900
  } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
11901
    er = new TypeError('Invalid non-string/buffer chunk');
11902
  }
11903
  if (er) {
11904
    stream.emit('error', er);
11905
    processNextTick(cb, er);
11906
    valid = false;
11907
  }
11908
  return valid;
11909
}
11910
11911 View Code Duplication
Writable.prototype.write = function (chunk, encoding, cb) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11912
  var state = this._writableState;
11913
  var ret = false;
11914
  var isBuf = _isUint8Array(chunk) && !state.objectMode;
11915
11916
  if (isBuf && !Buffer.isBuffer(chunk)) {
11917
    chunk = _uint8ArrayToBuffer(chunk);
11918
  }
11919
11920
  if (typeof encoding === 'function') {
11921
    cb = encoding;
11922
    encoding = null;
11923
  }
11924
11925
  if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11926
11927
  if (typeof cb !== 'function') cb = nop;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11928
11929
  if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11930
    state.pendingcb++;
11931
    ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
11932
  }
11933
11934
  return ret;
11935
};
11936
11937
Writable.prototype.cork = function () {
11938
  var state = this._writableState;
11939
11940
  state.corked++;
11941
};
11942
11943
Writable.prototype.uncork = function () {
11944
  var state = this._writableState;
11945
11946
  if (state.corked) {
11947
    state.corked--;
11948
11949
    if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11950
  }
11951
};
11952
11953 View Code Duplication
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11954
  // node::ParseEncoding() requires lower case.
11955
  if (typeof encoding === 'string') encoding = encoding.toLowerCase();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11956
  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);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11957
  this._writableState.defaultEncoding = encoding;
11958
  return this;
11959
};
11960
11961
function decodeChunk(state, chunk, encoding) {
11962
  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
11963
    chunk = Buffer.from(chunk, encoding);
11964
  }
11965
  return chunk;
11966
}
11967
11968
// if we're already writing something, then just put this
11969
// in the queue, and wait our turn.  Otherwise, call _write
11970
// If we return false, then we need a drain event, so set that flag.
11971 View Code Duplication
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11972
  if (!isBuf) {
11973
    var newChunk = decodeChunk(state, chunk, encoding);
11974
    if (chunk !== newChunk) {
11975
      isBuf = true;
11976
      encoding = 'buffer';
11977
      chunk = newChunk;
11978
    }
11979
  }
11980
  var len = state.objectMode ? 1 : chunk.length;
11981
11982
  state.length += len;
11983
11984
  var ret = state.length < state.highWaterMark;
11985
  // we must ensure that previous needDrain will not be reset to false.
11986
  if (!ret) state.needDrain = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
11987
11988
  if (state.writing || state.corked) {
11989
    var last = state.lastBufferedRequest;
11990
    state.lastBufferedRequest = {
11991
      chunk: chunk,
11992
      encoding: encoding,
11993
      isBuf: isBuf,
11994
      callback: cb,
11995
      next: null
11996
    };
11997
    if (last) {
11998
      last.next = state.lastBufferedRequest;
11999
    } else {
12000
      state.bufferedRequest = state.lastBufferedRequest;
12001
    }
12002
    state.bufferedRequestCount += 1;
12003
  } else {
12004
    doWrite(stream, state, false, len, chunk, encoding, cb);
12005
  }
12006
12007
  return ret;
12008
}
12009
12010
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
12011
  state.writelen = len;
12012
  state.writecb = cb;
12013
  state.writing = true;
12014
  state.sync = true;
12015
  if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12016
  state.sync = false;
12017
}
12018
12019
function onwriteError(stream, state, sync, er, cb) {
12020
  --state.pendingcb;
12021
12022
  if (sync) {
12023
    // defer the callback if we are being called synchronously
12024
    // to avoid piling up things on the stack
12025
    processNextTick(cb, er);
12026
    // this can emit finish, and it will always happen
12027
    // after error
12028
    processNextTick(finishMaybe, stream, state);
12029
    stream._writableState.errorEmitted = true;
12030
    stream.emit('error', er);
12031
  } else {
12032
    // the caller expect this to happen before if
12033
    // it is async
12034
    cb(er);
12035
    stream._writableState.errorEmitted = true;
12036
    stream.emit('error', er);
12037
    // this can emit finish, but finish must
12038
    // always follow error
12039
    finishMaybe(stream, state);
12040
  }
12041
}
12042
12043
function onwriteStateUpdate(state) {
12044
  state.writing = false;
12045
  state.writecb = null;
12046
  state.length -= state.writelen;
12047
  state.writelen = 0;
12048
}
12049
12050
function onwrite(stream, er) {
12051
  var state = stream._writableState;
12052
  var sync = state.sync;
12053
  var cb = state.writecb;
12054
12055
  onwriteStateUpdate(state);
12056
12057
  if (er) onwriteError(stream, state, sync, er, cb);else {
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12058
    // Check if we're actually ready to finish, but don't emit yet
12059
    var finished = needFinish(state);
12060
12061
    if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
12062
      clearBuffer(stream, state);
12063
    }
12064
12065
    if (sync) {
12066
      /*<replacement>*/
12067
      asyncWrite(afterWrite, stream, state, finished, cb);
12068
      /*</replacement>*/
12069
    } else {
12070
      afterWrite(stream, state, finished, cb);
12071
    }
12072
  }
12073
}
12074
12075
function afterWrite(stream, state, finished, cb) {
12076
  if (!finished) onwriteDrain(stream, state);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12077
  state.pendingcb--;
12078
  cb();
12079
  finishMaybe(stream, state);
12080
}
12081
12082
// Must force callback to be called on nextTick, so that we don't
12083
// emit 'drain' before the write() consumer gets the 'false' return
12084
// value, and has a chance to attach a 'drain' listener.
12085
function onwriteDrain(stream, state) {
12086
  if (state.length === 0 && state.needDrain) {
12087
    state.needDrain = false;
12088
    stream.emit('drain');
12089
  }
12090
}
12091
12092
// if there's something in the buffer waiting, then process it
12093 View Code Duplication
function clearBuffer(stream, state) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12094
  state.bufferProcessing = true;
12095
  var entry = state.bufferedRequest;
12096
12097
  if (stream._writev && entry && entry.next) {
12098
    // Fast case, write everything using _writev()
12099
    var l = state.bufferedRequestCount;
12100
    var buffer = new Array(l);
12101
    var holder = state.corkedRequestsFree;
12102
    holder.entry = entry;
12103
12104
    var count = 0;
12105
    var allBuffers = true;
12106
    while (entry) {
12107
      buffer[count] = entry;
12108
      if (!entry.isBuf) allBuffers = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12109
      entry = entry.next;
12110
      count += 1;
12111
    }
12112
    buffer.allBuffers = allBuffers;
12113
12114
    doWrite(stream, state, true, state.length, buffer, '', holder.finish);
12115
12116
    // doWrite is almost always async, defer these to save a bit of time
12117
    // as the hot path ends with doWrite
12118
    state.pendingcb++;
12119
    state.lastBufferedRequest = null;
12120
    if (holder.next) {
12121
      state.corkedRequestsFree = holder.next;
12122
      holder.next = null;
12123
    } else {
12124
      state.corkedRequestsFree = new CorkedRequest(state);
12125
    }
12126
  } else {
12127
    // Slow case, write chunks one-by-one
12128
    while (entry) {
12129
      var chunk = entry.chunk;
12130
      var encoding = entry.encoding;
12131
      var cb = entry.callback;
12132
      var len = state.objectMode ? 1 : chunk.length;
12133
12134
      doWrite(stream, state, false, len, chunk, encoding, cb);
12135
      entry = entry.next;
12136
      // if we didn't call the onwrite immediately, then
12137
      // it means that we need to wait until it does.
12138
      // also, that means that the chunk and cb are currently
12139
      // being processed, so move the buffer counter past them.
12140
      if (state.writing) {
12141
        break;
12142
      }
12143
    }
12144
12145
    if (entry === null) state.lastBufferedRequest = null;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12146
  }
12147
12148
  state.bufferedRequestCount = 0;
12149
  state.bufferedRequest = entry;
12150
  state.bufferProcessing = false;
12151
}
12152
12153
Writable.prototype._write = function (chunk, encoding, cb) {
12154
  cb(new Error('_write() is not implemented'));
12155
};
12156
12157
Writable.prototype._writev = null;
12158
12159 View Code Duplication
Writable.prototype.end = function (chunk, encoding, cb) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12160
  var state = this._writableState;
12161
12162
  if (typeof chunk === 'function') {
12163
    cb = chunk;
12164
    chunk = null;
12165
    encoding = null;
12166
  } else if (typeof encoding === 'function') {
12167
    cb = encoding;
12168
    encoding = null;
12169
  }
12170
12171
  if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12172
12173
  // .end() fully uncorks
12174
  if (state.corked) {
12175
    state.corked = 1;
12176
    this.uncork();
12177
  }
12178
12179
  // ignore unnecessary end() calls.
12180
  if (!state.ending && !state.finished) endWritable(this, state, cb);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12181
};
12182
12183
function needFinish(state) {
12184
  return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
12185
}
12186
function callFinal(stream, state) {
12187
  stream._final(function (err) {
12188
    state.pendingcb--;
12189
    if (err) {
12190
      stream.emit('error', err);
12191
    }
12192
    state.prefinished = true;
12193
    stream.emit('prefinish');
12194
    finishMaybe(stream, state);
12195
  });
12196
}
12197
function prefinish(stream, state) {
12198
  if (!state.prefinished && !state.finalCalled) {
12199
    if (typeof stream._final === 'function') {
12200
      state.pendingcb++;
12201
      state.finalCalled = true;
12202
      processNextTick(callFinal, stream, state);
12203
    } else {
12204
      state.prefinished = true;
12205
      stream.emit('prefinish');
12206
    }
12207
  }
12208
}
12209
12210
function finishMaybe(stream, state) {
12211
  var need = needFinish(state);
12212
  if (need) {
12213
    prefinish(stream, state);
12214
    if (state.pendingcb === 0) {
12215
      state.finished = true;
12216
      stream.emit('finish');
12217
    }
12218
  }
12219
  return need;
12220
}
12221
12222
function endWritable(stream, state, cb) {
12223
  state.ending = true;
12224
  finishMaybe(stream, state);
12225
  if (cb) {
12226
    if (state.finished) processNextTick(cb);else stream.once('finish', cb);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12227
  }
12228
  state.ended = true;
12229
  stream.writable = false;
12230
}
12231
12232
function onCorkedFinish(corkReq, state, err) {
12233
  var entry = corkReq.entry;
12234
  corkReq.entry = null;
12235
  while (entry) {
12236
    var cb = entry.callback;
12237
    state.pendingcb--;
12238
    cb(err);
12239
    entry = entry.next;
12240
  }
12241
  if (state.corkedRequestsFree) {
12242
    state.corkedRequestsFree.next = corkReq;
12243
  } else {
12244
    state.corkedRequestsFree = corkReq;
12245
  }
12246
}
12247
12248
Object.defineProperty(Writable.prototype, 'destroyed', {
12249
  get: function () {
12250
    if (this._writableState === undefined) {
12251
      return false;
12252
    }
12253
    return this._writableState.destroyed;
12254
  },
12255
  set: function (value) {
12256
    // we ignore the value if the stream
12257
    // has not been initialized yet
12258
    if (!this._writableState) {
12259
      return;
12260
    }
12261
12262
    // backward compatibility, the user is explicitly
12263
    // managing destroyed
12264
    this._writableState.destroyed = value;
12265
  }
12266
});
12267
12268
Writable.prototype.destroy = destroyImpl.destroy;
12269
Writable.prototype._undestroy = destroyImpl.undestroy;
12270
Writable.prototype._destroy = function (err, cb) {
12271
  this.end();
12272
  cb(err);
12273
};
12274
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12275
},{"./_stream_duplex":57,"./internal/streams/destroy":63,"./internal/streams/stream":64,"_process":55,"core-util-is":41,"inherits":49,"process-nextick-args":54,"safe-buffer":69,"util-deprecate":72}],62:[function(require,module,exports){
12276
'use strict';
12277
12278
/*<replacement>*/
12279
12280
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12281
12282
var Buffer = require('safe-buffer').Buffer;
12283
/*</replacement>*/
12284
12285
function copyBuffer(src, target, offset) {
12286
  src.copy(target, offset);
12287
}
12288
12289 View Code Duplication
module.exports = function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12290
  function BufferList() {
12291
    _classCallCheck(this, BufferList);
12292
12293
    this.head = null;
12294
    this.tail = null;
12295
    this.length = 0;
12296
  }
12297
12298
  BufferList.prototype.push = function push(v) {
12299
    var entry = { data: v, next: null };
12300
    if (this.length > 0) this.tail.next = entry;else this.head = entry;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12301
    this.tail = entry;
12302
    ++this.length;
12303
  };
12304
12305
  BufferList.prototype.unshift = function unshift(v) {
12306
    var entry = { data: v, next: this.head };
12307
    if (this.length === 0) this.tail = entry;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12308
    this.head = entry;
12309
    ++this.length;
12310
  };
12311
12312
  BufferList.prototype.shift = function shift() {
12313
    if (this.length === 0) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
12314
    var ret = this.head.data;
12315
    if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12316
    --this.length;
12317
    return ret;
12318
  };
12319
12320
  BufferList.prototype.clear = function clear() {
12321
    this.head = this.tail = null;
12322
    this.length = 0;
12323
  };
12324
12325
  BufferList.prototype.join = function join(s) {
12326
    if (this.length === 0) return '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12327
    var p = this.head;
12328
    var ret = '' + p.data;
12329
    while (p = p.next) {
12330
      ret += s + p.data;
12331
    }return ret;
12332
  };
12333
12334
  BufferList.prototype.concat = function concat(n) {
12335
    if (this.length === 0) return Buffer.alloc(0);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12336
    if (this.length === 1) return this.head.data;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12337
    var ret = Buffer.allocUnsafe(n >>> 0);
12338
    var p = this.head;
12339
    var i = 0;
12340
    while (p) {
12341
      copyBuffer(p.data, ret, i);
12342
      i += p.data.length;
12343
      p = p.next;
12344
    }
12345
    return ret;
12346
  };
12347
12348
  return BufferList;
12349
}();
12350
},{"safe-buffer":69}],63:[function(require,module,exports){
12351
'use strict';
12352
12353
/*<replacement>*/
12354
12355
var processNextTick = require('process-nextick-args');
12356
/*</replacement>*/
12357
12358
// undocumented cb() API, needed for core, not for public API
12359
function destroy(err, cb) {
12360
  var _this = this;
12361
12362
  var readableDestroyed = this._readableState && this._readableState.destroyed;
12363
  var writableDestroyed = this._writableState && this._writableState.destroyed;
12364
12365
  if (readableDestroyed || writableDestroyed) {
12366
    if (cb) {
12367
      cb(err);
12368
    } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
12369
      processNextTick(emitErrorNT, this, err);
12370
    }
12371
    return;
12372
  }
12373
12374
  // we set destroyed to true before firing error callbacks in order
12375
  // to make it re-entrance safe in case destroy() is called within callbacks
12376
12377
  if (this._readableState) {
12378
    this._readableState.destroyed = true;
12379
  }
12380
12381
  // if this is a duplex stream mark the writable part as destroyed as well
12382
  if (this._writableState) {
12383
    this._writableState.destroyed = true;
12384
  }
12385
12386
  this._destroy(err || null, function (err) {
12387
    if (!cb && err) {
12388
      processNextTick(emitErrorNT, _this, err);
12389
      if (_this._writableState) {
12390
        _this._writableState.errorEmitted = true;
12391
      }
12392
    } else if (cb) {
12393
      cb(err);
12394
    }
12395
  });
12396
}
12397
12398
function undestroy() {
12399
  if (this._readableState) {
12400
    this._readableState.destroyed = false;
12401
    this._readableState.reading = false;
12402
    this._readableState.ended = false;
12403
    this._readableState.endEmitted = false;
12404
  }
12405
12406
  if (this._writableState) {
12407
    this._writableState.destroyed = false;
12408
    this._writableState.ended = false;
12409
    this._writableState.ending = false;
12410
    this._writableState.finished = false;
12411
    this._writableState.errorEmitted = false;
12412
  }
12413
}
12414
12415
function emitErrorNT(self, err) {
12416
  self.emit('error', err);
12417
}
12418
12419
module.exports = {
12420
  destroy: destroy,
12421
  undestroy: undestroy
12422
};
12423
},{"process-nextick-args":54}],64:[function(require,module,exports){
12424
module.exports = require('events').EventEmitter;
12425
12426
},{"events":46}],65:[function(require,module,exports){
12427
module.exports = require('./readable').PassThrough
12428
12429
},{"./readable":66}],66:[function(require,module,exports){
12430
exports = module.exports = require('./lib/_stream_readable.js');
12431
exports.Stream = exports;
12432
exports.Readable = exports;
12433
exports.Writable = require('./lib/_stream_writable.js');
12434
exports.Duplex = require('./lib/_stream_duplex.js');
12435
exports.Transform = require('./lib/_stream_transform.js');
12436
exports.PassThrough = require('./lib/_stream_passthrough.js');
12437
12438
},{"./lib/_stream_duplex.js":57,"./lib/_stream_passthrough.js":58,"./lib/_stream_readable.js":59,"./lib/_stream_transform.js":60,"./lib/_stream_writable.js":61}],67:[function(require,module,exports){
12439
module.exports = require('./readable').Transform
12440
12441
},{"./readable":66}],68:[function(require,module,exports){
12442
module.exports = require('./lib/_stream_writable.js');
12443
12444
},{"./lib/_stream_writable.js":61}],69:[function(require,module,exports){
12445
/* eslint-disable node/no-deprecated-api */
12446
var buffer = require('buffer')
12447
var Buffer = buffer.Buffer
12448
12449
// alternative to using Object.keys for old browsers
12450
function copyProps (src, dst) {
12451
  for (var key in src) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
12452
    dst[key] = src[key]
12453
  }
12454
}
12455
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
12456
  module.exports = buffer
12457
} else {
12458
  // Copy properties from require('buffer')
12459
  copyProps(buffer, exports)
12460
  exports.Buffer = SafeBuffer
12461
}
12462
12463
function SafeBuffer (arg, encodingOrOffset, length) {
12464
  return Buffer(arg, encodingOrOffset, length)
12465
}
12466
12467
// Copy static methods from Buffer
12468
copyProps(Buffer, SafeBuffer)
12469
12470
SafeBuffer.from = function (arg, encodingOrOffset, length) {
12471
  if (typeof arg === 'number') {
12472
    throw new TypeError('Argument must not be a number')
12473
  }
12474
  return Buffer(arg, encodingOrOffset, length)
12475
}
12476
12477
SafeBuffer.alloc = function (size, fill, encoding) {
12478
  if (typeof size !== 'number') {
12479
    throw new TypeError('Argument must be a number')
12480
  }
12481
  var buf = Buffer(size)
12482
  if (fill !== undefined) {
12483
    if (typeof encoding === 'string') {
12484
      buf.fill(fill, encoding)
12485
    } else {
12486
      buf.fill(fill)
12487
    }
12488
  } else {
12489
    buf.fill(0)
12490
  }
12491
  return buf
12492
}
12493
12494
SafeBuffer.allocUnsafe = function (size) {
12495
  if (typeof size !== 'number') {
12496
    throw new TypeError('Argument must be a number')
12497
  }
12498
  return Buffer(size)
12499
}
12500
12501
SafeBuffer.allocUnsafeSlow = function (size) {
12502
  if (typeof size !== 'number') {
12503
    throw new TypeError('Argument must be a number')
12504
  }
12505
  return buffer.SlowBuffer(size)
12506
}
12507
12508
},{"buffer":"buffer"}],70:[function(require,module,exports){
12509
// Copyright Joyent, Inc. and other Node contributors.
12510
//
12511
// Permission is hereby granted, free of charge, to any person obtaining a
12512
// copy of this software and associated documentation files (the
12513
// "Software"), to deal in the Software without restriction, including
12514
// without limitation the rights to use, copy, modify, merge, publish,
12515
// distribute, sublicense, and/or sell copies of the Software, and to permit
12516
// persons to whom the Software is furnished to do so, subject to the
12517
// following conditions:
12518
//
12519
// The above copyright notice and this permission notice shall be included
12520
// in all copies or substantial portions of the Software.
12521
//
12522
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12523
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12524
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
12525
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
12526
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
12527
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
12528
// USE OR OTHER DEALINGS IN THE SOFTWARE.
12529
12530
module.exports = Stream;
12531
12532
var EE = require('events').EventEmitter;
12533
var inherits = require('inherits');
12534
12535
inherits(Stream, EE);
12536
Stream.Readable = require('readable-stream/readable.js');
12537
Stream.Writable = require('readable-stream/writable.js');
12538
Stream.Duplex = require('readable-stream/duplex.js');
12539
Stream.Transform = require('readable-stream/transform.js');
12540
Stream.PassThrough = require('readable-stream/passthrough.js');
12541
12542
// Backwards-compat with node 0.4.x
12543
Stream.Stream = Stream;
12544
12545
12546
12547
// old-style streams.  Note that the pipe method (the only relevant
12548
// part of this class) is overridden in the Readable class.
12549
12550
function Stream() {
12551
  EE.call(this);
12552
}
12553
12554
Stream.prototype.pipe = function(dest, options) {
12555
  var source = this;
12556
12557
  function ondata(chunk) {
12558
    if (dest.writable) {
12559
      if (false === dest.write(chunk) && source.pause) {
12560
        source.pause();
12561
      }
12562
    }
12563
  }
12564
12565
  source.on('data', ondata);
12566
12567
  function ondrain() {
12568
    if (source.readable && source.resume) {
12569
      source.resume();
12570
    }
12571
  }
12572
12573
  dest.on('drain', ondrain);
12574
12575
  // If the 'end' option is not supplied, dest.end() will be called when
12576
  // source gets the 'end' or 'close' events.  Only dest.end() once.
12577
  if (!dest._isStdio && (!options || options.end !== false)) {
12578
    source.on('end', onend);
12579
    source.on('close', onclose);
12580
  }
12581
12582
  var didOnEnd = false;
12583
  function onend() {
12584
    if (didOnEnd) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12585
    didOnEnd = true;
12586
12587
    dest.end();
12588
  }
12589
12590
12591
  function onclose() {
12592
    if (didOnEnd) return;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12593
    didOnEnd = true;
12594
12595
    if (typeof dest.destroy === 'function') dest.destroy();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12596
  }
12597
12598
  // don't leave dangling pipes when there are errors.
12599
  function onerror(er) {
12600
    cleanup();
12601
    if (EE.listenerCount(this, 'error') === 0) {
12602
      throw er; // Unhandled stream error in pipe.
12603
    }
12604
  }
12605
12606
  source.on('error', onerror);
12607
  dest.on('error', onerror);
12608
12609
  // remove all the event listeners that were added.
12610
  function cleanup() {
12611
    source.removeListener('data', ondata);
12612
    dest.removeListener('drain', ondrain);
12613
12614
    source.removeListener('end', onend);
12615
    source.removeListener('close', onclose);
12616
12617
    source.removeListener('error', onerror);
12618
    dest.removeListener('error', onerror);
12619
12620
    source.removeListener('end', cleanup);
12621
    source.removeListener('close', cleanup);
12622
12623
    dest.removeListener('close', cleanup);
12624
  }
12625
12626
  source.on('end', cleanup);
12627
  source.on('close', cleanup);
12628
12629
  dest.on('close', cleanup);
12630
12631
  dest.emit('pipe', source);
12632
12633
  // Allow for unix-like usage: A.pipe(B).pipe(C)
12634
  return dest;
12635
};
12636
12637
},{"events":46,"inherits":49,"readable-stream/duplex.js":56,"readable-stream/passthrough.js":65,"readable-stream/readable.js":66,"readable-stream/transform.js":67,"readable-stream/writable.js":68}],71:[function(require,module,exports){
12638
'use strict';
12639
12640
var Buffer = require('safe-buffer').Buffer;
12641
12642 View Code Duplication
var isEncoding = Buffer.isEncoding || function (encoding) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12643
  encoding = '' + encoding;
12644
  switch (encoding && encoding.toLowerCase()) {
12645
    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':
12646
      return true;
12647
    default:
12648
      return false;
12649
  }
12650
};
12651
12652 View Code Duplication
function _normalizeEncoding(enc) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12653
  if (!enc) return 'utf8';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12654
  var retried;
12655
  while (true) {
12656
    switch (enc) {
12657
      case 'utf8':
12658
      case 'utf-8':
12659
        return 'utf8';
12660
      case 'ucs2':
12661
      case 'ucs-2':
12662
      case 'utf16le':
12663
      case 'utf-16le':
12664
        return 'utf16le';
12665
      case 'latin1':
12666
      case 'binary':
12667
        return 'latin1';
12668
      case 'base64':
12669
      case 'ascii':
12670
      case 'hex':
12671
        return enc;
12672
      default:
12673
        if (retried) return; // undefined
0 ignored issues
show
Comprehensibility Best Practice introduced by
Are you sure this return statement is not missing an argument? If this is intended, consider adding an explicit undefined like return undefined;.
Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12674
        enc = ('' + enc).toLowerCase();
12675
        retried = true;
12676
    }
12677
  }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
12678
};
12679
12680
// Do not cache `Buffer.isEncoding` when checking encoding names as some
12681
// modules monkey-patch it to support additional encodings
12682
function normalizeEncoding(enc) {
12683
  var nenc = _normalizeEncoding(enc);
12684
  if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12685
  return nenc || enc;
12686
}
12687
12688
// StringDecoder provides an interface for efficiently splitting a series of
12689
// buffers into a series of JS strings without breaking apart multi-byte
12690
// characters.
12691
exports.StringDecoder = StringDecoder;
12692 View Code Duplication
function StringDecoder(encoding) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12693
  this.encoding = normalizeEncoding(encoding);
12694
  var nb;
12695
  switch (this.encoding) {
12696
    case 'utf16le':
12697
      this.text = utf16Text;
12698
      this.end = utf16End;
12699
      nb = 4;
12700
      break;
12701
    case 'utf8':
12702
      this.fillLast = utf8FillLast;
12703
      nb = 4;
12704
      break;
12705
    case 'base64':
12706
      this.text = base64Text;
12707
      this.end = base64End;
12708
      nb = 3;
12709
      break;
12710
    default:
12711
      this.write = simpleWrite;
12712
      this.end = simpleEnd;
12713
      return;
12714
  }
12715
  this.lastNeed = 0;
12716
  this.lastTotal = 0;
12717
  this.lastChar = Buffer.allocUnsafe(nb);
12718
}
12719
12720 View Code Duplication
StringDecoder.prototype.write = function (buf) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12721
  if (buf.length === 0) return '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12722
  var r;
12723
  var i;
12724
  if (this.lastNeed) {
12725
    r = this.fillLast(buf);
12726
    if (r === undefined) return '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12727
    i = this.lastNeed;
12728
    this.lastNeed = 0;
12729
  } else {
12730
    i = 0;
12731
  }
12732
  if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12733
  return r || '';
12734
};
12735
12736
StringDecoder.prototype.end = utf8End;
12737
12738
// Returns only complete characters in a Buffer
12739
StringDecoder.prototype.text = utf8Text;
12740
12741
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
12742
StringDecoder.prototype.fillLast = function (buf) {
12743
  if (this.lastNeed <= buf.length) {
12744
    buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
12745
    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
12746
  }
12747
  buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
12748
  this.lastNeed -= buf.length;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
12749
};
12750
12751
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
12752
// continuation byte.
12753 View Code Duplication
function utf8CheckByte(byte) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12754
  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;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12755
  return -1;
12756
}
12757
12758
// Checks at most 3 bytes at the end of a Buffer in order to detect an
12759
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
12760
// needed to complete the UTF-8 character (if applicable) are returned.
12761 View Code Duplication
function utf8CheckIncomplete(self, buf, i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12762
  var j = buf.length - 1;
12763
  if (j < i) return 0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12764
  var nb = utf8CheckByte(buf[j]);
12765
  if (nb >= 0) {
12766
    if (nb > 0) self.lastNeed = nb - 1;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12767
    return nb;
12768
  }
12769
  if (--j < i) return 0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12770
  nb = utf8CheckByte(buf[j]);
12771
  if (nb >= 0) {
12772
    if (nb > 0) self.lastNeed = nb - 2;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12773
    return nb;
12774
  }
12775
  if (--j < i) return 0;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12776
  nb = utf8CheckByte(buf[j]);
12777
  if (nb >= 0) {
12778
    if (nb > 0) {
12779
      if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12780
    }
12781
    return nb;
12782
  }
12783
  return 0;
12784
}
12785
12786
// Validates as many continuation bytes for a multi-byte UTF-8 character as
12787
// needed or are available. If we see a non-continuation byte where we expect
12788
// one, we "replace" the validated continuation bytes we've seen so far with
12789
// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
12790
// behavior. The continuation byte check is included three times in the case
12791
// where all of the continuation bytes for a character exist in the same buffer.
12792
// It is also done this way as a slight performance increase instead of using a
12793
// loop.
12794 View Code Duplication
function utf8CheckExtraBytes(self, buf, p) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12795
  if ((buf[0] & 0xC0) !== 0x80) {
12796
    self.lastNeed = 0;
12797
    return '\ufffd'.repeat(p);
12798
  }
12799
  if (self.lastNeed > 1 && buf.length > 1) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if self.lastNeed > 1 && buf.length > 1 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
12800
    if ((buf[1] & 0xC0) !== 0x80) {
12801
      self.lastNeed = 1;
12802
      return '\ufffd'.repeat(p + 1);
12803
    }
12804
    if (self.lastNeed > 2 && buf.length > 2) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if self.lastNeed > 2 && buf.length > 2 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
12805
      if ((buf[2] & 0xC0) !== 0x80) {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if buf.2 & 192 !== 128 is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
12806
        self.lastNeed = 2;
12807
        return '\ufffd'.repeat(p + 2);
12808
      }
12809
    }
12810
  }
12811
}
12812
12813
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
12814
function utf8FillLast(buf) {
12815
  var p = this.lastTotal - this.lastNeed;
12816
  var r = utf8CheckExtraBytes(this, buf, p);
12817
  if (r !== undefined) return r;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12818
  if (this.lastNeed <= buf.length) {
12819
    buf.copy(this.lastChar, p, 0, this.lastNeed);
12820
    return this.lastChar.toString(this.encoding, 0, this.lastTotal);
12821
  }
12822
  buf.copy(this.lastChar, p, 0, buf.length);
12823
  this.lastNeed -= buf.length;
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
12824
}
12825
12826
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
12827
// partial character, the character's bytes are buffered until the required
12828
// number of bytes are available.
12829
function utf8Text(buf, i) {
12830
  var total = utf8CheckIncomplete(this, buf, i);
12831
  if (!this.lastNeed) return buf.toString('utf8', i);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12832
  this.lastTotal = total;
12833
  var end = buf.length - (total - this.lastNeed);
12834
  buf.copy(this.lastChar, 0, end);
12835
  return buf.toString('utf8', i, end);
12836
}
12837
12838
// For UTF-8, a replacement character for each buffered byte of a (partial)
12839
// character needs to be added to the output.
12840
function utf8End(buf) {
12841
  var r = buf && buf.length ? this.write(buf) : '';
12842
  if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12843
  return r;
12844
}
12845
12846
// UTF-16LE typically needs two bytes per character, but even if we have an even
12847
// number of bytes available, we need to check if we end on a leading/high
12848
// surrogate. In that case, we need to wait for the next two bytes in order to
12849
// decode the last character properly.
12850 View Code Duplication
function utf16Text(buf, i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12851
  if ((buf.length - i) % 2 === 0) {
12852
    var r = buf.toString('utf16le', i);
12853
    if (r) {
12854
      var c = r.charCodeAt(r.length - 1);
12855
      if (c >= 0xD800 && c <= 0xDBFF) {
12856
        this.lastNeed = 2;
12857
        this.lastTotal = 4;
12858
        this.lastChar[0] = buf[buf.length - 2];
12859
        this.lastChar[1] = buf[buf.length - 1];
12860
        return r.slice(0, -1);
12861
      }
12862
    }
12863
    return r;
12864
  }
12865
  this.lastNeed = 1;
12866
  this.lastTotal = 2;
12867
  this.lastChar[0] = buf[buf.length - 1];
12868
  return buf.toString('utf16le', i, buf.length - 1);
12869
}
12870
12871
// For UTF-16LE we do not explicitly append special replacement characters if we
12872
// end on a partial character, we simply let v8 handle that.
12873
function utf16End(buf) {
12874
  var r = buf && buf.length ? this.write(buf) : '';
12875
  if (this.lastNeed) {
12876
    var end = this.lastTotal - this.lastNeed;
12877
    return r + this.lastChar.toString('utf16le', 0, end);
12878
  }
12879
  return r;
12880
}
12881
12882 View Code Duplication
function base64Text(buf, i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
12883
  var n = (buf.length - i) % 3;
12884
  if (n === 0) return buf.toString('base64', i);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12885
  this.lastNeed = 3 - n;
12886
  this.lastTotal = 3;
12887
  if (n === 1) {
12888
    this.lastChar[0] = buf[buf.length - 1];
12889
  } else {
12890
    this.lastChar[0] = buf[buf.length - 2];
12891
    this.lastChar[1] = buf[buf.length - 1];
12892
  }
12893
  return buf.toString('base64', i, buf.length - n);
12894
}
12895
12896
function base64End(buf) {
12897
  var r = buf && buf.length ? this.write(buf) : '';
12898
  if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12899
  return r;
12900
}
12901
12902
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
12903
function simpleWrite(buf) {
12904
  return buf.toString(this.encoding);
12905
}
12906
12907
function simpleEnd(buf) {
12908
  return buf && buf.length ? this.write(buf) : '';
12909
}
12910
},{"safe-buffer":69}],72:[function(require,module,exports){
12911
(function (global){
12912
12913
/**
12914
 * Module exports.
12915
 */
12916
12917
module.exports = deprecate;
12918
12919
/**
12920
 * Mark that a method should not be used.
12921
 * Returns a modified function which warns once by default.
12922
 *
12923
 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
12924
 *
12925
 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
12926
 * will throw an Error when invoked.
12927
 *
12928
 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
12929
 * will invoke `console.trace()` instead of `console.error()`.
12930
 *
12931
 * @param {Function} fn - the function to deprecate
12932
 * @param {String} msg - the string to print to the console when `fn` is invoked
12933
 * @returns {Function} a new "deprecated" version of `fn`
12934
 * @api public
12935
 */
12936
12937
function deprecate (fn, msg) {
12938
  if (config('noDeprecation')) {
12939
    return fn;
12940
  }
12941
12942
  var warned = false;
12943
  function deprecated() {
12944
    if (!warned) {
12945
      if (config('throwDeprecation')) {
12946
        throw new Error(msg);
12947
      } else if (config('traceDeprecation')) {
12948
        console.trace(msg);
12949
      } else {
12950
        console.warn(msg);
12951
      }
12952
      warned = true;
12953
    }
12954
    return fn.apply(this, arguments);
12955
  }
12956
12957
  return deprecated;
12958
}
12959
12960
/**
12961
 * Checks `localStorage` for boolean values for the given `name`.
12962
 *
12963
 * @param {String} name
12964
 * @returns {Boolean}
12965
 * @api private
12966
 */
12967
12968
function config (name) {
12969
  // accessing global.localStorage can trigger a DOMException in sandboxed iframes
12970
  try {
12971
    if (!global.localStorage) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
12972
  } catch (_) {
12973
    return false;
12974
  }
12975
  var val = global.localStorage[name];
12976
  if (null == val) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Best Practice introduced by
Comparing null to val using the == operator is not safe. Consider using === instead.
Loading history...
12977
  return String(val).toLowerCase() === 'true';
12978
}
12979
12980
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
12981
},{}],73:[function(require,module,exports){
12982
arguments[4][49][0].apply(exports,arguments)
12983
},{"dup":49}],74:[function(require,module,exports){
12984
module.exports = function isBuffer(arg) {
12985
  return arg && typeof arg === 'object'
12986
    && typeof arg.copy === 'function'
12987
    && typeof arg.fill === 'function'
12988
    && typeof arg.readUInt8 === 'function';
12989
}
12990
},{}],75:[function(require,module,exports){
12991
(function (process,global){
12992
// Copyright Joyent, Inc. and other Node contributors.
12993
//
12994
// Permission is hereby granted, free of charge, to any person obtaining a
12995
// copy of this software and associated documentation files (the
12996
// "Software"), to deal in the Software without restriction, including
12997
// without limitation the rights to use, copy, modify, merge, publish,
12998
// distribute, sublicense, and/or sell copies of the Software, and to permit
12999
// persons to whom the Software is furnished to do so, subject to the
13000
// following conditions:
13001
//
13002
// The above copyright notice and this permission notice shall be included
13003
// in all copies or substantial portions of the Software.
13004
//
13005
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13006
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13007
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13008
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13009
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13010
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13011
// USE OR OTHER DEALINGS IN THE SOFTWARE.
13012
13013
var formatRegExp = /%[sdj%]/g;
13014
exports.format = function(f) {
13015
  if (!isString(f)) {
13016
    var objects = [];
13017
    for (var i = 0; i < arguments.length; i++) {
13018
      objects.push(inspect(arguments[i]));
13019
    }
13020
    return objects.join(' ');
13021
  }
13022
13023
  var i = 1;
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable i already seems to be declared on line 13017. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
13024
  var args = arguments;
13025
  var len = args.length;
13026
  var str = String(f).replace(formatRegExp, function(x) {
13027
    if (x === '%%') return '%';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13028
    if (i >= len) return x;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13029
    switch (x) {
13030
      case '%s': return String(args[i++]);
13031
      case '%d': return Number(args[i++]);
13032
      case '%j':
13033
        try {
13034
          return JSON.stringify(args[i++]);
13035
        } catch (_) {
13036
          return '[Circular]';
13037
        }
13038
      default:
13039
        return x;
13040
    }
13041
  });
13042
  for (var x = args[i]; i < len; x = args[++i]) {
0 ignored issues
show
Unused Code introduced by
The loop variable x is initialized by the loop but not used in the test. Consider using another type of loop if this is the intended behavior.
Loading history...
13043
    if (isNull(x) || !isObject(x)) {
13044
      str += ' ' + x;
13045
    } else {
13046
      str += ' ' + inspect(x);
13047
    }
13048
  }
13049
  return str;
13050
};
13051
13052
13053
// Mark that a method should not be used.
13054
// Returns a modified function which warns once by default.
13055
// If --no-deprecation is set, then it is a no-op.
13056
exports.deprecate = function(fn, msg) {
13057
  // Allow for deprecating things in the process of starting up.
13058
  if (isUndefined(global.process)) {
13059
    return function() {
13060
      return exports.deprecate(fn, msg).apply(this, arguments);
13061
    };
13062
  }
13063
13064
  if (process.noDeprecation === true) {
13065
    return fn;
13066
  }
13067
13068
  var warned = false;
13069
  function deprecated() {
13070
    if (!warned) {
13071
      if (process.throwDeprecation) {
13072
        throw new Error(msg);
13073
      } else if (process.traceDeprecation) {
13074
        console.trace(msg);
13075
      } else {
13076
        console.error(msg);
13077
      }
13078
      warned = true;
13079
    }
13080
    return fn.apply(this, arguments);
13081
  }
13082
13083
  return deprecated;
13084
};
13085
13086
13087
var debugs = {};
13088
var debugEnviron;
13089
exports.debuglog = function(set) {
13090
  if (isUndefined(debugEnviron))
13091
    debugEnviron = process.env.NODE_DEBUG || '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13092
  set = set.toUpperCase();
13093
  if (!debugs[set]) {
13094
    if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
0 ignored issues
show
Bug introduced by
The variable debugEnviron does not seem to be initialized in case isUndefined(debugEnviron) on line 13090 is false. Are you sure the function test handles undefined variables?
Loading history...
13095
      var pid = process.pid;
13096
      debugs[set] = function() {
13097
        var msg = exports.format.apply(exports, arguments);
13098
        console.error('%s %d: %s', set, pid, msg);
13099
      };
13100
    } else {
13101
      debugs[set] = function() {};
13102
    }
13103
  }
13104
  return debugs[set];
13105
};
13106
13107
13108
/**
13109
 * Echos the value of a value. Trys to print the value out
13110
 * in the best way possible given the different types.
13111
 *
13112
 * @param {Object} obj The object to print out.
13113
 * @param {Object} opts Optional options object that alters the output.
13114
 */
13115
/* legacy: obj, showHidden, depth, colors*/
13116
function inspect(obj, opts) {
13117
  // default options
13118
  var ctx = {
13119
    seen: [],
13120
    stylize: stylizeNoColor
13121
  };
13122
  // legacy...
13123
  if (arguments.length >= 3) ctx.depth = arguments[2];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13124
  if (arguments.length >= 4) ctx.colors = arguments[3];
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13125
  if (isBoolean(opts)) {
13126
    // legacy...
13127
    ctx.showHidden = opts;
13128
  } else if (opts) {
13129
    // got an "options" object
13130
    exports._extend(ctx, opts);
13131
  }
13132
  // set default options
13133
  if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13134
  if (isUndefined(ctx.depth)) ctx.depth = 2;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13135
  if (isUndefined(ctx.colors)) ctx.colors = false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13136
  if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13137
  if (ctx.colors) ctx.stylize = stylizeWithColor;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13138
  return formatValue(ctx, obj, ctx.depth);
13139
}
13140
exports.inspect = inspect;
13141
13142
13143
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
13144
inspect.colors = {
13145
  'bold' : [1, 22],
13146
  'italic' : [3, 23],
13147
  'underline' : [4, 24],
13148
  'inverse' : [7, 27],
13149
  'white' : [37, 39],
13150
  'grey' : [90, 39],
13151
  'black' : [30, 39],
13152
  'blue' : [34, 39],
13153
  'cyan' : [36, 39],
13154
  'green' : [32, 39],
13155
  'magenta' : [35, 39],
13156
  'red' : [31, 39],
13157
  'yellow' : [33, 39]
13158
};
13159
13160
// Don't use 'blue' not visible on cmd.exe
13161
inspect.styles = {
13162
  'special': 'cyan',
13163
  'number': 'yellow',
13164
  'boolean': 'yellow',
13165
  'undefined': 'grey',
13166
  'null': 'bold',
13167
  'string': 'green',
13168
  'date': 'magenta',
13169
  // "name": intentionally not styling
13170
  'regexp': 'red'
13171
};
13172
13173
13174
function stylizeWithColor(str, styleType) {
13175
  var style = inspect.styles[styleType];
13176
13177
  if (style) {
13178
    return '\u001b[' + inspect.colors[style][0] + 'm' + str +
13179
           '\u001b[' + inspect.colors[style][1] + 'm';
13180
  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
13181
    return str;
13182
  }
13183
}
13184
13185
13186
function stylizeNoColor(str, styleType) {
0 ignored issues
show
Unused Code introduced by
The parameter styleType is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
13187
  return str;
13188
}
13189
13190
13191
function arrayToHash(array) {
13192
  var hash = {};
13193
13194
  array.forEach(function(val, idx) {
0 ignored issues
show
Unused Code introduced by
The parameter idx is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
13195
    hash[val] = true;
13196
  });
13197
13198
  return hash;
13199
}
13200
13201
13202
function formatValue(ctx, value, recurseTimes) {
13203
  // Provide a hook for user-specified inspect functions.
13204
  // Check that value is an object with an inspect function on it
13205
  if (ctx.customInspect &&
13206
      value &&
13207
      isFunction(value.inspect) &&
13208
      // Filter out the util module, it's inspect function is special
13209
      value.inspect !== exports.inspect &&
13210
      // Also filter out any prototype objects using the circular check.
13211
      !(value.constructor && value.constructor.prototype === value)) {
13212
    var ret = value.inspect(recurseTimes, ctx);
13213
    if (!isString(ret)) {
13214
      ret = formatValue(ctx, ret, recurseTimes);
13215
    }
13216
    return ret;
13217
  }
13218
13219
  // Primitive types cannot have properties
13220
  var primitive = formatPrimitive(ctx, value);
13221
  if (primitive) {
13222
    return primitive;
13223
  }
13224
13225
  // Look up the keys of the object.
13226
  var keys = Object.keys(value);
13227
  var visibleKeys = arrayToHash(keys);
13228
13229
  if (ctx.showHidden) {
13230
    keys = Object.getOwnPropertyNames(value);
13231
  }
13232
13233
  // IE doesn't make error fields non-enumerable
13234
  // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
13235
  if (isError(value)
13236
      && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
13237
    return formatError(value);
13238
  }
13239
13240
  // Some type of object without properties can be shortcutted.
13241
  if (keys.length === 0) {
13242
    if (isFunction(value)) {
13243
      var name = value.name ? ': ' + value.name : '';
13244
      return ctx.stylize('[Function' + name + ']', 'special');
13245
    }
13246
    if (isRegExp(value)) {
13247
      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
13248
    }
13249
    if (isDate(value)) {
13250
      return ctx.stylize(Date.prototype.toString.call(value), 'date');
13251
    }
13252
    if (isError(value)) {
13253
      return formatError(value);
13254
    }
13255
  }
13256
13257
  var base = '', array = false, braces = ['{', '}'];
13258
13259
  // Make Array say that they are Array
13260
  if (isArray(value)) {
13261
    array = true;
13262
    braces = ['[', ']'];
13263
  }
13264
13265
  // Make functions say that they are functions
13266
  if (isFunction(value)) {
13267
    var n = value.name ? ': ' + value.name : '';
13268
    base = ' [Function' + n + ']';
13269
  }
13270
13271
  // Make RegExps say that they are RegExps
13272
  if (isRegExp(value)) {
13273
    base = ' ' + RegExp.prototype.toString.call(value);
13274
  }
13275
13276
  // Make dates with properties first say the date
13277
  if (isDate(value)) {
13278
    base = ' ' + Date.prototype.toUTCString.call(value);
13279
  }
13280
13281
  // Make error with message first say the error
13282
  if (isError(value)) {
13283
    base = ' ' + formatError(value);
13284
  }
13285
13286
  if (keys.length === 0 && (!array || value.length == 0)) {
0 ignored issues
show
Best Practice introduced by
Comparing value.length to 0 using the == operator is not safe. Consider using === instead.
Loading history...
13287
    return braces[0] + base + braces[1];
13288
  }
13289
13290
  if (recurseTimes < 0) {
13291
    if (isRegExp(value)) {
13292
      return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
13293
    } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
13294
      return ctx.stylize('[Object]', 'special');
13295
    }
13296
  }
13297
13298
  ctx.seen.push(value);
13299
13300
  var output;
13301
  if (array) {
13302
    output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
13303
  } else {
13304
    output = keys.map(function(key) {
13305
      return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
13306
    });
13307
  }
13308
13309
  ctx.seen.pop();
13310
13311
  return reduceToSingleString(output, base, braces);
13312
}
13313
13314
13315
function formatPrimitive(ctx, value) {
13316
  if (isUndefined(value))
13317
    return ctx.stylize('undefined', 'undefined');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13318
  if (isString(value)) {
13319
    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
13320
                                             .replace(/'/g, "\\'")
13321
                                             .replace(/\\"/g, '"') + '\'';
13322
    return ctx.stylize(simple, 'string');
13323
  }
13324
  if (isNumber(value))
13325
    return ctx.stylize('' + value, 'number');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13326
  if (isBoolean(value))
13327
    return ctx.stylize('' + value, 'boolean');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13328
  // For some reason typeof null is "object", so special case here.
13329
  if (isNull(value))
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if isNull(value) is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
13330
    return ctx.stylize('null', 'null');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13331
}
13332
13333
13334
function formatError(value) {
13335
  return '[' + Error.prototype.toString.call(value) + ']';
13336
}
13337
13338
13339
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
13340
  var output = [];
13341
  for (var i = 0, l = value.length; i < l; ++i) {
13342
    if (hasOwnProperty(value, String(i))) {
13343
      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
13344
          String(i), true));
13345
    } else {
13346
      output.push('');
13347
    }
13348
  }
13349
  keys.forEach(function(key) {
13350
    if (!key.match(/^\d+$/)) {
13351
      output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
13352
          key, true));
13353
    }
13354
  });
13355
  return output;
13356
}
13357
13358
13359
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
13360
  var name, str, desc;
13361
  desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
13362
  if (desc.get) {
13363
    if (desc.set) {
13364
      str = ctx.stylize('[Getter/Setter]', 'special');
13365
    } else {
13366
      str = ctx.stylize('[Getter]', 'special');
13367
    }
13368
  } else {
13369
    if (desc.set) {
13370
      str = ctx.stylize('[Setter]', 'special');
13371
    }
13372
  }
13373
  if (!hasOwnProperty(visibleKeys, key)) {
13374
    name = '[' + key + ']';
13375
  }
13376
  if (!str) {
13377
    if (ctx.seen.indexOf(desc.value) < 0) {
13378
      if (isNull(recurseTimes)) {
13379
        str = formatValue(ctx, desc.value, null);
13380
      } else {
13381
        str = formatValue(ctx, desc.value, recurseTimes - 1);
13382
      }
13383
      if (str.indexOf('\n') > -1) {
13384
        if (array) {
13385
          str = str.split('\n').map(function(line) {
13386
            return '  ' + line;
13387
          }).join('\n').substr(2);
13388
        } else {
13389
          str = '\n' + str.split('\n').map(function(line) {
13390
            return '   ' + line;
13391
          }).join('\n');
13392
        }
13393
      }
13394
    } else {
13395
      str = ctx.stylize('[Circular]', 'special');
13396
    }
13397
  }
13398
  if (isUndefined(name)) {
0 ignored issues
show
Bug introduced by
The variable name does not seem to be initialized in case !hasOwnProperty(visibleKeys, key) on line 13373 is false. Are you sure the function isUndefined handles undefined variables?
Loading history...
13399
    if (array && key.match(/^\d+$/)) {
13400
      return str;
13401
    }
13402
    name = JSON.stringify('' + key);
13403
    if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
13404
      name = name.substr(1, name.length - 2);
13405
      name = ctx.stylize(name, 'name');
13406
    } else {
13407
      name = name.replace(/'/g, "\\'")
13408
                 .replace(/\\"/g, '"')
13409
                 .replace(/(^"|"$)/g, "'");
13410
      name = ctx.stylize(name, 'string');
13411
    }
13412
  }
13413
13414
  return name + ': ' + str;
13415
}
13416
13417
13418
function reduceToSingleString(output, base, braces) {
13419
  var numLinesEst = 0;
13420
  var length = output.reduce(function(prev, cur) {
13421
    numLinesEst++;
13422
    if (cur.indexOf('\n') >= 0) numLinesEst++;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13423
    return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
13424
  }, 0);
13425
13426
  if (length > 60) {
13427
    return braces[0] +
13428
           (base === '' ? '' : base + '\n ') +
13429
           ' ' +
13430
           output.join(',\n  ') +
13431
           ' ' +
13432
           braces[1];
13433
  }
13434
13435
  return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
13436
}
13437
13438
13439
// NOTE: These type checking functions intentionally don't use `instanceof`
13440
// because it is fragile and can be easily faked with `Object.create()`.
13441
function isArray(ar) {
13442
  return Array.isArray(ar);
13443
}
13444
exports.isArray = isArray;
13445
13446
function isBoolean(arg) {
13447
  return typeof arg === 'boolean';
13448
}
13449
exports.isBoolean = isBoolean;
13450
13451
function isNull(arg) {
13452
  return arg === null;
13453
}
13454
exports.isNull = isNull;
13455
13456
function isNullOrUndefined(arg) {
13457
  return arg == null;
0 ignored issues
show
Best Practice introduced by
Comparing arg to null using the == operator is not safe. Consider using === instead.
Loading history...
13458
}
13459
exports.isNullOrUndefined = isNullOrUndefined;
13460
13461
function isNumber(arg) {
13462
  return typeof arg === 'number';
13463
}
13464
exports.isNumber = isNumber;
13465
13466
function isString(arg) {
13467
  return typeof arg === 'string';
13468
}
13469
exports.isString = isString;
13470
13471
function isSymbol(arg) {
13472
  return typeof arg === 'symbol';
13473
}
13474
exports.isSymbol = isSymbol;
13475
13476
function isUndefined(arg) {
13477
  return arg === void 0;
0 ignored issues
show
Coding Style introduced by
Consider using undefined instead of void(0). It is equivalent and more straightforward to read.
Loading history...
13478
}
13479
exports.isUndefined = isUndefined;
13480
13481
function isRegExp(re) {
13482
  return isObject(re) && objectToString(re) === '[object RegExp]';
13483
}
13484
exports.isRegExp = isRegExp;
13485
13486
function isObject(arg) {
13487
  return typeof arg === 'object' && arg !== null;
13488
}
13489
exports.isObject = isObject;
13490
13491
function isDate(d) {
13492
  return isObject(d) && objectToString(d) === '[object Date]';
13493
}
13494
exports.isDate = isDate;
13495
13496
function isError(e) {
13497
  return isObject(e) &&
13498
      (objectToString(e) === '[object Error]' || e instanceof Error);
13499
}
13500
exports.isError = isError;
13501
13502
function isFunction(arg) {
13503
  return typeof arg === 'function';
13504
}
13505
exports.isFunction = isFunction;
13506
13507 View Code Duplication
function isPrimitive(arg) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
13508
  return arg === null ||
13509
         typeof arg === 'boolean' ||
13510
         typeof arg === 'number' ||
13511
         typeof arg === 'string' ||
13512
         typeof arg === 'symbol' ||  // ES6 symbol
13513
         typeof arg === 'undefined';
13514
}
13515
exports.isPrimitive = isPrimitive;
13516
13517
exports.isBuffer = require('./support/isBuffer');
13518
13519
function objectToString(o) {
13520
  return Object.prototype.toString.call(o);
13521
}
13522
13523
13524
function pad(n) {
13525
  return n < 10 ? '0' + n.toString(10) : n.toString(10);
13526
}
13527
13528
13529
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
13530
              'Oct', 'Nov', 'Dec'];
13531
13532
// 26 Feb 16:19:34
13533
function timestamp() {
13534
  var d = new Date();
13535
  var time = [pad(d.getHours()),
13536
              pad(d.getMinutes()),
13537
              pad(d.getSeconds())].join(':');
13538
  return [d.getDate(), months[d.getMonth()], time].join(' ');
13539
}
13540
13541
13542
// log is just a thin wrapper to console.log that prepends a timestamp
13543
exports.log = function() {
13544
  console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
13545
};
13546
13547
13548
/**
13549
 * Inherit the prototype methods from one constructor into another.
13550
 *
13551
 * The Function.prototype.inherits from lang.js rewritten as a standalone
13552
 * function (not on Function.prototype). NOTE: If this file is to be loaded
13553
 * during bootstrapping this function needs to be rewritten using some native
13554
 * functions as prototype setup using normal JavaScript does not work as
13555
 * expected during bootstrapping (see mirror.js in r114903).
13556
 *
13557
 * @param {function} ctor Constructor function which needs to inherit the
13558
 *     prototype.
13559
 * @param {function} superCtor Constructor function to inherit prototype from.
13560
 */
13561
exports.inherits = require('inherits');
13562
13563
exports._extend = function(origin, add) {
13564
  // Don't do anything if add isn't an object
13565
  if (!add || !isObject(add)) return origin;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13566
13567
  var keys = Object.keys(add);
13568
  var i = keys.length;
13569
  while (i--) {
13570
    origin[keys[i]] = add[keys[i]];
13571
  }
13572
  return origin;
13573
};
13574
13575
function hasOwnProperty(obj, prop) {
13576
  return Object.prototype.hasOwnProperty.call(obj, prop);
13577
}
13578
13579
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
13580
},{"./support/isBuffer":74,"_process":55,"inherits":73}],"buffer":[function(require,module,exports){
13581
(function (global){
13582
/*!
13583
 * The buffer module from node.js, for the browser.
13584
 *
13585
 * @author   Feross Aboukhadijeh <[email protected]> <http://feross.org>
13586
 * @license  MIT
13587
 */
13588
/* eslint-disable no-proto */
13589
13590
'use strict'
13591
13592
var base64 = require('base64-js')
13593
var ieee754 = require('ieee754')
13594
var isArray = require('isarray')
13595
13596
exports.Buffer = Buffer
13597
exports.SlowBuffer = SlowBuffer
13598
exports.INSPECT_MAX_BYTES = 50
13599
13600
/**
13601
 * If `Buffer.TYPED_ARRAY_SUPPORT`:
13602
 *   === true    Use Uint8Array implementation (fastest)
13603
 *   === false   Use Object implementation (most compatible, even IE6)
13604
 *
13605
 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
13606
 * Opera 11.6+, iOS 4.2+.
13607
 *
13608
 * Due to various browser bugs, sometimes the Object implementation will be used even
13609
 * when the browser supports typed arrays.
13610
 *
13611
 * Note:
13612
 *
13613
 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
13614
 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
13615
 *
13616
 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
13617
 *
13618
 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
13619
 *     incorrect length in some situations.
13620
13621
 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
13622
 * get the Object implementation, which is slower but behaves correctly.
13623
 */
13624
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
13625
  ? global.TYPED_ARRAY_SUPPORT
13626
  : typedArraySupport()
13627
13628
/*
13629
 * Export kMaxLength after typed array support is determined.
13630
 */
13631
exports.kMaxLength = kMaxLength()
13632
13633
function typedArraySupport () {
13634
  try {
13635
    var arr = new Uint8Array(1)
13636
    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
13637
    return arr.foo() === 42 && // typed array instances can be augmented
13638
        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
13639
        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
13640
  } catch (e) {
13641
    return false
13642
  }
13643
}
13644
13645
function kMaxLength () {
13646
  return Buffer.TYPED_ARRAY_SUPPORT
13647
    ? 0x7fffffff
13648
    : 0x3fffffff
13649
}
13650
13651
function createBuffer (that, length) {
13652
  if (kMaxLength() < length) {
13653
    throw new RangeError('Invalid typed array length')
13654
  }
13655
  if (Buffer.TYPED_ARRAY_SUPPORT) {
13656
    // Return an augmented `Uint8Array` instance, for best performance
13657
    that = new Uint8Array(length)
13658
    that.__proto__ = Buffer.prototype
13659
  } else {
13660
    // Fallback: Return an object instance of the Buffer class
13661
    if (that === null) {
13662
      that = new Buffer(length)
13663
    }
13664
    that.length = length
13665
  }
13666
13667
  return that
13668
}
13669
13670
/**
13671
 * The Buffer constructor returns instances of `Uint8Array` that have their
13672
 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
13673
 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
13674
 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
13675
 * returns a single octet.
13676
 *
13677
 * The `Uint8Array` prototype remains unmodified.
13678
 */
13679
13680
function Buffer (arg, encodingOrOffset, length) {
13681
  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
13682
    return new Buffer(arg, encodingOrOffset, length)
13683
  }
13684
13685
  // Common case.
13686
  if (typeof arg === 'number') {
13687
    if (typeof encodingOrOffset === 'string') {
13688
      throw new Error(
13689
        'If encoding is specified then the first argument must be a string'
13690
      )
13691
    }
13692
    return allocUnsafe(this, arg)
13693
  }
13694
  return from(this, arg, encodingOrOffset, length)
13695
}
13696
13697
Buffer.poolSize = 8192 // not used by this implementation
13698
13699
// TODO: Legacy, not needed anymore. Remove in next major version.
13700
Buffer._augment = function (arr) {
13701
  arr.__proto__ = Buffer.prototype
13702
  return arr
13703
}
13704
13705
function from (that, value, encodingOrOffset, length) {
13706
  if (typeof value === 'number') {
13707
    throw new TypeError('"value" argument must not be a number')
13708
  }
13709
13710
  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
13711
    return fromArrayBuffer(that, value, encodingOrOffset, length)
13712
  }
13713
13714
  if (typeof value === 'string') {
13715
    return fromString(that, value, encodingOrOffset)
13716
  }
13717
13718
  return fromObject(that, value)
13719
}
13720
13721
/**
13722
 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
13723
 * if value is a number.
13724
 * Buffer.from(str[, encoding])
13725
 * Buffer.from(array)
13726
 * Buffer.from(buffer)
13727
 * Buffer.from(arrayBuffer[, byteOffset[, length]])
13728
 **/
13729
Buffer.from = function (value, encodingOrOffset, length) {
13730
  return from(null, value, encodingOrOffset, length)
13731
}
13732
13733
if (Buffer.TYPED_ARRAY_SUPPORT) {
13734
  Buffer.prototype.__proto__ = Uint8Array.prototype
13735
  Buffer.__proto__ = Uint8Array
13736
  if (typeof Symbol !== 'undefined' && Symbol.species &&
0 ignored issues
show
Bug introduced by
The variable Symbol seems to be never declared. If this is a global, consider adding a /** global: Symbol */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
13737
      Buffer[Symbol.species] === Buffer) {
13738
    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
13739
    Object.defineProperty(Buffer, Symbol.species, {
13740
      value: null,
13741
      configurable: true
13742
    })
13743
  }
13744
}
13745
13746
function assertSize (size) {
13747
  if (typeof size !== 'number') {
13748
    throw new TypeError('"size" argument must be a number')
13749
  } else if (size < 0) {
13750
    throw new RangeError('"size" argument must not be negative')
13751
  }
13752
}
13753
13754
function alloc (that, size, fill, encoding) {
13755
  assertSize(size)
13756
  if (size <= 0) {
13757
    return createBuffer(that, size)
13758
  }
13759
  if (fill !== undefined) {
13760
    // Only pay attention to encoding if it's a string. This
13761
    // prevents accidentally sending in a number that would
13762
    // be interpretted as a start offset.
13763
    return typeof encoding === 'string'
13764
      ? createBuffer(that, size).fill(fill, encoding)
13765
      : createBuffer(that, size).fill(fill)
13766
  }
13767
  return createBuffer(that, size)
13768
}
13769
13770
/**
13771
 * Creates a new filled Buffer instance.
13772
 * alloc(size[, fill[, encoding]])
13773
 **/
13774
Buffer.alloc = function (size, fill, encoding) {
13775
  return alloc(null, size, fill, encoding)
13776
}
13777
13778
function allocUnsafe (that, size) {
13779
  assertSize(size)
13780
  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
13781
  if (!Buffer.TYPED_ARRAY_SUPPORT) {
13782
    for (var i = 0; i < size; ++i) {
13783
      that[i] = 0
13784
    }
13785
  }
13786
  return that
13787
}
13788
13789
/**
13790
 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
13791
 * */
13792
Buffer.allocUnsafe = function (size) {
13793
  return allocUnsafe(null, size)
13794
}
13795
/**
13796
 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
13797
 */
13798
Buffer.allocUnsafeSlow = function (size) {
13799
  return allocUnsafe(null, size)
13800
}
13801
13802
function fromString (that, string, encoding) {
13803
  if (typeof encoding !== 'string' || encoding === '') {
13804
    encoding = 'utf8'
13805
  }
13806
13807
  if (!Buffer.isEncoding(encoding)) {
13808
    throw new TypeError('"encoding" must be a valid string encoding')
13809
  }
13810
13811
  var length = byteLength(string, encoding) | 0
13812
  that = createBuffer(that, length)
13813
13814
  var actual = that.write(string, encoding)
13815
13816
  if (actual !== length) {
13817
    // Writing a hex string, for example, that contains invalid characters will
13818
    // cause everything after the first invalid character to be ignored. (e.g.
13819
    // 'abxxcd' will be treated as 'ab')
13820
    that = that.slice(0, actual)
13821
  }
13822
13823
  return that
13824
}
13825
13826
function fromArrayLike (that, array) {
13827
  var length = array.length < 0 ? 0 : checked(array.length) | 0
13828
  that = createBuffer(that, length)
13829
  for (var i = 0; i < length; i += 1) {
13830
    that[i] = array[i] & 255
13831
  }
13832
  return that
13833
}
13834
13835
function fromArrayBuffer (that, array, byteOffset, length) {
13836
  array.byteLength // this throws if `array` is not a valid ArrayBuffer
0 ignored issues
show
introduced by
The result of the property access to array.byteLength is not used.
Loading history...
13837
13838
  if (byteOffset < 0 || array.byteLength < byteOffset) {
13839
    throw new RangeError('\'offset\' is out of bounds')
13840
  }
13841
13842
  if (array.byteLength < byteOffset + (length || 0)) {
13843
    throw new RangeError('\'length\' is out of bounds')
13844
  }
13845
13846
  if (byteOffset === undefined && length === undefined) {
13847
    array = new Uint8Array(array)
13848
  } else if (length === undefined) {
13849
    array = new Uint8Array(array, byteOffset)
13850
  } else {
13851
    array = new Uint8Array(array, byteOffset, length)
13852
  }
13853
13854
  if (Buffer.TYPED_ARRAY_SUPPORT) {
13855
    // Return an augmented `Uint8Array` instance, for best performance
13856
    that = array
13857
    that.__proto__ = Buffer.prototype
13858
  } else {
13859
    // Fallback: Return an object instance of the Buffer class
13860
    that = fromArrayLike(that, array)
13861
  }
13862
  return that
13863
}
13864
13865
function fromObject (that, obj) {
13866
  if (Buffer.isBuffer(obj)) {
13867
    var len = checked(obj.length) | 0
13868
    that = createBuffer(that, len)
13869
13870
    if (that.length === 0) {
13871
      return that
13872
    }
13873
13874
    obj.copy(that, 0, 0, len)
13875
    return that
13876
  }
13877
13878
  if (obj) {
13879
    if ((typeof ArrayBuffer !== 'undefined' &&
13880
        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
13881
      if (typeof obj.length !== 'number' || isnan(obj.length)) {
13882
        return createBuffer(that, 0)
13883
      }
13884
      return fromArrayLike(that, obj)
13885
    }
13886
13887
    if (obj.type === 'Buffer' && isArray(obj.data)) {
13888
      return fromArrayLike(that, obj.data)
13889
    }
13890
  }
13891
13892
  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
13893
}
13894
13895
function checked (length) {
13896
  // Note: cannot use `length < kMaxLength()` here because that fails when
13897
  // length is NaN (which is otherwise coerced to zero.)
13898
  if (length >= kMaxLength()) {
13899
    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
13900
                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
13901
  }
13902
  return length | 0
13903
}
13904
13905
function SlowBuffer (length) {
13906
  if (+length != length) { // eslint-disable-line eqeqeq
13907
    length = 0
13908
  }
13909
  return Buffer.alloc(+length)
13910
}
13911
13912
Buffer.isBuffer = function isBuffer (b) {
13913
  return !!(b != null && b._isBuffer)
0 ignored issues
show
Best Practice introduced by
Comparing b to null using the != operator is not safe. Consider using !== instead.
Loading history...
13914
}
13915
13916
Buffer.compare = function compare (a, b) {
13917
  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
13918
    throw new TypeError('Arguments must be Buffers')
13919
  }
13920
13921
  if (a === b) return 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13922
13923
  var x = a.length
13924
  var y = b.length
13925
13926
  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
13927
    if (a[i] !== b[i]) {
13928
      x = a[i]
13929
      y = b[i]
13930
      break
13931
    }
13932
  }
13933
13934
  if (x < y) return -1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13935
  if (y < x) return 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
13936
  return 0
13937
}
13938
13939
Buffer.isEncoding = function isEncoding (encoding) {
13940
  switch (String(encoding).toLowerCase()) {
13941
    case 'hex':
13942
    case 'utf8':
13943
    case 'utf-8':
13944
    case 'ascii':
13945
    case 'latin1':
13946
    case 'binary':
13947
    case 'base64':
13948
    case 'ucs2':
13949
    case 'ucs-2':
13950
    case 'utf16le':
13951
    case 'utf-16le':
13952
      return true
13953
    default:
13954
      return false
13955
  }
13956
}
13957
13958
Buffer.concat = function concat (list, length) {
13959
  if (!isArray(list)) {
13960
    throw new TypeError('"list" argument must be an Array of Buffers')
13961
  }
13962
13963
  if (list.length === 0) {
13964
    return Buffer.alloc(0)
13965
  }
13966
13967
  var i
13968
  if (length === undefined) {
13969
    length = 0
13970
    for (i = 0; i < list.length; ++i) {
13971
      length += list[i].length
13972
    }
13973
  }
13974
13975
  var buffer = Buffer.allocUnsafe(length)
13976
  var pos = 0
13977
  for (i = 0; i < list.length; ++i) {
13978
    var buf = list[i]
13979
    if (!Buffer.isBuffer(buf)) {
13980
      throw new TypeError('"list" argument must be an Array of Buffers')
13981
    }
13982
    buf.copy(buffer, pos)
13983
    pos += buf.length
13984
  }
13985
  return buffer
13986
}
13987
13988
function byteLength (string, encoding) {
13989
  if (Buffer.isBuffer(string)) {
13990
    return string.length
13991
  }
13992
  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
13993
      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
13994
    return string.byteLength
13995
  }
13996
  if (typeof string !== 'string') {
13997
    string = '' + string
13998
  }
13999
14000
  var len = string.length
14001
  if (len === 0) return 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14002
14003
  // Use a for loop to avoid recursion
14004
  var loweredCase = false
14005
  for (;;) {
14006
    switch (encoding) {
14007
      case 'ascii':
14008
      case 'latin1':
14009
      case 'binary':
14010
        return len
14011
      case 'utf8':
14012
      case 'utf-8':
14013
      case undefined:
14014
        return utf8ToBytes(string).length
14015
      case 'ucs2':
14016
      case 'ucs-2':
14017
      case 'utf16le':
14018
      case 'utf-16le':
14019
        return len * 2
14020
      case 'hex':
14021
        return len >>> 1
14022
      case 'base64':
14023
        return base64ToBytes(string).length
14024
      default:
14025
        if (loweredCase) return utf8ToBytes(string).length // assume utf8
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14026
        encoding = ('' + encoding).toLowerCase()
14027
        loweredCase = true
14028
    }
14029
  }
14030
}
14031
Buffer.byteLength = byteLength
14032
14033
function slowToString (encoding, start, end) {
14034
  var loweredCase = false
14035
14036
  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
14037
  // property of a typed array.
14038
14039
  // This behaves neither like String nor Uint8Array in that we set start/end
14040
  // to their upper/lower bounds if the value passed is out of range.
14041
  // undefined is handled specially as per ECMA-262 6th Edition,
14042
  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
14043
  if (start === undefined || start < 0) {
14044
    start = 0
14045
  }
14046
  // Return early if start > this.length. Done here to prevent potential uint32
14047
  // coercion fail below.
14048
  if (start > this.length) {
14049
    return ''
14050
  }
14051
14052
  if (end === undefined || end > this.length) {
14053
    end = this.length
14054
  }
14055
14056
  if (end <= 0) {
14057
    return ''
14058
  }
14059
14060
  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
14061
  end >>>= 0
14062
  start >>>= 0
14063
14064
  if (end <= start) {
14065
    return ''
14066
  }
14067
14068
  if (!encoding) encoding = 'utf8'
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14069
14070
  while (true) {
14071
    switch (encoding) {
14072
      case 'hex':
14073
        return hexSlice(this, start, end)
14074
14075
      case 'utf8':
14076
      case 'utf-8':
14077
        return utf8Slice(this, start, end)
14078
14079
      case 'ascii':
14080
        return asciiSlice(this, start, end)
14081
14082
      case 'latin1':
14083
      case 'binary':
14084
        return latin1Slice(this, start, end)
14085
14086
      case 'base64':
14087
        return base64Slice(this, start, end)
14088
14089
      case 'ucs2':
14090
      case 'ucs-2':
14091
      case 'utf16le':
14092
      case 'utf-16le':
14093
        return utf16leSlice(this, start, end)
14094
14095
      default:
14096
        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14097
        encoding = (encoding + '').toLowerCase()
14098
        loweredCase = true
14099
    }
14100
  }
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
14101
}
14102
14103
// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
14104
// Buffer instances.
14105
Buffer.prototype._isBuffer = true
14106
14107
function swap (b, n, m) {
14108
  var i = b[n]
14109
  b[n] = b[m]
14110
  b[m] = i
14111
}
14112
14113
Buffer.prototype.swap16 = function swap16 () {
14114
  var len = this.length
14115
  if (len % 2 !== 0) {
14116
    throw new RangeError('Buffer size must be a multiple of 16-bits')
14117
  }
14118
  for (var i = 0; i < len; i += 2) {
14119
    swap(this, i, i + 1)
14120
  }
14121
  return this
14122
}
14123
14124
Buffer.prototype.swap32 = function swap32 () {
14125
  var len = this.length
14126
  if (len % 4 !== 0) {
14127
    throw new RangeError('Buffer size must be a multiple of 32-bits')
14128
  }
14129
  for (var i = 0; i < len; i += 4) {
14130
    swap(this, i, i + 3)
14131
    swap(this, i + 1, i + 2)
14132
  }
14133
  return this
14134
}
14135
14136
Buffer.prototype.swap64 = function swap64 () {
14137
  var len = this.length
14138
  if (len % 8 !== 0) {
14139
    throw new RangeError('Buffer size must be a multiple of 64-bits')
14140
  }
14141
  for (var i = 0; i < len; i += 8) {
14142
    swap(this, i, i + 7)
14143
    swap(this, i + 1, i + 6)
14144
    swap(this, i + 2, i + 5)
14145
    swap(this, i + 3, i + 4)
14146
  }
14147
  return this
14148
}
14149
14150
Buffer.prototype.toString = function toString () {
14151
  var length = this.length | 0
14152
  if (length === 0) return ''
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14153
  if (arguments.length === 0) return utf8Slice(this, 0, length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14154
  return slowToString.apply(this, arguments)
14155
}
14156
14157
Buffer.prototype.equals = function equals (b) {
14158
  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14159
  if (this === b) return true
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14160
  return Buffer.compare(this, b) === 0
14161
}
14162
14163
Buffer.prototype.inspect = function inspect () {
14164
  var str = ''
14165
  var max = exports.INSPECT_MAX_BYTES
14166
  if (this.length > 0) {
14167
    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
14168
    if (this.length > max) str += ' ... '
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14169
  }
14170
  return '<Buffer ' + str + '>'
14171
}
14172
14173
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
14174
  if (!Buffer.isBuffer(target)) {
14175
    throw new TypeError('Argument must be a Buffer')
14176
  }
14177
14178
  if (start === undefined) {
14179
    start = 0
14180
  }
14181
  if (end === undefined) {
14182
    end = target ? target.length : 0
14183
  }
14184
  if (thisStart === undefined) {
14185
    thisStart = 0
14186
  }
14187
  if (thisEnd === undefined) {
14188
    thisEnd = this.length
14189
  }
14190
14191
  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
14192
    throw new RangeError('out of range index')
14193
  }
14194
14195
  if (thisStart >= thisEnd && start >= end) {
14196
    return 0
14197
  }
14198
  if (thisStart >= thisEnd) {
14199
    return -1
14200
  }
14201
  if (start >= end) {
14202
    return 1
14203
  }
14204
14205
  start >>>= 0
14206
  end >>>= 0
14207
  thisStart >>>= 0
14208
  thisEnd >>>= 0
14209
14210
  if (this === target) return 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14211
14212
  var x = thisEnd - thisStart
14213
  var y = end - start
14214
  var len = Math.min(x, y)
14215
14216
  var thisCopy = this.slice(thisStart, thisEnd)
14217
  var targetCopy = target.slice(start, end)
14218
14219
  for (var i = 0; i < len; ++i) {
14220
    if (thisCopy[i] !== targetCopy[i]) {
14221
      x = thisCopy[i]
14222
      y = targetCopy[i]
14223
      break
14224
    }
14225
  }
14226
14227
  if (x < y) return -1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14228
  if (y < x) return 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14229
  return 0
14230
}
14231
14232
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
14233
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
14234
//
14235
// Arguments:
14236
// - buffer - a Buffer to search
14237
// - val - a string, Buffer, or number
14238
// - byteOffset - an index into `buffer`; will be clamped to an int32
14239
// - encoding - an optional encoding, relevant is val is a string
14240
// - dir - true for indexOf, false for lastIndexOf
14241
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
14242
  // Empty buffer means no match
14243
  if (buffer.length === 0) return -1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14244
14245
  // Normalize byteOffset
14246
  if (typeof byteOffset === 'string') {
14247
    encoding = byteOffset
14248
    byteOffset = 0
14249
  } else if (byteOffset > 0x7fffffff) {
14250
    byteOffset = 0x7fffffff
14251
  } else if (byteOffset < -0x80000000) {
14252
    byteOffset = -0x80000000
14253
  }
14254
  byteOffset = +byteOffset  // Coerce to Number.
14255
  if (isNaN(byteOffset)) {
14256
    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
14257
    byteOffset = dir ? 0 : (buffer.length - 1)
14258
  }
14259
14260
  // Normalize byteOffset: negative offsets start from the end of the buffer
14261
  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14262
  if (byteOffset >= buffer.length) {
14263
    if (dir) return -1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14264
    else byteOffset = buffer.length - 1
14265
  } else if (byteOffset < 0) {
14266
    if (dir) byteOffset = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14267
    else return -1
14268
  }
14269
14270
  // Normalize val
14271
  if (typeof val === 'string') {
14272
    val = Buffer.from(val, encoding)
14273
  }
14274
14275
  // Finally, search either indexOf (if dir is true) or lastIndexOf
14276
  if (Buffer.isBuffer(val)) {
14277
    // Special case: looking for empty string/buffer always fails
14278
    if (val.length === 0) {
14279
      return -1
14280
    }
14281
    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
14282
  } else if (typeof val === 'number') {
14283
    val = val & 0xFF // Search for a byte value [0-255]
14284
    if (Buffer.TYPED_ARRAY_SUPPORT &&
14285
        typeof Uint8Array.prototype.indexOf === 'function') {
14286
      if (dir) {
14287
        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
14288
      } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
14289
        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
14290
      }
14291
    }
14292
    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
14293
  }
14294
14295
  throw new TypeError('val must be string, number or Buffer')
14296
}
14297
14298
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
14299
  var indexSize = 1
14300
  var arrLength = arr.length
14301
  var valLength = val.length
14302
14303
  if (encoding !== undefined) {
14304
    encoding = String(encoding).toLowerCase()
14305
    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
14306
        encoding === 'utf16le' || encoding === 'utf-16le') {
14307
      if (arr.length < 2 || val.length < 2) {
14308
        return -1
14309
      }
14310
      indexSize = 2
14311
      arrLength /= 2
14312
      valLength /= 2
14313
      byteOffset /= 2
14314
    }
14315
  }
14316
14317
  function read (buf, i) {
14318
    if (indexSize === 1) {
14319
      return buf[i]
14320
    } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
14321
      return buf.readUInt16BE(i * indexSize)
14322
    }
14323
  }
14324
14325
  var i
14326
  if (dir) {
14327
    var foundIndex = -1
14328
    for (i = byteOffset; i < arrLength; i++) {
14329
      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
14330
        if (foundIndex === -1) foundIndex = i
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14331
        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14332
      } else {
14333
        if (foundIndex !== -1) i -= i - foundIndex
0 ignored issues
show
Complexity Coding Style introduced by
You seem to be assigning a new value to the loop variable i here. Please check if this was indeed your intention. Even if it was, consider using another kind of loop instead.
Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14334
        foundIndex = -1
14335
      }
14336
    }
14337
  } else {
14338
    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14339
    for (i = byteOffset; i >= 0; i--) {
14340
      var found = true
14341
      for (var j = 0; j < valLength; j++) {
14342
        if (read(arr, i + j) !== read(val, j)) {
14343
          found = false
14344
          break
14345
        }
14346
      }
14347
      if (found) return i
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14348
    }
14349
  }
14350
14351
  return -1
14352
}
14353
14354
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
14355
  return this.indexOf(val, byteOffset, encoding) !== -1
14356
}
14357
14358
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
14359
  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
14360
}
14361
14362
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
14363
  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
14364
}
14365
14366
function hexWrite (buf, string, offset, length) {
14367
  offset = Number(offset) || 0
14368
  var remaining = buf.length - offset
14369
  if (!length) {
14370
    length = remaining
14371
  } else {
14372
    length = Number(length)
14373
    if (length > remaining) {
14374
      length = remaining
14375
    }
14376
  }
14377
14378
  // must be an even number of digits
14379
  var strLen = string.length
14380
  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14381
14382
  if (length > strLen / 2) {
14383
    length = strLen / 2
14384
  }
14385
  for (var i = 0; i < length; ++i) {
14386
    var parsed = parseInt(string.substr(i * 2, 2), 16)
14387
    if (isNaN(parsed)) return i
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14388
    buf[offset + i] = parsed
14389
  }
14390
  return i
14391
}
14392
14393
function utf8Write (buf, string, offset, length) {
14394
  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
14395
}
14396
14397
function asciiWrite (buf, string, offset, length) {
14398
  return blitBuffer(asciiToBytes(string), buf, offset, length)
14399
}
14400
14401
function latin1Write (buf, string, offset, length) {
14402
  return asciiWrite(buf, string, offset, length)
14403
}
14404
14405
function base64Write (buf, string, offset, length) {
14406
  return blitBuffer(base64ToBytes(string), buf, offset, length)
14407
}
14408
14409
function ucs2Write (buf, string, offset, length) {
14410
  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
14411
}
14412
14413
Buffer.prototype.write = function write (string, offset, length, encoding) {
14414
  // Buffer#write(string)
14415
  if (offset === undefined) {
14416
    encoding = 'utf8'
14417
    length = this.length
14418
    offset = 0
14419
  // Buffer#write(string, encoding)
14420
  } else if (length === undefined && typeof offset === 'string') {
14421
    encoding = offset
14422
    length = this.length
14423
    offset = 0
14424
  // Buffer#write(string, offset[, length][, encoding])
14425
  } else if (isFinite(offset)) {
14426
    offset = offset | 0
14427
    if (isFinite(length)) {
14428
      length = length | 0
14429
      if (encoding === undefined) encoding = 'utf8'
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14430
    } else {
14431
      encoding = length
14432
      length = undefined
14433
    }
14434
  // legacy write(string, encoding, offset, length) - remove in v0.13
14435
  } else {
14436
    throw new Error(
14437
      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
14438
    )
14439
  }
14440
14441
  var remaining = this.length - offset
14442
  if (length === undefined || length > remaining) length = remaining
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14443
14444
  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
14445
    throw new RangeError('Attempt to write outside buffer bounds')
14446
  }
14447
14448
  if (!encoding) encoding = 'utf8'
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14449
14450
  var loweredCase = false
14451
  for (;;) {
14452
    switch (encoding) {
14453
      case 'hex':
14454
        return hexWrite(this, string, offset, length)
14455
14456
      case 'utf8':
14457
      case 'utf-8':
14458
        return utf8Write(this, string, offset, length)
14459
14460
      case 'ascii':
14461
        return asciiWrite(this, string, offset, length)
14462
14463
      case 'latin1':
14464
      case 'binary':
14465
        return latin1Write(this, string, offset, length)
14466
14467
      case 'base64':
14468
        // Warning: maxLength not taken into account in base64Write
14469
        return base64Write(this, string, offset, length)
14470
14471
      case 'ucs2':
14472
      case 'ucs-2':
14473
      case 'utf16le':
14474
      case 'utf-16le':
14475
        return ucs2Write(this, string, offset, length)
14476
14477
      default:
14478
        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14479
        encoding = ('' + encoding).toLowerCase()
14480
        loweredCase = true
14481
    }
14482
  }
14483
}
14484
14485
Buffer.prototype.toJSON = function toJSON () {
14486
  return {
14487
    type: 'Buffer',
14488
    data: Array.prototype.slice.call(this._arr || this, 0)
14489
  }
14490
}
14491
14492
function base64Slice (buf, start, end) {
14493
  if (start === 0 && end === buf.length) {
14494
    return base64.fromByteArray(buf)
14495
  } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
14496
    return base64.fromByteArray(buf.slice(start, end))
14497
  }
14498
}
14499
14500
function utf8Slice (buf, start, end) {
14501
  end = Math.min(buf.length, end)
14502
  var res = []
14503
14504
  var i = start
14505
  while (i < end) {
14506
    var firstByte = buf[i]
14507
    var codePoint = null
14508
    var bytesPerSequence = (firstByte > 0xEF) ? 4
14509
      : (firstByte > 0xDF) ? 3
14510
      : (firstByte > 0xBF) ? 2
14511
      : 1
14512
14513
    if (i + bytesPerSequence <= end) {
14514
      var secondByte, thirdByte, fourthByte, tempCodePoint
14515
14516
      switch (bytesPerSequence) {
14517
        case 1:
14518
          if (firstByte < 0x80) {
14519
            codePoint = firstByte
14520
          }
14521
          break
14522
        case 2:
14523
          secondByte = buf[i + 1]
14524
          if ((secondByte & 0xC0) === 0x80) {
14525
            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
14526
            if (tempCodePoint > 0x7F) {
14527
              codePoint = tempCodePoint
14528
            }
14529
          }
14530
          break
14531
        case 3:
14532
          secondByte = buf[i + 1]
14533
          thirdByte = buf[i + 2]
14534 View Code Duplication
          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14535
            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
14536
            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
14537
              codePoint = tempCodePoint
14538
            }
14539
          }
14540
          break
14541
        case 4:
14542
          secondByte = buf[i + 1]
14543
          thirdByte = buf[i + 2]
14544
          fourthByte = buf[i + 3]
14545
          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
14546
            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
14547
            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
14548
              codePoint = tempCodePoint
14549
            }
14550
          }
14551
      }
14552
    }
14553
14554
    if (codePoint === null) {
14555
      // we did not generate a valid codePoint so insert a
14556
      // replacement char (U+FFFD) and advance only 1 byte
14557
      codePoint = 0xFFFD
14558
      bytesPerSequence = 1
14559
    } else if (codePoint > 0xFFFF) {
14560
      // encode to utf16 (surrogate pair dance)
14561
      codePoint -= 0x10000
14562
      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
14563
      codePoint = 0xDC00 | codePoint & 0x3FF
14564
    }
14565
14566
    res.push(codePoint)
14567
    i += bytesPerSequence
14568
  }
14569
14570
  return decodeCodePointsArray(res)
14571
}
14572
14573
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
14574
// the lowest limit is Chrome, with 0x10000 args.
14575
// We go 1 magnitude less, for safety
14576
var MAX_ARGUMENTS_LENGTH = 0x1000
14577
14578
function decodeCodePointsArray (codePoints) {
14579
  var len = codePoints.length
14580
  if (len <= MAX_ARGUMENTS_LENGTH) {
14581
    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
14582
  }
14583
14584
  // Decode in chunks to avoid "call stack size exceeded".
14585
  var res = ''
14586
  var i = 0
14587
  while (i < len) {
14588
    res += String.fromCharCode.apply(
14589
      String,
14590
      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
14591
    )
14592
  }
14593
  return res
14594
}
14595
14596
function asciiSlice (buf, start, end) {
14597
  var ret = ''
14598
  end = Math.min(buf.length, end)
14599
14600
  for (var i = start; i < end; ++i) {
14601
    ret += String.fromCharCode(buf[i] & 0x7F)
14602
  }
14603
  return ret
14604
}
14605
14606
function latin1Slice (buf, start, end) {
14607
  var ret = ''
14608
  end = Math.min(buf.length, end)
14609
14610
  for (var i = start; i < end; ++i) {
14611
    ret += String.fromCharCode(buf[i])
14612
  }
14613
  return ret
14614
}
14615
14616
function hexSlice (buf, start, end) {
14617
  var len = buf.length
14618
14619
  if (!start || start < 0) start = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14620
  if (!end || end < 0 || end > len) end = len
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14621
14622
  var out = ''
14623
  for (var i = start; i < end; ++i) {
14624
    out += toHex(buf[i])
14625
  }
14626
  return out
14627
}
14628
14629
function utf16leSlice (buf, start, end) {
14630
  var bytes = buf.slice(start, end)
14631
  var res = ''
14632
  for (var i = 0; i < bytes.length; i += 2) {
14633
    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
14634
  }
14635
  return res
14636
}
14637
14638
Buffer.prototype.slice = function slice (start, end) {
14639
  var len = this.length
14640
  start = ~~start
14641
  end = end === undefined ? len : ~~end
14642
14643
  if (start < 0) {
14644
    start += len
14645
    if (start < 0) start = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14646
  } else if (start > len) {
14647
    start = len
14648
  }
14649
14650
  if (end < 0) {
14651
    end += len
14652
    if (end < 0) end = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14653
  } else if (end > len) {
14654
    end = len
14655
  }
14656
14657
  if (end < start) end = start
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14658
14659
  var newBuf
14660
  if (Buffer.TYPED_ARRAY_SUPPORT) {
14661
    newBuf = this.subarray(start, end)
14662
    newBuf.__proto__ = Buffer.prototype
14663
  } else {
14664
    var sliceLen = end - start
14665
    newBuf = new Buffer(sliceLen, undefined)
14666
    for (var i = 0; i < sliceLen; ++i) {
14667
      newBuf[i] = this[i + start]
14668
    }
14669
  }
14670
14671
  return newBuf
14672
}
14673
14674
/*
14675
 * Need to make sure that buffer isn't trying to write out of bounds.
14676
 */
14677
function checkOffset (offset, ext, length) {
14678
  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14679
  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14680
}
14681
14682 View Code Duplication
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14683
  offset = offset | 0
14684
  byteLength = byteLength | 0
14685
  if (!noAssert) checkOffset(offset, byteLength, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14686
14687
  var val = this[offset]
14688
  var mul = 1
14689
  var i = 0
14690
  while (++i < byteLength && (mul *= 0x100)) {
14691
    val += this[offset + i] * mul
14692
  }
14693
14694
  return val
14695
}
14696
14697 View Code Duplication
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14698
  offset = offset | 0
14699
  byteLength = byteLength | 0
14700
  if (!noAssert) {
14701
    checkOffset(offset, byteLength, this.length)
14702
  }
14703
14704
  var val = this[offset + --byteLength]
14705
  var mul = 1
14706
  while (byteLength > 0 && (mul *= 0x100)) {
14707
    val += this[offset + --byteLength] * mul
14708
  }
14709
14710
  return val
14711
}
14712
14713
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
14714
  if (!noAssert) checkOffset(offset, 1, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14715
  return this[offset]
14716
}
14717
14718
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
14719
  if (!noAssert) checkOffset(offset, 2, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14720
  return this[offset] | (this[offset + 1] << 8)
14721
}
14722
14723
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
14724
  if (!noAssert) checkOffset(offset, 2, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14725
  return (this[offset] << 8) | this[offset + 1]
14726
}
14727
14728
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
14729
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14730
14731
  return ((this[offset]) |
14732
      (this[offset + 1] << 8) |
14733
      (this[offset + 2] << 16)) +
14734
      (this[offset + 3] * 0x1000000)
14735
}
14736
14737
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
14738
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14739
14740
  return (this[offset] * 0x1000000) +
14741
    ((this[offset + 1] << 16) |
14742
    (this[offset + 2] << 8) |
14743
    this[offset + 3])
14744
}
14745
14746 View Code Duplication
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14747
  offset = offset | 0
14748
  byteLength = byteLength | 0
14749
  if (!noAssert) checkOffset(offset, byteLength, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14750
14751
  var val = this[offset]
14752
  var mul = 1
14753
  var i = 0
14754
  while (++i < byteLength && (mul *= 0x100)) {
14755
    val += this[offset + i] * mul
14756
  }
14757
  mul *= 0x80
14758
14759
  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14760
14761
  return val
14762
}
14763
14764 View Code Duplication
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14765
  offset = offset | 0
14766
  byteLength = byteLength | 0
14767
  if (!noAssert) checkOffset(offset, byteLength, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14768
14769
  var i = byteLength
14770
  var mul = 1
14771
  var val = this[offset + --i]
14772
  while (i > 0 && (mul *= 0x100)) {
14773
    val += this[offset + --i] * mul
14774
  }
14775
  mul *= 0x80
14776
14777
  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14778
14779
  return val
14780
}
14781
14782
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
14783
  if (!noAssert) checkOffset(offset, 1, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14784
  if (!(this[offset] & 0x80)) return (this[offset])
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14785
  return ((0xff - this[offset] + 1) * -1)
14786
}
14787
14788
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
14789
  if (!noAssert) checkOffset(offset, 2, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14790
  var val = this[offset] | (this[offset + 1] << 8)
14791
  return (val & 0x8000) ? val | 0xFFFF0000 : val
0 ignored issues
show
introduced by
You have used a bitwise operator & in a condition. Did you maybe want to use the logical operator &&
Loading history...
14792
}
14793
14794
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
14795
  if (!noAssert) checkOffset(offset, 2, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14796
  var val = this[offset + 1] | (this[offset] << 8)
14797
  return (val & 0x8000) ? val | 0xFFFF0000 : val
0 ignored issues
show
introduced by
You have used a bitwise operator & in a condition. Did you maybe want to use the logical operator &&
Loading history...
14798
}
14799
14800
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
14801
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14802
14803
  return (this[offset]) |
14804
    (this[offset + 1] << 8) |
14805
    (this[offset + 2] << 16) |
14806
    (this[offset + 3] << 24)
14807
}
14808
14809
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
14810
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14811
14812
  return (this[offset] << 24) |
14813
    (this[offset + 1] << 16) |
14814
    (this[offset + 2] << 8) |
14815
    (this[offset + 3])
14816
}
14817
14818
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
14819
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14820
  return ieee754.read(this, offset, true, 23, 4)
14821
}
14822
14823
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
14824
  if (!noAssert) checkOffset(offset, 4, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14825
  return ieee754.read(this, offset, false, 23, 4)
14826
}
14827
14828
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
14829
  if (!noAssert) checkOffset(offset, 8, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14830
  return ieee754.read(this, offset, true, 52, 8)
14831
}
14832
14833
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
14834
  if (!noAssert) checkOffset(offset, 8, this.length)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14835
  return ieee754.read(this, offset, false, 52, 8)
14836
}
14837
14838
function checkInt (buf, value, offset, ext, max, min) {
14839
  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14840
  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14841
  if (offset + ext > buf.length) throw new RangeError('Index out of range')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14842
}
14843
14844
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
14845
  value = +value
14846
  offset = offset | 0
14847
  byteLength = byteLength | 0
14848
  if (!noAssert) {
14849
    var maxBytes = Math.pow(2, 8 * byteLength) - 1
14850
    checkInt(this, value, offset, byteLength, maxBytes, 0)
14851
  }
14852
14853
  var mul = 1
14854
  var i = 0
14855
  this[offset] = value & 0xFF
14856
  while (++i < byteLength && (mul *= 0x100)) {
14857
    this[offset + i] = (value / mul) & 0xFF
14858
  }
14859
14860
  return offset + byteLength
14861
}
14862
14863 View Code Duplication
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14864
  value = +value
14865
  offset = offset | 0
14866
  byteLength = byteLength | 0
14867
  if (!noAssert) {
14868
    var maxBytes = Math.pow(2, 8 * byteLength) - 1
14869
    checkInt(this, value, offset, byteLength, maxBytes, 0)
14870
  }
14871
14872
  var i = byteLength - 1
14873
  var mul = 1
14874
  this[offset + i] = value & 0xFF
14875
  while (--i >= 0 && (mul *= 0x100)) {
14876
    this[offset + i] = (value / mul) & 0xFF
14877
  }
14878
14879
  return offset + byteLength
14880
}
14881
14882
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
14883
  value = +value
14884
  offset = offset | 0
14885
  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14886
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14887
  this[offset] = (value & 0xff)
14888
  return offset + 1
14889
}
14890
14891 View Code Duplication
function objectWriteUInt16 (buf, value, offset, littleEndian) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14892
  if (value < 0) value = 0xffff + value + 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14893
  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
14894
    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
14895
      (littleEndian ? i : 1 - i) * 8
14896
  }
14897
}
14898
14899
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
14900
  value = +value
14901
  offset = offset | 0
14902
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14903
  if (Buffer.TYPED_ARRAY_SUPPORT) {
14904
    this[offset] = (value & 0xff)
14905
    this[offset + 1] = (value >>> 8)
14906
  } else {
14907
    objectWriteUInt16(this, value, offset, true)
14908
  }
14909
  return offset + 2
14910
}
14911
14912
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
14913
  value = +value
14914
  offset = offset | 0
14915
  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14916
  if (Buffer.TYPED_ARRAY_SUPPORT) {
14917
    this[offset] = (value >>> 8)
14918
    this[offset + 1] = (value & 0xff)
14919
  } else {
14920
    objectWriteUInt16(this, value, offset, false)
14921
  }
14922
  return offset + 2
14923
}
14924
14925 View Code Duplication
function objectWriteUInt32 (buf, value, offset, littleEndian) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14926
  if (value < 0) value = 0xffffffff + value + 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14927
  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
14928
    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
14929
  }
14930
}
14931
14932 View Code Duplication
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14933
  value = +value
14934
  offset = offset | 0
14935
  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14936
  if (Buffer.TYPED_ARRAY_SUPPORT) {
14937
    this[offset + 3] = (value >>> 24)
14938
    this[offset + 2] = (value >>> 16)
14939
    this[offset + 1] = (value >>> 8)
14940
    this[offset] = (value & 0xff)
14941
  } else {
14942
    objectWriteUInt32(this, value, offset, true)
14943
  }
14944
  return offset + 4
14945
}
14946
14947 View Code Duplication
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14948
  value = +value
14949
  offset = offset | 0
14950
  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
14951
  if (Buffer.TYPED_ARRAY_SUPPORT) {
14952
    this[offset] = (value >>> 24)
14953
    this[offset + 1] = (value >>> 16)
14954
    this[offset + 2] = (value >>> 8)
14955
    this[offset + 3] = (value & 0xff)
14956
  } else {
14957
    objectWriteUInt32(this, value, offset, false)
14958
  }
14959
  return offset + 4
14960
}
14961
14962
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
14963
  value = +value
14964
  offset = offset | 0
14965
  if (!noAssert) {
14966
    var limit = Math.pow(2, 8 * byteLength - 1)
14967
14968
    checkInt(this, value, offset, byteLength, limit - 1, -limit)
14969
  }
14970
14971
  var i = 0
14972
  var mul = 1
14973
  var sub = 0
14974
  this[offset] = value & 0xFF
14975
  while (++i < byteLength && (mul *= 0x100)) {
14976
    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
14977
      sub = 1
14978
    }
14979
    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
14980
  }
14981
14982
  return offset + byteLength
14983
}
14984
14985 View Code Duplication
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14986
  value = +value
14987
  offset = offset | 0
14988
  if (!noAssert) {
14989
    var limit = Math.pow(2, 8 * byteLength - 1)
14990
14991
    checkInt(this, value, offset, byteLength, limit - 1, -limit)
14992
  }
14993
14994
  var i = byteLength - 1
14995
  var mul = 1
14996
  var sub = 0
14997
  this[offset + i] = value & 0xFF
14998
  while (--i >= 0 && (mul *= 0x100)) {
14999
    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
15000
      sub = 1
15001
    }
15002
    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
15003
  }
15004
15005
  return offset + byteLength
15006
}
15007
15008
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
15009
  value = +value
15010
  offset = offset | 0
15011
  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15012
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15013
  if (value < 0) value = 0xff + value + 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15014
  this[offset] = (value & 0xff)
15015
  return offset + 1
15016
}
15017
15018 View Code Duplication
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15019
  value = +value
15020
  offset = offset | 0
15021
  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15022
  if (Buffer.TYPED_ARRAY_SUPPORT) {
15023
    this[offset] = (value & 0xff)
15024
    this[offset + 1] = (value >>> 8)
15025
  } else {
15026
    objectWriteUInt16(this, value, offset, true)
15027
  }
15028
  return offset + 2
15029
}
15030
15031 View Code Duplication
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15032
  value = +value
15033
  offset = offset | 0
15034
  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15035
  if (Buffer.TYPED_ARRAY_SUPPORT) {
15036
    this[offset] = (value >>> 8)
15037
    this[offset + 1] = (value & 0xff)
15038
  } else {
15039
    objectWriteUInt16(this, value, offset, false)
15040
  }
15041
  return offset + 2
15042
}
15043
15044 View Code Duplication
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15045
  value = +value
15046
  offset = offset | 0
15047
  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15048
  if (Buffer.TYPED_ARRAY_SUPPORT) {
15049
    this[offset] = (value & 0xff)
15050
    this[offset + 1] = (value >>> 8)
15051
    this[offset + 2] = (value >>> 16)
15052
    this[offset + 3] = (value >>> 24)
15053
  } else {
15054
    objectWriteUInt32(this, value, offset, true)
15055
  }
15056
  return offset + 4
15057
}
15058
15059 View Code Duplication
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
15060
  value = +value
15061
  offset = offset | 0
15062
  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15063
  if (value < 0) value = 0xffffffff + value + 1
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15064
  if (Buffer.TYPED_ARRAY_SUPPORT) {
15065
    this[offset] = (value >>> 24)
15066
    this[offset + 1] = (value >>> 16)
15067
    this[offset + 2] = (value >>> 8)
15068
    this[offset + 3] = (value & 0xff)
15069
  } else {
15070
    objectWriteUInt32(this, value, offset, false)
15071
  }
15072
  return offset + 4
15073
}
15074
15075
function checkIEEE754 (buf, value, offset, ext, max, min) {
0 ignored issues
show
Unused Code introduced by
The parameter max is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter min is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
15076
  if (offset + ext > buf.length) throw new RangeError('Index out of range')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15077
  if (offset < 0) throw new RangeError('Index out of range')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15078
}
15079
15080
function writeFloat (buf, value, offset, littleEndian, noAssert) {
15081
  if (!noAssert) {
15082
    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
15083
  }
15084
  ieee754.write(buf, value, offset, littleEndian, 23, 4)
15085
  return offset + 4
15086
}
15087
15088
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
15089
  return writeFloat(this, value, offset, true, noAssert)
15090
}
15091
15092
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
15093
  return writeFloat(this, value, offset, false, noAssert)
15094
}
15095
15096
function writeDouble (buf, value, offset, littleEndian, noAssert) {
15097
  if (!noAssert) {
15098
    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
15099
  }
15100
  ieee754.write(buf, value, offset, littleEndian, 52, 8)
15101
  return offset + 8
15102
}
15103
15104
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
15105
  return writeDouble(this, value, offset, true, noAssert)
15106
}
15107
15108
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
15109
  return writeDouble(this, value, offset, false, noAssert)
15110
}
15111
15112
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
15113
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
15114
  if (!start) start = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15115
  if (!end && end !== 0) end = this.length
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15116
  if (targetStart >= target.length) targetStart = target.length
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15117
  if (!targetStart) targetStart = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15118
  if (end > 0 && end < start) end = start
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15119
15120
  // Copy 0 bytes; we're done
15121
  if (end === start) return 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15122
  if (target.length === 0 || this.length === 0) return 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15123
15124
  // Fatal error conditions
15125
  if (targetStart < 0) {
15126
    throw new RangeError('targetStart out of bounds')
15127
  }
15128
  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15129
  if (end < 0) throw new RangeError('sourceEnd out of bounds')
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15130
15131
  // Are we oob?
15132
  if (end > this.length) end = this.length
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15133
  if (target.length - targetStart < end - start) {
15134
    end = target.length - targetStart + start
15135
  }
15136
15137
  var len = end - start
15138
  var i
15139
15140
  if (this === target && start < targetStart && targetStart < end) {
15141
    // descending copy from end
15142
    for (i = len - 1; i >= 0; --i) {
15143
      target[i + targetStart] = this[i + start]
15144
    }
15145
  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
15146
    // ascending copy from start
15147
    for (i = 0; i < len; ++i) {
15148
      target[i + targetStart] = this[i + start]
15149
    }
15150
  } else {
15151
    Uint8Array.prototype.set.call(
15152
      target,
15153
      this.subarray(start, start + len),
15154
      targetStart
15155
    )
15156
  }
15157
15158
  return len
15159
}
15160
15161
// Usage:
15162
//    buffer.fill(number[, offset[, end]])
15163
//    buffer.fill(buffer[, offset[, end]])
15164
//    buffer.fill(string[, offset[, end]][, encoding])
15165
Buffer.prototype.fill = function fill (val, start, end, encoding) {
15166
  // Handle string cases:
15167
  if (typeof val === 'string') {
15168
    if (typeof start === 'string') {
15169
      encoding = start
15170
      start = 0
15171
      end = this.length
15172
    } else if (typeof end === 'string') {
15173
      encoding = end
15174
      end = this.length
15175
    }
15176
    if (val.length === 1) {
15177
      var code = val.charCodeAt(0)
15178
      if (code < 256) {
15179
        val = code
15180
      }
15181
    }
15182
    if (encoding !== undefined && typeof encoding !== 'string') {
15183
      throw new TypeError('encoding must be a string')
15184
    }
15185
    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
15186
      throw new TypeError('Unknown encoding: ' + encoding)
15187
    }
15188
  } else if (typeof val === 'number') {
15189
    val = val & 255
15190
  }
15191
15192
  // Invalid ranges are not set to a default, so can range check early.
15193
  if (start < 0 || this.length < start || this.length < end) {
15194
    throw new RangeError('Out of range index')
15195
  }
15196
15197
  if (end <= start) {
15198
    return this
15199
  }
15200
15201
  start = start >>> 0
15202
  end = end === undefined ? this.length : end >>> 0
15203
15204
  if (!val) val = 0
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15205
15206
  var i
15207
  if (typeof val === 'number') {
15208
    for (i = start; i < end; ++i) {
15209
      this[i] = val
15210
    }
15211
  } else {
15212
    var bytes = Buffer.isBuffer(val)
15213
      ? val
15214
      : utf8ToBytes(new Buffer(val, encoding).toString())
15215
    var len = bytes.length
15216
    for (i = 0; i < end - start; ++i) {
15217
      this[i + start] = bytes[i % len]
15218
    }
15219
  }
15220
15221
  return this
15222
}
15223
15224
// HELPER FUNCTIONS
15225
// ================
15226
15227
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
15228
15229
function base64clean (str) {
15230
  // Node strips out invalid characters like \n and \t from the string, base64-js does not
15231
  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
15232
  // Node converts strings with length < 2 to ''
15233
  if (str.length < 2) return ''
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15234
  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
15235
  while (str.length % 4 !== 0) {
15236
    str = str + '='
15237
  }
15238
  return str
15239
}
15240
15241
function stringtrim (str) {
15242
  if (str.trim) return str.trim()
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15243
  return str.replace(/^\s+|\s+$/g, '')
15244
}
15245
15246
function toHex (n) {
15247
  if (n < 16) return '0' + n.toString(16)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15248
  return n.toString(16)
15249
}
15250
15251
function utf8ToBytes (string, units) {
15252
  units = units || Infinity
15253
  var codePoint
15254
  var length = string.length
15255
  var leadSurrogate = null
15256
  var bytes = []
15257
15258
  for (var i = 0; i < length; ++i) {
15259
    codePoint = string.charCodeAt(i)
15260
15261
    // is surrogate component
15262
    if (codePoint > 0xD7FF && codePoint < 0xE000) {
15263
      // last char was a lead
15264
      if (!leadSurrogate) {
15265
        // no lead yet
15266
        if (codePoint > 0xDBFF) {
15267
          // unexpected trail
15268
          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15269
          continue
15270
        } else if (i + 1 === length) {
15271
          // unpaired lead
15272
          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15273
          continue
15274
        }
15275
15276
        // valid lead
15277
        leadSurrogate = codePoint
15278
15279
        continue
15280
      }
15281
15282
      // 2 leads in a row
15283
      if (codePoint < 0xDC00) {
15284
        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15285
        leadSurrogate = codePoint
15286
        continue
15287
      }
15288
15289
      // valid surrogate pair
15290
      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
15291
    } else if (leadSurrogate) {
15292
      // valid bmp char, but last char was a lead
15293
      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15294
    }
15295
15296
    leadSurrogate = null
15297
15298
    // encode utf8
15299
    if (codePoint < 0x80) {
15300
      if ((units -= 1) < 0) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15301
      bytes.push(codePoint)
15302
    } else if (codePoint < 0x800) {
15303
      if ((units -= 2) < 0) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15304
      bytes.push(
15305
        codePoint >> 0x6 | 0xC0,
15306
        codePoint & 0x3F | 0x80
15307
      )
15308
    } else if (codePoint < 0x10000) {
15309
      if ((units -= 3) < 0) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15310
      bytes.push(
15311
        codePoint >> 0xC | 0xE0,
15312
        codePoint >> 0x6 & 0x3F | 0x80,
15313
        codePoint & 0x3F | 0x80
15314
      )
15315
    } else if (codePoint < 0x110000) {
15316
      if ((units -= 4) < 0) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15317
      bytes.push(
15318
        codePoint >> 0x12 | 0xF0,
15319
        codePoint >> 0xC & 0x3F | 0x80,
15320
        codePoint >> 0x6 & 0x3F | 0x80,
15321
        codePoint & 0x3F | 0x80
15322
      )
15323
    } else {
15324
      throw new Error('Invalid code point')
15325
    }
15326
  }
15327
15328
  return bytes
15329
}
15330
15331
function asciiToBytes (str) {
15332
  var byteArray = []
15333
  for (var i = 0; i < str.length; ++i) {
15334
    // Node's code seems to be doing this and not & 0x7F..
15335
    byteArray.push(str.charCodeAt(i) & 0xFF)
15336
  }
15337
  return byteArray
15338
}
15339
15340
function utf16leToBytes (str, units) {
15341
  var c, hi, lo
15342
  var byteArray = []
15343
  for (var i = 0; i < str.length; ++i) {
15344
    if ((units -= 2) < 0) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15345
15346
    c = str.charCodeAt(i)
15347
    hi = c >> 8
15348
    lo = c % 256
15349
    byteArray.push(lo)
15350
    byteArray.push(hi)
15351
  }
15352
15353
  return byteArray
15354
}
15355
15356
function base64ToBytes (str) {
15357
  return base64.toByteArray(base64clean(str))
15358
}
15359
15360
function blitBuffer (src, dst, offset, length) {
15361
  for (var i = 0; i < length; ++i) {
15362
    if ((i + offset >= dst.length) || (i >= src.length)) break
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
15363
    dst[i + offset] = src[i]
15364
  }
15365
  return i
15366
}
15367
15368
function isnan (val) {
15369
  return val !== val // eslint-disable-line no-self-compare
15370
}
15371
15372
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
0 ignored issues
show
Bug introduced by
The variable self seems to be never declared. If this is a global, consider adding a /** global: self */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
15373
},{"base64-js":37,"ieee754":48,"isarray":51}]},{},[1]);
15374