mocha 3.2.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mocha.js CHANGED
@@ -189,7 +189,7 @@ global.mocha = mocha;
189
189
  module.exports = global;
190
190
 
191
191
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
192
- },{"./lib/mocha":14,"_process":67,"browser-stdout":41}],2:[function(require,module,exports){
192
+ },{"./lib/mocha":14,"_process":81,"browser-stdout":41}],2:[function(require,module,exports){
193
193
  'use strict';
194
194
 
195
195
  function noop () {}
@@ -647,7 +647,7 @@ Context.prototype.inspect = function () {
647
647
  }, 2);
648
648
  };
649
649
 
650
- },{"json3":54}],7:[function(require,module,exports){
650
+ },{"json3":68}],7:[function(require,module,exports){
651
651
  'use strict';
652
652
 
653
653
  /**
@@ -1412,9 +1412,17 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {
1412
1412
  try {
1413
1413
  _reporter = require(reporter);
1414
1414
  } catch (err) {
1415
- err.message.indexOf('Cannot find module') !== -1
1416
- ? console.warn('"' + reporter + '" reporter not found')
1417
- : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
1415
+ if (err.message.indexOf('Cannot find module') !== -1) {
1416
+ // Try to load reporters from a path (absolute or relative)
1417
+ try {
1418
+ _reporter = require(path.resolve(process.cwd(), reporter));
1419
+ } catch (_err) {
1420
+ err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')
1421
+ : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
1422
+ }
1423
+ } else {
1424
+ console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
1425
+ }
1418
1426
  }
1419
1427
  }
1420
1428
  if (!_reporter && reporter === 'teamcity') {
@@ -1735,6 +1743,24 @@ Mocha.prototype.delay = function delay () {
1735
1743
  return this;
1736
1744
  };
1737
1745
 
1746
+ /**
1747
+ * Tests marked only fail the suite
1748
+ * @returns {Mocha}
1749
+ */
1750
+ Mocha.prototype.forbidOnly = function () {
1751
+ this.options.forbidOnly = true;
1752
+ return this;
1753
+ };
1754
+
1755
+ /**
1756
+ * Pending tests and tests marked skip fail the suite
1757
+ * @returns {Mocha}
1758
+ */
1759
+ Mocha.prototype.forbidPending = function () {
1760
+ this.options.forbidPending = true;
1761
+ return this;
1762
+ };
1763
+
1738
1764
  /**
1739
1765
  * Run tests and invoke `fn()` when complete.
1740
1766
  *
@@ -1756,6 +1782,8 @@ Mocha.prototype.run = function (fn) {
1756
1782
  runner.hasOnly = options.hasOnly;
1757
1783
  runner.asyncOnly = options.asyncOnly;
1758
1784
  runner.allowUncaught = options.allowUncaught;
1785
+ runner.forbidOnly = options.forbidOnly;
1786
+ runner.forbidPending = options.forbidPending;
1759
1787
  if (options.grep) {
1760
1788
  runner.grep(options.grep, options.invert);
1761
1789
  }
@@ -1782,7 +1810,7 @@ Mocha.prototype.run = function (fn) {
1782
1810
  };
1783
1811
 
1784
1812
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib")
1785
- },{"./context":6,"./hook":7,"./interfaces":11,"./reporters":21,"./runnable":33,"./runner":34,"./suite":35,"./test":36,"./utils":38,"_process":67,"escape-string-regexp":47,"growl":49,"path":42}],15:[function(require,module,exports){
1813
+ },{"./context":6,"./hook":7,"./interfaces":11,"./reporters":21,"./runnable":33,"./runner":34,"./suite":35,"./test":36,"./utils":38,"_process":81,"escape-string-regexp":61,"growl":63,"path":42}],15:[function(require,module,exports){
1786
1814
  'use strict';
1787
1815
 
1788
1816
  /**
@@ -2427,7 +2455,7 @@ function sameType (a, b) {
2427
2455
  }
2428
2456
 
2429
2457
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2430
- },{"../ms":15,"../utils":38,"_process":67,"diff":46,"supports-color":42,"tty":5}],18:[function(require,module,exports){
2458
+ },{"../ms":15,"../utils":38,"_process":81,"diff":55,"supports-color":42,"tty":5}],18:[function(require,module,exports){
2431
2459
  'use strict';
2432
2460
 
2433
2461
  /**
@@ -2565,7 +2593,7 @@ function Dot (runner) {
2565
2593
  inherits(Dot, Base);
2566
2594
 
2567
2595
  }).call(this,require('_process'))
2568
- },{"../utils":38,"./base":17,"_process":67}],20:[function(require,module,exports){
2596
+ },{"../utils":38,"./base":17,"_process":81}],20:[function(require,module,exports){
2569
2597
  (function (global){
2570
2598
  'use strict';
2571
2599
 
@@ -2610,6 +2638,8 @@ var statsTemplate = '<ul id="mocha-stats">' +
2610
2638
  '<li class="duration">duration: <em>0</em>s</li>' +
2611
2639
  '</ul>';
2612
2640
 
2641
+ var playIcon = '&#x2023;';
2642
+
2613
2643
  /**
2614
2644
  * Initialize a new `HTML` reporter.
2615
2645
  *
@@ -2705,7 +2735,7 @@ function HTML (runner) {
2705
2735
  runner.on('pass', function (test) {
2706
2736
  var url = self.testURL(test);
2707
2737
  var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
2708
- '<a href="%s" class="replay">‣</a></h2></li>';
2738
+ '<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
2709
2739
  var el = fragment(markup, test.speed, test.title, test.duration, url);
2710
2740
  self.addCodeToggle(el, test.body);
2711
2741
  appendToStack(el);
@@ -2713,7 +2743,7 @@ function HTML (runner) {
2713
2743
  });
2714
2744
 
2715
2745
  runner.on('fail', function (test) {
2716
- var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>',
2746
+ var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
2717
2747
  test.title, self.testURL(test));
2718
2748
  var stackString; // Note: Includes leading newline
2719
2749
  var message = test.err.toString();
@@ -2915,7 +2945,7 @@ function on (el, event, fn) {
2915
2945
  }
2916
2946
 
2917
2947
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
2918
- },{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":47}],21:[function(require,module,exports){
2948
+ },{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":61}],21:[function(require,module,exports){
2919
2949
  'use strict';
2920
2950
 
2921
2951
  // Alias exports to a their normalized format Mocha#reporter to prevent a need
@@ -3003,7 +3033,7 @@ function clean (test) {
3003
3033
  }
3004
3034
 
3005
3035
  }).call(this,require('_process'))
3006
- },{"./base":17,"_process":67,"json3":54}],23:[function(require,module,exports){
3036
+ },{"./base":17,"_process":81,"json3":68}],23:[function(require,module,exports){
3007
3037
  (function (process){
3008
3038
  'use strict';
3009
3039
 
@@ -3099,7 +3129,7 @@ function errorJSON (err) {
3099
3129
  }
3100
3130
 
3101
3131
  }).call(this,require('_process'))
3102
- },{"./base":17,"_process":67}],24:[function(require,module,exports){
3132
+ },{"./base":17,"_process":81}],24:[function(require,module,exports){
3103
3133
  (function (process){
3104
3134
  'use strict';
3105
3135
 
@@ -3197,7 +3227,7 @@ function Landing (runner) {
3197
3227
  inherits(Landing, Base);
3198
3228
 
3199
3229
  }).call(this,require('_process'))
3200
- },{"../utils":38,"./base":17,"_process":67}],25:[function(require,module,exports){
3230
+ },{"../utils":38,"./base":17,"_process":81}],25:[function(require,module,exports){
3201
3231
  (function (process){
3202
3232
  'use strict';
3203
3233
 
@@ -3264,7 +3294,7 @@ function List (runner) {
3264
3294
  inherits(List, Base);
3265
3295
 
3266
3296
  }).call(this,require('_process'))
3267
- },{"../utils":38,"./base":17,"_process":67}],26:[function(require,module,exports){
3297
+ },{"../utils":38,"./base":17,"_process":81}],26:[function(require,module,exports){
3268
3298
  (function (process){
3269
3299
  'use strict';
3270
3300
 
@@ -3367,7 +3397,7 @@ function Markdown (runner) {
3367
3397
  }
3368
3398
 
3369
3399
  }).call(this,require('_process'))
3370
- },{"../utils":38,"./base":17,"_process":67}],27:[function(require,module,exports){
3400
+ },{"../utils":38,"./base":17,"_process":81}],27:[function(require,module,exports){
3371
3401
  (function (process){
3372
3402
  'use strict';
3373
3403
 
@@ -3409,7 +3439,7 @@ function Min (runner) {
3409
3439
  inherits(Min, Base);
3410
3440
 
3411
3441
  }).call(this,require('_process'))
3412
- },{"../utils":38,"./base":17,"_process":67}],28:[function(require,module,exports){
3442
+ },{"../utils":38,"./base":17,"_process":81}],28:[function(require,module,exports){
3413
3443
  (function (process){
3414
3444
  'use strict';
3415
3445
 
@@ -3676,7 +3706,7 @@ function write (string) {
3676
3706
  }
3677
3707
 
3678
3708
  }).call(this,require('_process'))
3679
- },{"../utils":38,"./base":17,"_process":67}],29:[function(require,module,exports){
3709
+ },{"../utils":38,"./base":17,"_process":81}],29:[function(require,module,exports){
3680
3710
  (function (process){
3681
3711
  'use strict';
3682
3712
 
@@ -3771,7 +3801,7 @@ function Progress (runner, options) {
3771
3801
  inherits(Progress, Base);
3772
3802
 
3773
3803
  }).call(this,require('_process'))
3774
- },{"../utils":38,"./base":17,"_process":67}],30:[function(require,module,exports){
3804
+ },{"../utils":38,"./base":17,"_process":81}],30:[function(require,module,exports){
3775
3805
  'use strict';
3776
3806
 
3777
3807
  /**
@@ -4098,7 +4128,7 @@ function tag (name, attrs, close, content) {
4098
4128
  }
4099
4129
 
4100
4130
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4101
- },{"../utils":38,"./base":17,"_process":67,"fs":42,"mkdirp":64,"path":42}],33:[function(require,module,exports){
4131
+ },{"../utils":38,"./base":17,"_process":81,"fs":42,"mkdirp":78,"path":42}],33:[function(require,module,exports){
4102
4132
  (function (global){
4103
4133
  'use strict';
4104
4134
 
@@ -4426,8 +4456,11 @@ Runnable.prototype.run = function (fn) {
4426
4456
  }
4427
4457
 
4428
4458
  if (this.allowUncaught) {
4429
- callFn(this.fn);
4430
- done();
4459
+ if (this.isPending()) {
4460
+ done();
4461
+ } else {
4462
+ callFn(this.fn);
4463
+ }
4431
4464
  return;
4432
4465
  }
4433
4466
 
@@ -4488,7 +4521,7 @@ Runnable.prototype.run = function (fn) {
4488
4521
  };
4489
4522
 
4490
4523
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4491
- },{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":54,"lodash.create":60}],34:[function(require,module,exports){
4524
+ },{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":68,"lodash.create":69}],34:[function(require,module,exports){
4492
4525
  (function (process,global){
4493
4526
  'use strict';
4494
4527
 
@@ -4924,15 +4957,14 @@ Runner.prototype.runTest = function (fn) {
4924
4957
  if (this.asyncOnly) {
4925
4958
  test.asyncOnly = true;
4926
4959
  }
4927
-
4960
+ test.on('error', function (err) {
4961
+ self.fail(test, err);
4962
+ });
4928
4963
  if (this.allowUncaught) {
4929
4964
  test.allowUncaught = true;
4930
4965
  return test.run(fn);
4931
4966
  }
4932
4967
  try {
4933
- test.on('error', function (err) {
4934
- self.fail(test, err);
4935
- });
4936
4968
  test.run(fn);
4937
4969
  } catch (err) {
4938
4970
  fn(err);
@@ -5173,9 +5205,9 @@ Runner.prototype.runSuite = function (suite, fn) {
5173
5205
  */
5174
5206
  Runner.prototype.uncaught = function (err) {
5175
5207
  if (err) {
5176
- debug('uncaught exception %s', err !== function () {
5208
+ debug('uncaught exception %s', err === (function () {
5177
5209
  return this;
5178
- }.call(err) ? err : (err.message || err));
5210
+ }.call(err)) ? (err.message || err) : err);
5179
5211
  } else {
5180
5212
  debug('uncaught undefined exception');
5181
5213
  err = undefinedError();
@@ -5313,6 +5345,12 @@ Runner.prototype.run = function (fn) {
5313
5345
 
5314
5346
  // callback
5315
5347
  this.on('end', function () {
5348
+ if (self.forbidOnly && self.hasOnly) {
5349
+ self.failures += self.stats.tests;
5350
+ }
5351
+ if (self.forbidPending) {
5352
+ self.failures += self.stats.pending;
5353
+ }
5316
5354
  debug('end');
5317
5355
  process.removeListener('uncaughtException', uncaught);
5318
5356
  fn(self.failures);
@@ -5455,7 +5493,7 @@ function extraGlobals () {
5455
5493
  }
5456
5494
 
5457
5495
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5458
- },{"./pending":16,"./runnable":33,"./utils":38,"_process":67,"debug":2,"events":3}],35:[function(require,module,exports){
5496
+ },{"./pending":16,"./runnable":33,"./utils":38,"_process":81,"debug":2,"events":3}],35:[function(require,module,exports){
5459
5497
  'use strict';
5460
5498
 
5461
5499
  /**
@@ -5913,7 +5951,7 @@ Test.prototype.clone = function () {
5913
5951
  return test;
5914
5952
  };
5915
5953
 
5916
- },{"./runnable":33,"./utils":38,"lodash.create":60}],37:[function(require,module,exports){
5954
+ },{"./runnable":33,"./utils":38,"lodash.create":69}],37:[function(require,module,exports){
5917
5955
  'use strict';
5918
5956
 
5919
5957
  /**
@@ -6278,7 +6316,9 @@ exports.parseQuery = function (qs) {
6278
6316
  var key = pair.slice(0, i);
6279
6317
  var val = pair.slice(++i);
6280
6318
 
6281
- obj[key] = decodeURIComponent(val);
6319
+ // Due to how the URLSearchParams API treats spaces
6320
+ obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
6321
+
6282
6322
  return obj;
6283
6323
  }, {});
6284
6324
  };
@@ -6372,7 +6412,7 @@ var type = exports.type = function type (value) {
6372
6412
  return 'buffer';
6373
6413
  }
6374
6414
  return Object.prototype.toString.call(value)
6375
- .replace(/^\[.+\s(.+?)\]$/, '$1')
6415
+ .replace(/^\[.+\s(.+?)]$/, '$1')
6376
6416
  .toLowerCase();
6377
6417
  };
6378
6418
 
@@ -6697,7 +6737,9 @@ exports.stackTraceFilter = function () {
6697
6737
  if (is.node) {
6698
6738
  cwd = process.cwd() + slash;
6699
6739
  } else {
6700
- cwd = (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
6740
+ cwd = (typeof location === 'undefined'
6741
+ ? window.location
6742
+ : location).href.replace(/\/[^/]*$/, '/');
6701
6743
  slash = '/';
6702
6744
  }
6703
6745
 
@@ -6759,7 +6801,7 @@ exports.isPromise = function isPromise (value) {
6759
6801
  exports.noop = function () {};
6760
6802
 
6761
6803
  }).call(this,require('_process'),require("buffer").Buffer)
6762
- },{"./to-iso-string":37,"_process":67,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":54,"path":42,"util":84}],39:[function(require,module,exports){
6804
+ },{"./to-iso-string":37,"_process":81,"buffer":43,"debug":2,"fs":42,"glob":42,"json3":68,"path":42,"util":101}],39:[function(require,module,exports){
6763
6805
  'use strict'
6764
6806
 
6765
6807
  exports.byteLength = byteLength
@@ -6795,22 +6837,22 @@ function placeHoldersCount (b64) {
6795
6837
 
6796
6838
  function byteLength (b64) {
6797
6839
  // base64 is 4/3 + up to two characters of the original data
6798
- return b64.length * 3 / 4 - placeHoldersCount(b64)
6840
+ return (b64.length * 3 / 4) - placeHoldersCount(b64)
6799
6841
  }
6800
6842
 
6801
6843
  function toByteArray (b64) {
6802
- var i, j, l, tmp, placeHolders, arr
6844
+ var i, l, tmp, placeHolders, arr
6803
6845
  var len = b64.length
6804
6846
  placeHolders = placeHoldersCount(b64)
6805
6847
 
6806
- arr = new Arr(len * 3 / 4 - placeHolders)
6848
+ arr = new Arr((len * 3 / 4) - placeHolders)
6807
6849
 
6808
6850
  // if there are placeholders, only get up to the last complete 4 chars
6809
6851
  l = placeHolders > 0 ? len - 4 : len
6810
6852
 
6811
6853
  var L = 0
6812
6854
 
6813
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
6855
+ for (i = 0; i < l; i += 4) {
6814
6856
  tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
6815
6857
  arr[L++] = (tmp >> 16) & 0xFF
6816
6858
  arr[L++] = (tmp >> 8) & 0xFF
@@ -6906,122 +6948,10 @@ BrowserStdout.prototype._write = function(chunks, encoding, cb) {
6906
6948
  }
6907
6949
 
6908
6950
  }).call(this,require('_process'))
6909
- },{"_process":67,"stream":79,"util":84}],42:[function(require,module,exports){
6951
+ },{"_process":81,"stream":95,"util":101}],42:[function(require,module,exports){
6910
6952
  arguments[4][40][0].apply(exports,arguments)
6911
6953
  },{"dup":40}],43:[function(require,module,exports){
6912
6954
  (function (global){
6913
- 'use strict';
6914
-
6915
- var buffer = require('buffer');
6916
- var Buffer = buffer.Buffer;
6917
- var SlowBuffer = buffer.SlowBuffer;
6918
- var MAX_LEN = buffer.kMaxLength || 2147483647;
6919
- exports.alloc = function alloc(size, fill, encoding) {
6920
- if (typeof Buffer.alloc === 'function') {
6921
- return Buffer.alloc(size, fill, encoding);
6922
- }
6923
- if (typeof encoding === 'number') {
6924
- throw new TypeError('encoding must not be number');
6925
- }
6926
- if (typeof size !== 'number') {
6927
- throw new TypeError('size must be a number');
6928
- }
6929
- if (size > MAX_LEN) {
6930
- throw new RangeError('size is too large');
6931
- }
6932
- var enc = encoding;
6933
- var _fill = fill;
6934
- if (_fill === undefined) {
6935
- enc = undefined;
6936
- _fill = 0;
6937
- }
6938
- var buf = new Buffer(size);
6939
- if (typeof _fill === 'string') {
6940
- var fillBuf = new Buffer(_fill, enc);
6941
- var flen = fillBuf.length;
6942
- var i = -1;
6943
- while (++i < size) {
6944
- buf[i] = fillBuf[i % flen];
6945
- }
6946
- } else {
6947
- buf.fill(_fill);
6948
- }
6949
- return buf;
6950
- }
6951
- exports.allocUnsafe = function allocUnsafe(size) {
6952
- if (typeof Buffer.allocUnsafe === 'function') {
6953
- return Buffer.allocUnsafe(size);
6954
- }
6955
- if (typeof size !== 'number') {
6956
- throw new TypeError('size must be a number');
6957
- }
6958
- if (size > MAX_LEN) {
6959
- throw new RangeError('size is too large');
6960
- }
6961
- return new Buffer(size);
6962
- }
6963
- exports.from = function from(value, encodingOrOffset, length) {
6964
- if (typeof Buffer.from === 'function' && (!global.Uint8Array || Uint8Array.from !== Buffer.from)) {
6965
- return Buffer.from(value, encodingOrOffset, length);
6966
- }
6967
- if (typeof value === 'number') {
6968
- throw new TypeError('"value" argument must not be a number');
6969
- }
6970
- if (typeof value === 'string') {
6971
- return new Buffer(value, encodingOrOffset);
6972
- }
6973
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
6974
- var offset = encodingOrOffset;
6975
- if (arguments.length === 1) {
6976
- return new Buffer(value);
6977
- }
6978
- if (typeof offset === 'undefined') {
6979
- offset = 0;
6980
- }
6981
- var len = length;
6982
- if (typeof len === 'undefined') {
6983
- len = value.byteLength - offset;
6984
- }
6985
- if (offset >= value.byteLength) {
6986
- throw new RangeError('\'offset\' is out of bounds');
6987
- }
6988
- if (len > value.byteLength - offset) {
6989
- throw new RangeError('\'length\' is out of bounds');
6990
- }
6991
- return new Buffer(value.slice(offset, offset + len));
6992
- }
6993
- if (Buffer.isBuffer(value)) {
6994
- var out = new Buffer(value.length);
6995
- value.copy(out, 0, 0, value.length);
6996
- return out;
6997
- }
6998
- if (value) {
6999
- if (Array.isArray(value) || (typeof ArrayBuffer !== 'undefined' && value.buffer instanceof ArrayBuffer) || 'length' in value) {
7000
- return new Buffer(value);
7001
- }
7002
- if (value.type === 'Buffer' && Array.isArray(value.data)) {
7003
- return new Buffer(value.data);
7004
- }
7005
- }
7006
-
7007
- throw new TypeError('First argument must be a string, Buffer, ' + 'ArrayBuffer, Array, or array-like object.');
7008
- }
7009
- exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
7010
- if (typeof Buffer.allocUnsafeSlow === 'function') {
7011
- return Buffer.allocUnsafeSlow(size);
7012
- }
7013
- if (typeof size !== 'number') {
7014
- throw new TypeError('size must be a number');
7015
- }
7016
- if (size >= MAX_LEN) {
7017
- throw new RangeError('size is too large');
7018
- }
7019
- return new SlowBuffer(size);
7020
- }
7021
-
7022
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7023
- },{"buffer":44}],44:[function(require,module,exports){
7024
- (function (global){
7025
6955
  /*!
7026
6956
  * The buffer module from node.js, for the browser.
7027
6957
  *
@@ -8813,7 +8743,7 @@ function isnan (val) {
8813
8743
  }
8814
8744
 
8815
8745
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
8816
- },{"base64-js":39,"ieee754":50,"isarray":53}],45:[function(require,module,exports){
8746
+ },{"base64-js":39,"ieee754":64,"isarray":67}],44:[function(require,module,exports){
8817
8747
  (function (Buffer){
8818
8748
  // Copyright Joyent, Inc. and other Node contributors.
8819
8749
  //
@@ -8924,628 +8854,1258 @@ function objectToString(o) {
8924
8854
  }
8925
8855
 
8926
8856
  }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
8927
- },{"../../is-buffer/index.js":52}],46:[function(require,module,exports){
8928
- /* See LICENSE file for terms of use */
8857
+ },{"../../is-buffer/index.js":66}],45:[function(require,module,exports){
8858
+ /*istanbul ignore start*/"use strict";
8859
+
8860
+ exports.__esModule = true;
8861
+ exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
8862
+ // See: http://code.google.com/p/google-diff-match-patch/wiki/API
8863
+ function convertChangesToDMP(changes) {
8864
+ var ret = [],
8865
+ change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
8866
+ operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
8867
+ for (var i = 0; i < changes.length; i++) {
8868
+ change = changes[i];
8869
+ if (change.added) {
8870
+ operation = 1;
8871
+ } else if (change.removed) {
8872
+ operation = -1;
8873
+ } else {
8874
+ operation = 0;
8875
+ }
8929
8876
 
8930
- /*
8931
- * Text diff implementation.
8932
- *
8933
- * This library supports the following APIS:
8934
- * JsDiff.diffChars: Character by character diff
8935
- * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
8936
- * JsDiff.diffLines: Line based diff
8937
- *
8938
- * JsDiff.diffCss: Diff targeted at CSS content
8939
- *
8940
- * These methods are based on the implementation proposed in
8941
- * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
8942
- * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
8943
- */
8944
- (function(global, undefined) {
8945
- var objectPrototypeToString = Object.prototype.toString;
8877
+ ret.push([operation, change.value]);
8878
+ }
8879
+ return ret;
8880
+ }
8946
8881
 
8947
- /*istanbul ignore next*/
8948
- function map(arr, mapper, that) {
8949
- if (Array.prototype.map) {
8950
- return Array.prototype.map.call(arr, mapper, that);
8951
- }
8952
8882
 
8953
- var other = new Array(arr.length);
8883
+ },{}],46:[function(require,module,exports){
8884
+ /*istanbul ignore start*/'use strict';
8954
8885
 
8955
- for (var i = 0, n = arr.length; i < n; i++) {
8956
- other[i] = mapper.call(that, arr[i], i, arr);
8886
+ exports.__esModule = true;
8887
+ exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
8888
+ function convertChangesToXML(changes) {
8889
+ var ret = [];
8890
+ for (var i = 0; i < changes.length; i++) {
8891
+ var change = changes[i];
8892
+ if (change.added) {
8893
+ ret.push('<ins>');
8894
+ } else if (change.removed) {
8895
+ ret.push('<del>');
8957
8896
  }
8958
- return other;
8959
- }
8960
- function clonePath(path) {
8961
- return { newPos: path.newPos, components: path.components.slice(0) };
8962
- }
8963
- function removeEmpty(array) {
8964
- var ret = [];
8965
- for (var i = 0; i < array.length; i++) {
8966
- if (array[i]) {
8967
- ret.push(array[i]);
8968
- }
8897
+
8898
+ ret.push(escapeHTML(change.value));
8899
+
8900
+ if (change.added) {
8901
+ ret.push('</ins>');
8902
+ } else if (change.removed) {
8903
+ ret.push('</del>');
8969
8904
  }
8970
- return ret;
8971
8905
  }
8972
- function escapeHTML(s) {
8973
- var n = s;
8974
- n = n.replace(/&/g, '&amp;');
8975
- n = n.replace(/</g, '&lt;');
8976
- n = n.replace(/>/g, '&gt;');
8977
- n = n.replace(/"/g, '&quot;');
8906
+ return ret.join('');
8907
+ }
8978
8908
 
8979
- return n;
8980
- }
8909
+ function escapeHTML(s) {
8910
+ var n = s;
8911
+ n = n.replace(/&/g, '&amp;');
8912
+ n = n.replace(/</g, '&lt;');
8913
+ n = n.replace(/>/g, '&gt;');
8914
+ n = n.replace(/"/g, '&quot;');
8981
8915
 
8982
- // This function handles the presence of circular references by bailing out when encountering an
8983
- // object that is already on the "stack" of items being processed.
8984
- function canonicalize(obj, stack, replacementStack) {
8985
- stack = stack || [];
8986
- replacementStack = replacementStack || [];
8916
+ return n;
8917
+ }
8987
8918
 
8988
- var i;
8989
8919
 
8990
- for (i = 0; i < stack.length; i += 1) {
8991
- if (stack[i] === obj) {
8992
- return replacementStack[i];
8993
- }
8994
- }
8920
+ },{}],47:[function(require,module,exports){
8921
+ /*istanbul ignore start*/'use strict';
8995
8922
 
8996
- var canonicalizedObj;
8923
+ exports.__esModule = true;
8924
+ exports.arrayDiff = undefined;
8925
+ exports. /*istanbul ignore end*/diffArrays = diffArrays;
8997
8926
 
8998
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
8999
- stack.push(obj);
9000
- canonicalizedObj = new Array(obj.length);
9001
- replacementStack.push(canonicalizedObj);
9002
- for (i = 0; i < obj.length; i += 1) {
9003
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
9004
- }
9005
- stack.pop();
9006
- replacementStack.pop();
9007
- } else if (typeof obj === 'object' && obj !== null) {
9008
- stack.push(obj);
9009
- canonicalizedObj = {};
9010
- replacementStack.push(canonicalizedObj);
9011
- var sortedKeys = [],
9012
- key;
9013
- for (key in obj) {
9014
- sortedKeys.push(key);
9015
- }
9016
- sortedKeys.sort();
9017
- for (i = 0; i < sortedKeys.length; i += 1) {
9018
- key = sortedKeys[i];
9019
- canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
9020
- }
9021
- stack.pop();
9022
- replacementStack.pop();
9023
- } else {
9024
- canonicalizedObj = obj;
9025
- }
9026
- return canonicalizedObj;
9027
- }
8927
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9028
8928
 
9029
- function buildValues(components, newString, oldString, useLongestToken) {
9030
- var componentPos = 0,
9031
- componentLen = components.length,
9032
- newPos = 0,
9033
- oldPos = 0;
8929
+ /*istanbul ignore start*/
8930
+ var _base2 = _interopRequireDefault(_base);
9034
8931
 
9035
- for (; componentPos < componentLen; componentPos++) {
9036
- var component = components[componentPos];
9037
- if (!component.removed) {
9038
- if (!component.added && useLongestToken) {
9039
- var value = newString.slice(newPos, newPos + component.count);
9040
- value = map(value, function(value, i) {
9041
- var oldValue = oldString[oldPos + i];
9042
- return oldValue.length > value.length ? oldValue : value;
9043
- });
8932
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9044
8933
 
9045
- component.value = value.join('');
9046
- } else {
9047
- component.value = newString.slice(newPos, newPos + component.count).join('');
9048
- }
9049
- newPos += component.count;
8934
+ /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
8935
+ arrayDiff.tokenize = arrayDiff.join = function (value) {
8936
+ return value.slice();
8937
+ };
9050
8938
 
9051
- // Common case
9052
- if (!component.added) {
9053
- oldPos += component.count;
9054
- }
9055
- } else {
9056
- component.value = oldString.slice(oldPos, oldPos + component.count).join('');
9057
- oldPos += component.count;
8939
+ function diffArrays(oldArr, newArr, callback) {
8940
+ return arrayDiff.diff(oldArr, newArr, callback);
8941
+ }
9058
8942
 
9059
- // Reverse add and remove so removes are output first to match common convention
9060
- // The diffing algorithm is tied to add then remove output and this is the simplest
9061
- // route to get the desired output with minimal overhead.
9062
- if (componentPos && components[componentPos - 1].added) {
9063
- var tmp = components[componentPos - 1];
9064
- components[componentPos - 1] = components[componentPos];
9065
- components[componentPos] = tmp;
9066
- }
9067
- }
8943
+
8944
+ },{"./base":48}],48:[function(require,module,exports){
8945
+ /*istanbul ignore start*/'use strict';
8946
+
8947
+ exports.__esModule = true;
8948
+ exports['default'] = /*istanbul ignore end*/Diff;
8949
+ function Diff() {}
8950
+
8951
+ Diff.prototype = { /*istanbul ignore start*/
8952
+ /*istanbul ignore end*/diff: function diff(oldString, newString) {
8953
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
8954
+
8955
+ var callback = options.callback;
8956
+ if (typeof options === 'function') {
8957
+ callback = options;
8958
+ options = {};
9068
8959
  }
8960
+ this.options = options;
9069
8961
 
9070
- return components;
9071
- }
8962
+ var self = this;
9072
8963
 
9073
- function Diff(ignoreWhitespace) {
9074
- this.ignoreWhitespace = ignoreWhitespace;
9075
- }
9076
- Diff.prototype = {
9077
- diff: function(oldString, newString, callback) {
9078
- var self = this;
8964
+ function done(value) {
8965
+ if (callback) {
8966
+ setTimeout(function () {
8967
+ callback(undefined, value);
8968
+ }, 0);
8969
+ return true;
8970
+ } else {
8971
+ return value;
8972
+ }
8973
+ }
9079
8974
 
9080
- function done(value) {
9081
- if (callback) {
9082
- setTimeout(function() { callback(undefined, value); }, 0);
9083
- return true;
9084
- } else {
9085
- return value;
8975
+ // Allow subclasses to massage the input prior to running
8976
+ oldString = this.castInput(oldString);
8977
+ newString = this.castInput(newString);
8978
+
8979
+ oldString = this.removeEmpty(this.tokenize(oldString));
8980
+ newString = this.removeEmpty(this.tokenize(newString));
8981
+
8982
+ var newLen = newString.length,
8983
+ oldLen = oldString.length;
8984
+ var editLength = 1;
8985
+ var maxEditLength = newLen + oldLen;
8986
+ var bestPath = [{ newPos: -1, components: [] }];
8987
+
8988
+ // Seed editLength = 0, i.e. the content starts with the same values
8989
+ var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
8990
+ if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
8991
+ // Identity per the equality and tokenizer
8992
+ return done([{ value: this.join(newString), count: newString.length }]);
8993
+ }
8994
+
8995
+ // Main worker method. checks all permutations of a given edit length for acceptance.
8996
+ function execEditLength() {
8997
+ for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
8998
+ var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
8999
+ var addPath = bestPath[diagonalPath - 1],
9000
+ removePath = bestPath[diagonalPath + 1],
9001
+ _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
9002
+ if (addPath) {
9003
+ // No one else is going to attempt to use this value, clear it
9004
+ bestPath[diagonalPath - 1] = undefined;
9086
9005
  }
9087
- }
9088
9006
 
9089
- // Handle the identity case (this is due to unrolling editLength == 0
9090
- if (newString === oldString) {
9091
- return done([{ value: newString }]);
9092
- }
9093
- if (!newString) {
9094
- return done([{ value: oldString, removed: true }]);
9095
- }
9096
- if (!oldString) {
9097
- return done([{ value: newString, added: true }]);
9098
- }
9007
+ var canAdd = addPath && addPath.newPos + 1 < newLen,
9008
+ canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
9009
+ if (!canAdd && !canRemove) {
9010
+ // If this path is a terminal then prune
9011
+ bestPath[diagonalPath] = undefined;
9012
+ continue;
9013
+ }
9099
9014
 
9100
- newString = this.tokenize(newString);
9101
- oldString = this.tokenize(oldString);
9015
+ // Select the diagonal that we want to branch from. We select the prior
9016
+ // path whose position in the new string is the farthest from the origin
9017
+ // and does not pass the bounds of the diff graph
9018
+ if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
9019
+ basePath = clonePath(removePath);
9020
+ self.pushComponent(basePath.components, undefined, true);
9021
+ } else {
9022
+ basePath = addPath; // No need to clone, we've pulled it from the list
9023
+ basePath.newPos++;
9024
+ self.pushComponent(basePath.components, true, undefined);
9025
+ }
9102
9026
 
9103
- var newLen = newString.length, oldLen = oldString.length;
9104
- var editLength = 1;
9105
- var maxEditLength = newLen + oldLen;
9106
- var bestPath = [{ newPos: -1, components: [] }];
9027
+ _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
9107
9028
 
9108
- // Seed editLength = 0, i.e. the content starts with the same values
9109
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
9110
- if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
9111
- // Identity per the equality and tokenizer
9112
- return done([{value: newString.join('')}]);
9029
+ // If we have hit the end of both strings, then we are done
9030
+ if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
9031
+ return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
9032
+ } else {
9033
+ // Otherwise track this path as a potential candidate and continue.
9034
+ bestPath[diagonalPath] = basePath;
9035
+ }
9113
9036
  }
9114
9037
 
9115
- // Main worker method. checks all permutations of a given edit length for acceptance.
9116
- function execEditLength() {
9117
- for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
9118
- var basePath;
9119
- var addPath = bestPath[diagonalPath - 1],
9120
- removePath = bestPath[diagonalPath + 1],
9121
- oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
9122
- if (addPath) {
9123
- // No one else is going to attempt to use this value, clear it
9124
- bestPath[diagonalPath - 1] = undefined;
9125
- }
9126
-
9127
- var canAdd = addPath && addPath.newPos + 1 < newLen,
9128
- canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
9129
- if (!canAdd && !canRemove) {
9130
- // If this path is a terminal then prune
9131
- bestPath[diagonalPath] = undefined;
9132
- continue;
9133
- }
9038
+ editLength++;
9039
+ }
9134
9040
 
9135
- // Select the diagonal that we want to branch from. We select the prior
9136
- // path whose position in the new string is the farthest from the origin
9137
- // and does not pass the bounds of the diff graph
9138
- if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
9139
- basePath = clonePath(removePath);
9140
- self.pushComponent(basePath.components, undefined, true);
9141
- } else {
9142
- basePath = addPath; // No need to clone, we've pulled it from the list
9143
- basePath.newPos++;
9144
- self.pushComponent(basePath.components, true, undefined);
9041
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
9042
+ // sync and async mode which is never fun. Loops over execEditLength until a value
9043
+ // is produced.
9044
+ if (callback) {
9045
+ (function exec() {
9046
+ setTimeout(function () {
9047
+ // This should not happen, but we want to be safe.
9048
+ /* istanbul ignore next */
9049
+ if (editLength > maxEditLength) {
9050
+ return callback();
9145
9051
  }
9146
9052
 
9147
- oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
9148
-
9149
- // If we have hit the end of both strings, then we are done
9150
- if (basePath.newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
9151
- return done(buildValues(basePath.components, newString, oldString, self.useLongestToken));
9152
- } else {
9153
- // Otherwise track this path as a potential candidate and continue.
9154
- bestPath[diagonalPath] = basePath;
9053
+ if (!execEditLength()) {
9054
+ exec();
9155
9055
  }
9056
+ }, 0);
9057
+ })();
9058
+ } else {
9059
+ while (editLength <= maxEditLength) {
9060
+ var ret = execEditLength();
9061
+ if (ret) {
9062
+ return ret;
9156
9063
  }
9157
-
9158
- editLength++;
9159
9064
  }
9065
+ }
9066
+ },
9067
+ /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
9068
+ var last = components[components.length - 1];
9069
+ if (last && last.added === added && last.removed === removed) {
9070
+ // We need to clone here as the component clone operation is just
9071
+ // as shallow array clone
9072
+ components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
9073
+ } else {
9074
+ components.push({ count: 1, added: added, removed: removed });
9075
+ }
9076
+ },
9077
+ /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
9078
+ var newLen = newString.length,
9079
+ oldLen = oldString.length,
9080
+ newPos = basePath.newPos,
9081
+ oldPos = newPos - diagonalPath,
9082
+ commonCount = 0;
9083
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
9084
+ newPos++;
9085
+ oldPos++;
9086
+ commonCount++;
9087
+ }
9160
9088
 
9161
- // Performs the length of edit iteration. Is a bit fugly as this has to support the
9162
- // sync and async mode which is never fun. Loops over execEditLength until a value
9163
- // is produced.
9164
- if (callback) {
9165
- (function exec() {
9166
- setTimeout(function() {
9167
- // This should not happen, but we want to be safe.
9168
- /*istanbul ignore next */
9169
- if (editLength > maxEditLength) {
9170
- return callback();
9171
- }
9089
+ if (commonCount) {
9090
+ basePath.components.push({ count: commonCount });
9091
+ }
9172
9092
 
9173
- if (!execEditLength()) {
9174
- exec();
9175
- }
9176
- }, 0);
9177
- }());
9178
- } else {
9179
- while (editLength <= maxEditLength) {
9180
- var ret = execEditLength();
9181
- if (ret) {
9182
- return ret;
9183
- }
9184
- }
9093
+ basePath.newPos = newPos;
9094
+ return oldPos;
9095
+ },
9096
+ /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
9097
+ return left === right;
9098
+ },
9099
+ /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
9100
+ var ret = [];
9101
+ for (var i = 0; i < array.length; i++) {
9102
+ if (array[i]) {
9103
+ ret.push(array[i]);
9185
9104
  }
9186
- },
9105
+ }
9106
+ return ret;
9107
+ },
9108
+ /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
9109
+ return value;
9110
+ },
9111
+ /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
9112
+ return value.split('');
9113
+ },
9114
+ /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
9115
+ return chars.join('');
9116
+ }
9117
+ };
9118
+
9119
+ function buildValues(diff, components, newString, oldString, useLongestToken) {
9120
+ var componentPos = 0,
9121
+ componentLen = components.length,
9122
+ newPos = 0,
9123
+ oldPos = 0;
9187
9124
 
9188
- pushComponent: function(components, added, removed) {
9189
- var last = components[components.length - 1];
9190
- if (last && last.added === added && last.removed === removed) {
9191
- // We need to clone here as the component clone operation is just
9192
- // as shallow array clone
9193
- components[components.length - 1] = {count: last.count + 1, added: added, removed: removed };
9125
+ for (; componentPos < componentLen; componentPos++) {
9126
+ var component = components[componentPos];
9127
+ if (!component.removed) {
9128
+ if (!component.added && useLongestToken) {
9129
+ var value = newString.slice(newPos, newPos + component.count);
9130
+ value = value.map(function (value, i) {
9131
+ var oldValue = oldString[oldPos + i];
9132
+ return oldValue.length > value.length ? oldValue : value;
9133
+ });
9134
+
9135
+ component.value = diff.join(value);
9194
9136
  } else {
9195
- components.push({count: 1, added: added, removed: removed });
9196
- }
9197
- },
9198
- extractCommon: function(basePath, newString, oldString, diagonalPath) {
9199
- var newLen = newString.length,
9200
- oldLen = oldString.length,
9201
- newPos = basePath.newPos,
9202
- oldPos = newPos - diagonalPath,
9203
-
9204
- commonCount = 0;
9205
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
9206
- newPos++;
9207
- oldPos++;
9208
- commonCount++;
9137
+ component.value = diff.join(newString.slice(newPos, newPos + component.count));
9209
9138
  }
9139
+ newPos += component.count;
9210
9140
 
9211
- if (commonCount) {
9212
- basePath.components.push({count: commonCount});
9141
+ // Common case
9142
+ if (!component.added) {
9143
+ oldPos += component.count;
9144
+ }
9145
+ } else {
9146
+ component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
9147
+ oldPos += component.count;
9148
+
9149
+ // Reverse add and remove so removes are output first to match common convention
9150
+ // The diffing algorithm is tied to add then remove output and this is the simplest
9151
+ // route to get the desired output with minimal overhead.
9152
+ if (componentPos && components[componentPos - 1].added) {
9153
+ var tmp = components[componentPos - 1];
9154
+ components[componentPos - 1] = components[componentPos];
9155
+ components[componentPos] = tmp;
9213
9156
  }
9157
+ }
9158
+ }
9214
9159
 
9215
- basePath.newPos = newPos;
9216
- return oldPos;
9217
- },
9160
+ // Special case handle for when one terminal is ignored. For this case we merge the
9161
+ // terminal into the prior string and drop the change.
9162
+ var lastComponent = components[componentLen - 1];
9163
+ if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
9164
+ components[componentLen - 2].value += lastComponent.value;
9165
+ components.pop();
9166
+ }
9218
9167
 
9219
- equals: function(left, right) {
9220
- var reWhitespace = /\S/;
9221
- return left === right || (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right));
9222
- },
9223
- tokenize: function(value) {
9224
- return value.split('');
9225
- }
9226
- };
9168
+ return components;
9169
+ }
9227
9170
 
9228
- var CharDiff = new Diff();
9171
+ function clonePath(path) {
9172
+ return { newPos: path.newPos, components: path.components.slice(0) };
9173
+ }
9229
9174
 
9230
- var WordDiff = new Diff(true);
9231
- var WordWithSpaceDiff = new Diff();
9232
- WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {
9233
- return removeEmpty(value.split(/(\s+|\b)/));
9234
- };
9235
9175
 
9236
- var CssDiff = new Diff(true);
9237
- CssDiff.tokenize = function(value) {
9238
- return removeEmpty(value.split(/([{}:;,]|\s+)/));
9239
- };
9176
+ },{}],49:[function(require,module,exports){
9177
+ /*istanbul ignore start*/'use strict';
9240
9178
 
9241
- var LineDiff = new Diff();
9179
+ exports.__esModule = true;
9180
+ exports.characterDiff = undefined;
9181
+ exports. /*istanbul ignore end*/diffChars = diffChars;
9242
9182
 
9243
- var TrimmedLineDiff = new Diff();
9244
- TrimmedLineDiff.ignoreTrim = true;
9183
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9245
9184
 
9246
- LineDiff.tokenize = TrimmedLineDiff.tokenize = function(value) {
9247
- var retLines = [],
9248
- lines = value.split(/^/m);
9249
- for (var i = 0; i < lines.length; i++) {
9250
- var line = lines[i],
9251
- lastLine = lines[i - 1],
9252
- lastLineLastChar = lastLine && lastLine[lastLine.length - 1];
9185
+ /*istanbul ignore start*/
9186
+ var _base2 = _interopRequireDefault(_base);
9253
9187
 
9254
- // Merge lines that may contain windows new lines
9255
- if (line === '\n' && lastLineLastChar === '\r') {
9256
- retLines[retLines.length - 1] = retLines[retLines.length - 1].slice(0, -1) + '\r\n';
9257
- } else {
9258
- if (this.ignoreTrim) {
9259
- line = line.trim();
9260
- // add a newline unless this is the last line.
9261
- if (i < lines.length - 1) {
9262
- line += '\n';
9263
- }
9264
- }
9265
- retLines.push(line);
9266
- }
9267
- }
9188
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9268
9189
 
9269
- return retLines;
9270
- };
9190
+ /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9191
+ function diffChars(oldStr, newStr, callback) {
9192
+ return characterDiff.diff(oldStr, newStr, callback);
9193
+ }
9271
9194
 
9272
- var PatchDiff = new Diff();
9273
- PatchDiff.tokenize = function(value) {
9274
- var ret = [],
9275
- linesAndNewlines = value.split(/(\n|\r\n)/);
9276
9195
 
9277
- // Ignore the final empty token that occurs if the string ends with a new line
9278
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
9279
- linesAndNewlines.pop();
9280
- }
9196
+ },{"./base":48}],50:[function(require,module,exports){
9197
+ /*istanbul ignore start*/'use strict';
9281
9198
 
9282
- // Merge the content and line separators into single tokens
9283
- for (var i = 0; i < linesAndNewlines.length; i++) {
9284
- var line = linesAndNewlines[i];
9199
+ exports.__esModule = true;
9200
+ exports.cssDiff = undefined;
9201
+ exports. /*istanbul ignore end*/diffCss = diffCss;
9285
9202
 
9286
- if (i % 2) {
9287
- ret[ret.length - 1] += line;
9288
- } else {
9289
- ret.push(line);
9290
- }
9291
- }
9292
- return ret;
9293
- };
9203
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9294
9204
 
9295
- var SentenceDiff = new Diff();
9296
- SentenceDiff.tokenize = function(value) {
9297
- return removeEmpty(value.split(/(\S.+?[.!?])(?=\s+|$)/));
9298
- };
9205
+ /*istanbul ignore start*/
9206
+ var _base2 = _interopRequireDefault(_base);
9299
9207
 
9300
- var JsonDiff = new Diff();
9301
- // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
9302
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
9303
- JsonDiff.useLongestToken = true;
9304
- JsonDiff.tokenize = LineDiff.tokenize;
9305
- JsonDiff.equals = function(left, right) {
9306
- return LineDiff.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
9307
- };
9208
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9308
9209
 
9309
- var JsDiff = {
9310
- Diff: Diff,
9210
+ /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9211
+ cssDiff.tokenize = function (value) {
9212
+ return value.split(/([{}:;,]|\s+)/);
9213
+ };
9311
9214
 
9312
- diffChars: function(oldStr, newStr, callback) { return CharDiff.diff(oldStr, newStr, callback); },
9313
- diffWords: function(oldStr, newStr, callback) { return WordDiff.diff(oldStr, newStr, callback); },
9314
- diffWordsWithSpace: function(oldStr, newStr, callback) { return WordWithSpaceDiff.diff(oldStr, newStr, callback); },
9315
- diffLines: function(oldStr, newStr, callback) { return LineDiff.diff(oldStr, newStr, callback); },
9316
- diffTrimmedLines: function(oldStr, newStr, callback) { return TrimmedLineDiff.diff(oldStr, newStr, callback); },
9215
+ function diffCss(oldStr, newStr, callback) {
9216
+ return cssDiff.diff(oldStr, newStr, callback);
9217
+ }
9317
9218
 
9318
- diffSentences: function(oldStr, newStr, callback) { return SentenceDiff.diff(oldStr, newStr, callback); },
9319
9219
 
9320
- diffCss: function(oldStr, newStr, callback) { return CssDiff.diff(oldStr, newStr, callback); },
9321
- diffJson: function(oldObj, newObj, callback) {
9322
- return JsonDiff.diff(
9323
- typeof oldObj === 'string' ? oldObj : JSON.stringify(canonicalize(oldObj), undefined, ' '),
9324
- typeof newObj === 'string' ? newObj : JSON.stringify(canonicalize(newObj), undefined, ' '),
9325
- callback
9326
- );
9327
- },
9220
+ },{"./base":48}],51:[function(require,module,exports){
9221
+ /*istanbul ignore start*/'use strict';
9328
9222
 
9329
- createTwoFilesPatch: function(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader) {
9330
- var ret = [];
9223
+ exports.__esModule = true;
9224
+ exports.jsonDiff = undefined;
9331
9225
 
9332
- if (oldFileName == newFileName) {
9333
- ret.push('Index: ' + oldFileName);
9334
- }
9335
- ret.push('===================================================================');
9336
- ret.push('--- ' + oldFileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader));
9337
- ret.push('+++ ' + newFileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader));
9226
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
9338
9227
 
9339
- var diff = PatchDiff.diff(oldStr, newStr);
9340
- diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier
9228
+ exports. /*istanbul ignore end*/diffJson = diffJson;
9229
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
9341
9230
 
9342
- // Formats a given set of lines for printing as context lines in a patch
9343
- function contextLines(lines) {
9344
- return map(lines, function(entry) { return ' ' + entry; });
9345
- }
9231
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9346
9232
 
9347
- // Outputs the no newline at end of file warning if needed
9348
- function eofNL(curRange, i, current) {
9349
- var last = diff[diff.length - 2],
9350
- isLast = i === diff.length - 2,
9351
- isLastOfType = i === diff.length - 3 && current.added !== last.added;
9233
+ /*istanbul ignore start*/
9234
+ var _base2 = _interopRequireDefault(_base);
9352
9235
 
9353
- // Figure out if this is the last line for the given file and missing NL
9354
- if (!(/\n$/.test(current.value)) && (isLast || isLastOfType)) {
9355
- curRange.push('\');
9356
- }
9357
- }
9236
+ /*istanbul ignore end*/
9237
+ var /*istanbul ignore start*/_line = require('./line') /*istanbul ignore end*/;
9358
9238
 
9359
- var oldRangeStart = 0, newRangeStart = 0, curRange = [],
9360
- oldLine = 1, newLine = 1;
9361
- for (var i = 0; i < diff.length; i++) {
9362
- var current = diff[i],
9363
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
9364
- current.lines = lines;
9365
-
9366
- if (current.added || current.removed) {
9367
- // If we have previous context, start with that
9368
- if (!oldRangeStart) {
9369
- var prev = diff[i - 1];
9370
- oldRangeStart = oldLine;
9371
- newRangeStart = newLine;
9372
-
9373
- if (prev) {
9374
- curRange = contextLines(prev.lines.slice(-4));
9375
- oldRangeStart -= curRange.length;
9376
- newRangeStart -= curRange.length;
9377
- }
9378
- }
9239
+ /*istanbul ignore start*/
9240
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9379
9241
 
9380
- // Output our changes
9381
- curRange.push.apply(curRange, map(lines, function(entry) {
9382
- return (current.added ? '+' : '-') + entry;
9383
- }));
9384
- eofNL(curRange, i, current);
9242
+ /*istanbul ignore end*/
9385
9243
 
9386
- // Track the updated file position
9387
- if (current.added) {
9388
- newLine += lines.length;
9389
- } else {
9390
- oldLine += lines.length;
9391
- }
9392
- } else {
9393
- // Identical context lines. Track line changes
9394
- if (oldRangeStart) {
9395
- // Close out any changes that have been output (or join overlapping)
9396
- if (lines.length <= 8 && i < diff.length - 2) {
9397
- // Overlapping
9398
- curRange.push.apply(curRange, contextLines(lines));
9399
- } else {
9400
- // end the range and output
9401
- var contextSize = Math.min(lines.length, 4);
9402
- ret.push(
9403
- '@@ -' + oldRangeStart + ',' + (oldLine - oldRangeStart + contextSize)
9404
- + ' +' + newRangeStart + ',' + (newLine - newRangeStart + contextSize)
9405
- + ' @@');
9406
- ret.push.apply(ret, curRange);
9407
- ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
9408
- if (lines.length <= 4) {
9409
- eofNL(ret, i, current);
9410
- }
9244
+ var objectPrototypeToString = Object.prototype.toString;
9411
9245
 
9412
- oldRangeStart = 0;
9413
- newRangeStart = 0;
9414
- curRange = [];
9415
- }
9416
- }
9417
- oldLine += lines.length;
9418
- newLine += lines.length;
9419
- }
9420
- }
9246
+ var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9247
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
9248
+ // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
9249
+ jsonDiff.useLongestToken = true;
9421
9250
 
9422
- return ret.join('\n') + '\n';
9423
- },
9251
+ jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff. /*istanbul ignore end*/tokenize;
9252
+ jsonDiff.castInput = function (value) {
9253
+ /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement;
9424
9254
 
9425
- createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
9426
- return JsDiff.createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader);
9427
- },
9428
9255
 
9429
- applyPatch: function(oldStr, uniDiff) {
9430
- var diffstr = uniDiff.split('\n'),
9431
- hunks = [],
9432
- i = 0,
9433
- remEOFNL = false,
9434
- addEOFNL = false;
9256
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
9257
+ if (typeof v === 'undefined') {
9258
+ return undefinedReplacement;
9259
+ }
9435
9260
 
9436
- // Skip to the first change hunk
9437
- while (i < diffstr.length && !(/^@@/.test(diffstr[i]))) {
9438
- i++;
9439
- }
9261
+ return v;
9262
+ }, ' ');
9263
+ };
9264
+ jsonDiff.equals = function (left, right) {
9265
+ return (/*istanbul ignore start*/_base2['default']. /*istanbul ignore end*/prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
9266
+ );
9267
+ };
9440
9268
 
9441
- // Parse the unified diff
9442
- for (; i < diffstr.length; i++) {
9443
- if (diffstr[i][0] === '@') {
9444
- var chnukHeader = diffstr[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
9445
- hunks.unshift({
9446
- start: chnukHeader[3],
9447
- oldlength: +chnukHeader[2],
9448
- removed: [],
9449
- newlength: chnukHeader[4],
9450
- added: []
9451
- });
9452
- } else if (diffstr[i][0] === '+') {
9453
- hunks[0].added.push(diffstr[i].substr(1));
9454
- } else if (diffstr[i][0] === '-') {
9455
- hunks[0].removed.push(diffstr[i].substr(1));
9456
- } else if (diffstr[i][0] === ' ') {
9457
- hunks[0].added.push(diffstr[i].substr(1));
9458
- hunks[0].removed.push(diffstr[i].substr(1));
9459
- } else if (diffstr[i][0] === '\\') {
9460
- if (diffstr[i - 1][0] === '+') {
9461
- remEOFNL = true;
9462
- } else if (diffstr[i - 1][0] === '-') {
9463
- addEOFNL = true;
9464
- }
9465
- }
9466
- }
9269
+ function diffJson(oldObj, newObj, options) {
9270
+ return jsonDiff.diff(oldObj, newObj, options);
9271
+ }
9467
9272
 
9468
- // Apply the diff to the input
9469
- var lines = oldStr.split('\n');
9470
- for (i = hunks.length - 1; i >= 0; i--) {
9471
- var hunk = hunks[i];
9472
- // Sanity check the input string. Bail if we don't match.
9473
- for (var j = 0; j < hunk.oldlength; j++) {
9474
- if (lines[hunk.start - 1 + j] !== hunk.removed[j]) {
9475
- return false;
9476
- }
9477
- }
9478
- Array.prototype.splice.apply(lines, [hunk.start - 1, hunk.oldlength].concat(hunk.added));
9479
- }
9273
+ // This function handles the presence of circular references by bailing out when encountering an
9274
+ // object that is already on the "stack" of items being processed.
9275
+ function canonicalize(obj, stack, replacementStack) {
9276
+ stack = stack || [];
9277
+ replacementStack = replacementStack || [];
9480
9278
 
9481
- // Handle EOFNL insertion/removal
9482
- if (remEOFNL) {
9483
- while (!lines[lines.length - 1]) {
9484
- lines.pop();
9485
- }
9486
- } else if (addEOFNL) {
9487
- lines.push('');
9488
- }
9489
- return lines.join('\n');
9490
- },
9279
+ var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9491
9280
 
9492
- convertChangesToXML: function(changes) {
9493
- var ret = [];
9494
- for (var i = 0; i < changes.length; i++) {
9495
- var change = changes[i];
9496
- if (change.added) {
9497
- ret.push('<ins>');
9498
- } else if (change.removed) {
9499
- ret.push('<del>');
9281
+ for (i = 0; i < stack.length; i += 1) {
9282
+ if (stack[i] === obj) {
9283
+ return replacementStack[i];
9284
+ }
9285
+ }
9286
+
9287
+ var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9288
+
9289
+ if ('[object Array]' === objectPrototypeToString.call(obj)) {
9290
+ stack.push(obj);
9291
+ canonicalizedObj = new Array(obj.length);
9292
+ replacementStack.push(canonicalizedObj);
9293
+ for (i = 0; i < obj.length; i += 1) {
9294
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
9295
+ }
9296
+ stack.pop();
9297
+ replacementStack.pop();
9298
+ return canonicalizedObj;
9299
+ }
9300
+
9301
+ if (obj && obj.toJSON) {
9302
+ obj = obj.toJSON();
9303
+ }
9304
+
9305
+ if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
9306
+ stack.push(obj);
9307
+ canonicalizedObj = {};
9308
+ replacementStack.push(canonicalizedObj);
9309
+ var sortedKeys = [],
9310
+ key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9311
+ for (key in obj) {
9312
+ /* istanbul ignore else */
9313
+ if (obj.hasOwnProperty(key)) {
9314
+ sortedKeys.push(key);
9315
+ }
9316
+ }
9317
+ sortedKeys.sort();
9318
+ for (i = 0; i < sortedKeys.length; i += 1) {
9319
+ key = sortedKeys[i];
9320
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
9321
+ }
9322
+ stack.pop();
9323
+ replacementStack.pop();
9324
+ } else {
9325
+ canonicalizedObj = obj;
9326
+ }
9327
+ return canonicalizedObj;
9328
+ }
9329
+
9330
+
9331
+ },{"./base":48,"./line":52}],52:[function(require,module,exports){
9332
+ /*istanbul ignore start*/'use strict';
9333
+
9334
+ exports.__esModule = true;
9335
+ exports.lineDiff = undefined;
9336
+ exports. /*istanbul ignore end*/diffLines = diffLines;
9337
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
9338
+
9339
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9340
+
9341
+ /*istanbul ignore start*/
9342
+ var _base2 = _interopRequireDefault(_base);
9343
+
9344
+ /*istanbul ignore end*/
9345
+ var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
9346
+
9347
+ /*istanbul ignore start*/
9348
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9349
+
9350
+ /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9351
+ lineDiff.tokenize = function (value) {
9352
+ var retLines = [],
9353
+ linesAndNewlines = value.split(/(\n|\r\n)/);
9354
+
9355
+ // Ignore the final empty token that occurs if the string ends with a new line
9356
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
9357
+ linesAndNewlines.pop();
9358
+ }
9359
+
9360
+ // Merge the content and line separators into single tokens
9361
+ for (var i = 0; i < linesAndNewlines.length; i++) {
9362
+ var line = linesAndNewlines[i];
9363
+
9364
+ if (i % 2 && !this.options.newlineIsToken) {
9365
+ retLines[retLines.length - 1] += line;
9366
+ } else {
9367
+ if (this.options.ignoreWhitespace) {
9368
+ line = line.trim();
9369
+ }
9370
+ retLines.push(line);
9371
+ }
9372
+ }
9373
+
9374
+ return retLines;
9375
+ };
9376
+
9377
+ function diffLines(oldStr, newStr, callback) {
9378
+ return lineDiff.diff(oldStr, newStr, callback);
9379
+ }
9380
+ function diffTrimmedLines(oldStr, newStr, callback) {
9381
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
9382
+ return lineDiff.diff(oldStr, newStr, options);
9383
+ }
9384
+
9385
+
9386
+ },{"../util/params":60,"./base":48}],53:[function(require,module,exports){
9387
+ /*istanbul ignore start*/'use strict';
9388
+
9389
+ exports.__esModule = true;
9390
+ exports.sentenceDiff = undefined;
9391
+ exports. /*istanbul ignore end*/diffSentences = diffSentences;
9392
+
9393
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9394
+
9395
+ /*istanbul ignore start*/
9396
+ var _base2 = _interopRequireDefault(_base);
9397
+
9398
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9399
+
9400
+ /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9401
+ sentenceDiff.tokenize = function (value) {
9402
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
9403
+ };
9404
+
9405
+ function diffSentences(oldStr, newStr, callback) {
9406
+ return sentenceDiff.diff(oldStr, newStr, callback);
9407
+ }
9408
+
9409
+
9410
+ },{"./base":48}],54:[function(require,module,exports){
9411
+ /*istanbul ignore start*/'use strict';
9412
+
9413
+ exports.__esModule = true;
9414
+ exports.wordDiff = undefined;
9415
+ exports. /*istanbul ignore end*/diffWords = diffWords;
9416
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
9417
+
9418
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9419
+
9420
+ /*istanbul ignore start*/
9421
+ var _base2 = _interopRequireDefault(_base);
9422
+
9423
+ /*istanbul ignore end*/
9424
+ var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
9425
+
9426
+ /*istanbul ignore start*/
9427
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9428
+
9429
+ /*istanbul ignore end*/
9430
+
9431
+ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
9432
+ //
9433
+ // Ranges and exceptions:
9434
+ // Latin-1 Supplement, 0080–00FF
9435
+ // - U+00D7 × Multiplication sign
9436
+ // - U+00F7 ÷ Division sign
9437
+ // Latin Extended-A, 0100–017F
9438
+ // Latin Extended-B, 0180–024F
9439
+ // IPA Extensions, 0250–02AF
9440
+ // Spacing Modifier Letters, 02B0–02FF
9441
+ // - U+02C7 ˇ &#711; Caron
9442
+ // - U+02D8 ˘ &#728; Breve
9443
+ // - U+02D9 ˙ &#729; Dot Above
9444
+ // - U+02DA ˚ &#730; Ring Above
9445
+ // - U+02DB ˛ &#731; Ogonek
9446
+ // - U+02DC ˜ &#732; Small Tilde
9447
+ // - U+02DD ˝ &#733; Double Acute Accent
9448
+ // Latin Extended Additional, 1E00–1EFF
9449
+ var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
9450
+
9451
+ var reWhitespace = /\S/;
9452
+
9453
+ var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9454
+ wordDiff.equals = function (left, right) {
9455
+ return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
9456
+ };
9457
+ wordDiff.tokenize = function (value) {
9458
+ var tokens = value.split(/(\s+|\b)/);
9459
+
9460
+ // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
9461
+ for (var i = 0; i < tokens.length - 1; i++) {
9462
+ // If we have an empty string in the next field and we have only word chars before and after, merge
9463
+ if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
9464
+ tokens[i] += tokens[i + 2];
9465
+ tokens.splice(i + 1, 2);
9466
+ i--;
9467
+ }
9468
+ }
9469
+
9470
+ return tokens;
9471
+ };
9472
+
9473
+ function diffWords(oldStr, newStr, callback) {
9474
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
9475
+ return wordDiff.diff(oldStr, newStr, options);
9476
+ }
9477
+ function diffWordsWithSpace(oldStr, newStr, callback) {
9478
+ return wordDiff.diff(oldStr, newStr, callback);
9479
+ }
9480
+
9481
+
9482
+ },{"../util/params":60,"./base":48}],55:[function(require,module,exports){
9483
+ /*istanbul ignore start*/'use strict';
9484
+
9485
+ exports.__esModule = true;
9486
+ exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = 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;
9487
+ /*istanbul ignore end*/
9488
+ var /*istanbul ignore start*/_base = require('./diff/base') /*istanbul ignore end*/;
9489
+
9490
+ /*istanbul ignore start*/
9491
+ var _base2 = _interopRequireDefault(_base);
9492
+
9493
+ /*istanbul ignore end*/
9494
+ var /*istanbul ignore start*/_character = require('./diff/character') /*istanbul ignore end*/;
9495
+
9496
+ var /*istanbul ignore start*/_word = require('./diff/word') /*istanbul ignore end*/;
9497
+
9498
+ var /*istanbul ignore start*/_line = require('./diff/line') /*istanbul ignore end*/;
9499
+
9500
+ var /*istanbul ignore start*/_sentence = require('./diff/sentence') /*istanbul ignore end*/;
9501
+
9502
+ var /*istanbul ignore start*/_css = require('./diff/css') /*istanbul ignore end*/;
9503
+
9504
+ var /*istanbul ignore start*/_json = require('./diff/json') /*istanbul ignore end*/;
9505
+
9506
+ var /*istanbul ignore start*/_array = require('./diff/array') /*istanbul ignore end*/;
9507
+
9508
+ var /*istanbul ignore start*/_apply = require('./patch/apply') /*istanbul ignore end*/;
9509
+
9510
+ var /*istanbul ignore start*/_parse = require('./patch/parse') /*istanbul ignore end*/;
9511
+
9512
+ var /*istanbul ignore start*/_create = require('./patch/create') /*istanbul ignore end*/;
9513
+
9514
+ var /*istanbul ignore start*/_dmp = require('./convert/dmp') /*istanbul ignore end*/;
9515
+
9516
+ var /*istanbul ignore start*/_xml = require('./convert/xml') /*istanbul ignore end*/;
9517
+
9518
+ /*istanbul ignore start*/
9519
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9520
+
9521
+ exports. /*istanbul ignore end*/Diff = _base2['default'];
9522
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
9523
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
9524
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
9525
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
9526
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
9527
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
9528
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
9529
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
9530
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
9531
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
9532
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
9533
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
9534
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
9535
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
9536
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
9537
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
9538
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
9539
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize; /* See LICENSE file for terms of use */
9540
+
9541
+ /*
9542
+ * Text diff implementation.
9543
+ *
9544
+ * This library supports the following APIS:
9545
+ * JsDiff.diffChars: Character by character diff
9546
+ * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
9547
+ * JsDiff.diffLines: Line based diff
9548
+ *
9549
+ * JsDiff.diffCss: Diff targeted at CSS content
9550
+ *
9551
+ * These methods are based on the implementation proposed in
9552
+ * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
9553
+ * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
9554
+ */
9555
+
9556
+
9557
+ },{"./convert/dmp":45,"./convert/xml":46,"./diff/array":47,"./diff/base":48,"./diff/character":49,"./diff/css":50,"./diff/json":51,"./diff/line":52,"./diff/sentence":53,"./diff/word":54,"./patch/apply":56,"./patch/create":57,"./patch/parse":58}],56:[function(require,module,exports){
9558
+ /*istanbul ignore start*/'use strict';
9559
+
9560
+ exports.__esModule = true;
9561
+ exports. /*istanbul ignore end*/applyPatch = applyPatch;
9562
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
9563
+
9564
+ var /*istanbul ignore start*/_parse = require('./parse') /*istanbul ignore end*/;
9565
+
9566
+ var /*istanbul ignore start*/_distanceIterator = require('../util/distance-iterator') /*istanbul ignore end*/;
9567
+
9568
+ /*istanbul ignore start*/
9569
+ var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
9570
+
9571
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9572
+
9573
+ /*istanbul ignore end*/function applyPatch(source, uniDiff) {
9574
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
9575
+
9576
+ if (typeof uniDiff === 'string') {
9577
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
9578
+ }
9579
+
9580
+ if (Array.isArray(uniDiff)) {
9581
+ if (uniDiff.length > 1) {
9582
+ throw new Error('applyPatch only works with a single input.');
9583
+ }
9584
+
9585
+ uniDiff = uniDiff[0];
9586
+ }
9587
+
9588
+ // Apply the diff to the input
9589
+ var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
9590
+ delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
9591
+ hunks = uniDiff.hunks,
9592
+ compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
9593
+ return (/*istanbul ignore end*/line === patchContent
9594
+ );
9595
+ },
9596
+ errorCount = 0,
9597
+ fuzzFactor = options.fuzzFactor || 0,
9598
+ minLine = 0,
9599
+ offset = 0,
9600
+ removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
9601
+ addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9602
+
9603
+ /**
9604
+ * Checks if the hunk exactly fits on the provided location
9605
+ */
9606
+ function hunkFits(hunk, toPos) {
9607
+ for (var j = 0; j < hunk.lines.length; j++) {
9608
+ var line = hunk.lines[j],
9609
+ operation = line[0],
9610
+ content = line.substr(1);
9611
+
9612
+ if (operation === ' ' || operation === '-') {
9613
+ // Context sanity check
9614
+ if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
9615
+ errorCount++;
9616
+
9617
+ if (errorCount > fuzzFactor) {
9618
+ return false;
9619
+ }
9500
9620
  }
9621
+ toPos++;
9622
+ }
9623
+ }
9501
9624
 
9502
- ret.push(escapeHTML(change.value));
9625
+ return true;
9626
+ }
9627
+
9628
+ // Search best fit offsets for each hunk based on the previous ones
9629
+ for (var i = 0; i < hunks.length; i++) {
9630
+ var hunk = hunks[i],
9631
+ maxLine = lines.length - hunk.oldLines,
9632
+ localOffset = 0,
9633
+ toPos = offset + hunk.oldStart - 1;
9634
+
9635
+ var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
9636
+
9637
+ for (; localOffset !== undefined; localOffset = iterator()) {
9638
+ if (hunkFits(hunk, toPos + localOffset)) {
9639
+ hunk.offset = offset += localOffset;
9640
+ break;
9641
+ }
9642
+ }
9503
9643
 
9504
- if (change.added) {
9505
- ret.push('</ins>');
9506
- } else if (change.removed) {
9507
- ret.push('</del>');
9644
+ if (localOffset === undefined) {
9645
+ return false;
9646
+ }
9647
+
9648
+ // Set lower text limit to end of the current hunk, so next ones don't try
9649
+ // to fit over already patched text
9650
+ minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
9651
+ }
9652
+
9653
+ // Apply patch hunks
9654
+ for (var _i = 0; _i < hunks.length; _i++) {
9655
+ var _hunk = hunks[_i],
9656
+ _toPos = _hunk.offset + _hunk.newStart - 1;
9657
+ if (_hunk.newLines == 0) {
9658
+ _toPos++;
9659
+ }
9660
+
9661
+ for (var j = 0; j < _hunk.lines.length; j++) {
9662
+ var line = _hunk.lines[j],
9663
+ operation = line[0],
9664
+ content = line.substr(1),
9665
+ delimiter = _hunk.linedelimiters[j];
9666
+
9667
+ if (operation === ' ') {
9668
+ _toPos++;
9669
+ } else if (operation === '-') {
9670
+ lines.splice(_toPos, 1);
9671
+ delimiters.splice(_toPos, 1);
9672
+ /* istanbul ignore else */
9673
+ } else if (operation === '+') {
9674
+ lines.splice(_toPos, 0, content);
9675
+ delimiters.splice(_toPos, 0, delimiter);
9676
+ _toPos++;
9677
+ } else if (operation === '\\') {
9678
+ var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
9679
+ if (previousOperation === '+') {
9680
+ removeEOFNL = true;
9681
+ } else if (previousOperation === '-') {
9682
+ addEOFNL = true;
9683
+ }
9508
9684
  }
9685
+ }
9686
+ }
9687
+
9688
+ // Handle EOFNL insertion/removal
9689
+ if (removeEOFNL) {
9690
+ while (!lines[lines.length - 1]) {
9691
+ lines.pop();
9692
+ delimiters.pop();
9693
+ }
9694
+ } else if (addEOFNL) {
9695
+ lines.push('');
9696
+ delimiters.push('\n');
9697
+ }
9698
+ for (var _k = 0; _k < lines.length - 1; _k++) {
9699
+ lines[_k] = lines[_k] + delimiters[_k];
9700
+ }
9701
+ return lines.join('');
9702
+ }
9703
+
9704
+ // Wrapper that supports multiple file patches via callbacks.
9705
+ function applyPatches(uniDiff, options) {
9706
+ if (typeof uniDiff === 'string') {
9707
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
9708
+ }
9709
+
9710
+ var currentIndex = 0;
9711
+ function processIndex() {
9712
+ var index = uniDiff[currentIndex++];
9713
+ if (!index) {
9714
+ return options.complete();
9715
+ }
9716
+
9717
+ options.loadFile(index, function (err, data) {
9718
+ if (err) {
9719
+ return options.complete(err);
9509
9720
  }
9510
- return ret.join('');
9511
- },
9512
9721
 
9513
- // See: http://code.google.com/p/google-diff-match-patch/wiki/API
9514
- convertChangesToDMP: function(changes) {
9515
- var ret = [],
9516
- change,
9517
- operation;
9518
- for (var i = 0; i < changes.length; i++) {
9519
- change = changes[i];
9520
- if (change.added) {
9521
- operation = 1;
9522
- } else if (change.removed) {
9523
- operation = -1;
9722
+ var updatedContent = applyPatch(data, index, options);
9723
+ options.patched(index, updatedContent, function (err) {
9724
+ if (err) {
9725
+ return options.complete(err);
9726
+ }
9727
+
9728
+ processIndex();
9729
+ });
9730
+ });
9731
+ }
9732
+ processIndex();
9733
+ }
9734
+
9735
+
9736
+ },{"../util/distance-iterator":59,"./parse":58}],57:[function(require,module,exports){
9737
+ /*istanbul ignore start*/'use strict';
9738
+
9739
+ exports.__esModule = true;
9740
+ exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
9741
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
9742
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
9743
+
9744
+ var /*istanbul ignore start*/_line = require('../diff/line') /*istanbul ignore end*/;
9745
+
9746
+ /*istanbul ignore start*/
9747
+ 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); } }
9748
+
9749
+ /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
9750
+ if (!options) {
9751
+ options = {};
9752
+ }
9753
+ if (typeof options.context === 'undefined') {
9754
+ options.context = 4;
9755
+ }
9756
+
9757
+ var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
9758
+ diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
9759
+
9760
+ function contextLines(lines) {
9761
+ return lines.map(function (entry) {
9762
+ return ' ' + entry;
9763
+ });
9764
+ }
9765
+
9766
+ var hunks = [];
9767
+ var oldRangeStart = 0,
9768
+ newRangeStart = 0,
9769
+ curRange = [],
9770
+ oldLine = 1,
9771
+ newLine = 1;
9772
+ /*istanbul ignore start*/
9773
+ var _loop = function _loop( /*istanbul ignore end*/i) {
9774
+ var current = diff[i],
9775
+ lines = current.lines || current.value.replace(/\n$/, '').split('\n');
9776
+ current.lines = lines;
9777
+
9778
+ if (current.added || current.removed) {
9779
+ /*istanbul ignore start*/
9780
+ var _curRange;
9781
+
9782
+ /*istanbul ignore end*/
9783
+ // If we have previous context, start with that
9784
+ if (!oldRangeStart) {
9785
+ var prev = diff[i - 1];
9786
+ oldRangeStart = oldLine;
9787
+ newRangeStart = newLine;
9788
+
9789
+ if (prev) {
9790
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
9791
+ oldRangeStart -= curRange.length;
9792
+ newRangeStart -= curRange.length;
9793
+ }
9794
+ }
9795
+
9796
+ // Output our changes
9797
+ /*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) {
9798
+ return (current.added ? '+' : '-') + entry;
9799
+ })));
9800
+
9801
+ // Track the updated file position
9802
+ if (current.added) {
9803
+ newLine += lines.length;
9804
+ } else {
9805
+ oldLine += lines.length;
9806
+ }
9807
+ } else {
9808
+ // Identical context lines. Track line changes
9809
+ if (oldRangeStart) {
9810
+ // Close out any changes that have been output (or join overlapping)
9811
+ if (lines.length <= options.context * 2 && i < diff.length - 2) {
9812
+ /*istanbul ignore start*/
9813
+ var _curRange2;
9814
+
9815
+ /*istanbul ignore end*/
9816
+ // Overlapping
9817
+ /*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)));
9524
9818
  } else {
9525
- operation = 0;
9819
+ /*istanbul ignore start*/
9820
+ var _curRange3;
9821
+
9822
+ /*istanbul ignore end*/
9823
+ // end the range and output
9824
+ var contextSize = Math.min(lines.length, options.context);
9825
+ /*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))));
9826
+
9827
+ var hunk = {
9828
+ oldStart: oldRangeStart,
9829
+ oldLines: oldLine - oldRangeStart + contextSize,
9830
+ newStart: newRangeStart,
9831
+ newLines: newLine - newRangeStart + contextSize,
9832
+ lines: curRange
9833
+ };
9834
+ if (i >= diff.length - 2 && lines.length <= options.context) {
9835
+ // EOF is inside this hunk
9836
+ var oldEOFNewline = /\n$/.test(oldStr);
9837
+ var newEOFNewline = /\n$/.test(newStr);
9838
+ if (lines.length == 0 && !oldEOFNewline) {
9839
+ // special case: old has no eol and no trailing context; no-nl can end up before adds
9840
+ curRange.splice(hunk.oldLines, 0, '\');
9841
+ } else if (!oldEOFNewline || !newEOFNewline) {
9842
+ curRange.push('\');
9843
+ }
9844
+ }
9845
+ hunks.push(hunk);
9846
+
9847
+ oldRangeStart = 0;
9848
+ newRangeStart = 0;
9849
+ curRange = [];
9526
9850
  }
9851
+ }
9852
+ oldLine += lines.length;
9853
+ newLine += lines.length;
9854
+ }
9855
+ };
9856
+
9857
+ for (var i = 0; i < diff.length; i++) {
9858
+ /*istanbul ignore start*/
9859
+ _loop( /*istanbul ignore end*/i);
9860
+ }
9861
+
9862
+ return {
9863
+ oldFileName: oldFileName, newFileName: newFileName,
9864
+ oldHeader: oldHeader, newHeader: newHeader,
9865
+ hunks: hunks
9866
+ };
9867
+ }
9868
+
9869
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
9870
+ var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
9871
+
9872
+ var ret = [];
9873
+ if (oldFileName == newFileName) {
9874
+ ret.push('Index: ' + oldFileName);
9875
+ }
9876
+ ret.push('===================================================================');
9877
+ ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
9878
+ ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
9879
+
9880
+ for (var i = 0; i < diff.hunks.length; i++) {
9881
+ var hunk = diff.hunks[i];
9882
+ ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
9883
+ ret.push.apply(ret, hunk.lines);
9884
+ }
9527
9885
 
9528
- ret.push([operation, change.value]);
9886
+ return ret.join('\n') + '\n';
9887
+ }
9888
+
9889
+ function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
9890
+ return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
9891
+ }
9892
+
9893
+
9894
+ },{"../diff/line":52}],58:[function(require,module,exports){
9895
+ /*istanbul ignore start*/'use strict';
9896
+
9897
+ exports.__esModule = true;
9898
+ exports. /*istanbul ignore end*/parsePatch = parsePatch;
9899
+ function parsePatch(uniDiff) {
9900
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
9901
+
9902
+ var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
9903
+ delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
9904
+ list = [],
9905
+ i = 0;
9906
+
9907
+ function parseIndex() {
9908
+ var index = {};
9909
+ list.push(index);
9910
+
9911
+ // Parse diff metadata
9912
+ while (i < diffstr.length) {
9913
+ var line = diffstr[i];
9914
+
9915
+ // File header found, end parsing diff metadata
9916
+ if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
9917
+ break;
9529
9918
  }
9530
- return ret;
9531
- },
9532
9919
 
9533
- canonicalize: canonicalize
9920
+ // Diff index
9921
+ var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
9922
+ if (header) {
9923
+ index.index = header[1];
9924
+ }
9925
+
9926
+ i++;
9927
+ }
9928
+
9929
+ // Parse file headers if they are defined. Unified diff requires them, but
9930
+ // there's no technical issues to have an isolated hunk without file header
9931
+ parseFileHeader(index);
9932
+ parseFileHeader(index);
9933
+
9934
+ // Parse hunks
9935
+ index.hunks = [];
9936
+
9937
+ while (i < diffstr.length) {
9938
+ var _line = diffstr[i];
9939
+
9940
+ if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
9941
+ break;
9942
+ } else if (/^@@/.test(_line)) {
9943
+ index.hunks.push(parseHunk());
9944
+ } else if (_line && options.strict) {
9945
+ // Ignore unexpected content unless in strict mode
9946
+ throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
9947
+ } else {
9948
+ i++;
9949
+ }
9950
+ }
9951
+ }
9952
+
9953
+ // Parses the --- and +++ headers, if none are found, no lines
9954
+ // are consumed.
9955
+ function parseFileHeader(index) {
9956
+ var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
9957
+ var fileHeader = headerPattern.exec(diffstr[i]);
9958
+ if (fileHeader) {
9959
+ var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
9960
+ index[keyPrefix + 'FileName'] = fileHeader[2];
9961
+ index[keyPrefix + 'Header'] = fileHeader[3];
9962
+
9963
+ i++;
9964
+ }
9965
+ }
9966
+
9967
+ // Parses a hunk
9968
+ // This assumes that we are at the start of a hunk.
9969
+ function parseHunk() {
9970
+ var chunkHeaderIndex = i,
9971
+ chunkHeaderLine = diffstr[i++],
9972
+ chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
9973
+
9974
+ var hunk = {
9975
+ oldStart: +chunkHeader[1],
9976
+ oldLines: +chunkHeader[2] || 1,
9977
+ newStart: +chunkHeader[3],
9978
+ newLines: +chunkHeader[4] || 1,
9979
+ lines: [],
9980
+ linedelimiters: []
9981
+ };
9982
+
9983
+ var addCount = 0,
9984
+ removeCount = 0;
9985
+ for (; i < diffstr.length; i++) {
9986
+ // Lines starting with '---' could be mistaken for the "remove line" operation
9987
+ // But they could be the header for the next file. Therefore prune such cases out.
9988
+ if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
9989
+ break;
9990
+ }
9991
+ var operation = diffstr[i][0];
9992
+
9993
+ if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
9994
+ hunk.lines.push(diffstr[i]);
9995
+ hunk.linedelimiters.push(delimiters[i] || '\n');
9996
+
9997
+ if (operation === '+') {
9998
+ addCount++;
9999
+ } else if (operation === '-') {
10000
+ removeCount++;
10001
+ } else if (operation === ' ') {
10002
+ addCount++;
10003
+ removeCount++;
10004
+ }
10005
+ } else {
10006
+ break;
10007
+ }
10008
+ }
10009
+
10010
+ // Handle the empty block count case
10011
+ if (!addCount && hunk.newLines === 1) {
10012
+ hunk.newLines = 0;
10013
+ }
10014
+ if (!removeCount && hunk.oldLines === 1) {
10015
+ hunk.oldLines = 0;
10016
+ }
10017
+
10018
+ // Perform optional sanity checking
10019
+ if (options.strict) {
10020
+ if (addCount !== hunk.newLines) {
10021
+ throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
10022
+ }
10023
+ if (removeCount !== hunk.oldLines) {
10024
+ throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
10025
+ }
10026
+ }
10027
+
10028
+ return hunk;
10029
+ }
10030
+
10031
+ while (i < diffstr.length) {
10032
+ parseIndex();
10033
+ }
10034
+
10035
+ return list;
10036
+ }
10037
+
10038
+
10039
+ },{}],59:[function(require,module,exports){
10040
+ /*istanbul ignore start*/"use strict";
10041
+
10042
+ exports.__esModule = true;
10043
+
10044
+ exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
10045
+ var wantForward = true,
10046
+ backwardExhausted = false,
10047
+ forwardExhausted = false,
10048
+ localOffset = 1;
10049
+
10050
+ return function iterator() {
10051
+ if (wantForward && !forwardExhausted) {
10052
+ if (backwardExhausted) {
10053
+ localOffset++;
10054
+ } else {
10055
+ wantForward = false;
10056
+ }
10057
+
10058
+ // Check if trying to fit beyond text length, and if not, check it fits
10059
+ // after offset location (or desired location on first iteration)
10060
+ if (start + localOffset <= maxLine) {
10061
+ return localOffset;
10062
+ }
10063
+
10064
+ forwardExhausted = true;
10065
+ }
10066
+
10067
+ if (!backwardExhausted) {
10068
+ if (!forwardExhausted) {
10069
+ wantForward = true;
10070
+ }
10071
+
10072
+ // Check if trying to fit before text beginning, and if not, check it fits
10073
+ // before offset location
10074
+ if (minLine <= start - localOffset) {
10075
+ return -localOffset++;
10076
+ }
10077
+
10078
+ backwardExhausted = true;
10079
+ return iterator();
10080
+ }
10081
+
10082
+ // We tried to fit hunk before text beginning and beyond text lenght, then
10083
+ // hunk can't fit on the text. Return undefined
9534
10084
  };
10085
+ };
9535
10086
 
9536
- /*istanbul ignore next */
9537
- /*global module */
9538
- if (typeof module !== 'undefined' && module.exports) {
9539
- module.exports = JsDiff;
9540
- } else if (false) {
9541
- /*global define */
9542
- define([], function() { return JsDiff; });
9543
- } else if (typeof global.JsDiff === 'undefined') {
9544
- global.JsDiff = JsDiff;
10087
+
10088
+ },{}],60:[function(require,module,exports){
10089
+ /*istanbul ignore start*/'use strict';
10090
+
10091
+ exports.__esModule = true;
10092
+ exports. /*istanbul ignore end*/generateOptions = generateOptions;
10093
+ function generateOptions(options, defaults) {
10094
+ if (typeof options === 'function') {
10095
+ defaults.callback = options;
10096
+ } else if (options) {
10097
+ for (var name in options) {
10098
+ /* istanbul ignore else */
10099
+ if (options.hasOwnProperty(name)) {
10100
+ defaults[name] = options[name];
10101
+ }
10102
+ }
9545
10103
  }
9546
- }(this));
10104
+ return defaults;
10105
+ }
9547
10106
 
9548
- },{}],47:[function(require,module,exports){
10107
+
10108
+ },{}],61:[function(require,module,exports){
9549
10109
  'use strict';
9550
10110
 
9551
10111
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
@@ -9558,7 +10118,7 @@ module.exports = function (str) {
9558
10118
  return str.replace(matchOperatorsRe, '\\$&');
9559
10119
  };
9560
10120
 
9561
- },{}],48:[function(require,module,exports){
10121
+ },{}],62:[function(require,module,exports){
9562
10122
  // Copyright Joyent, Inc. and other Node contributors.
9563
10123
  //
9564
10124
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -9862,7 +10422,7 @@ function isUndefined(arg) {
9862
10422
  return arg === void 0;
9863
10423
  }
9864
10424
 
9865
- },{}],49:[function(require,module,exports){
10425
+ },{}],63:[function(require,module,exports){
9866
10426
  (function (process){
9867
10427
  // Growl - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
9868
10428
 
@@ -10156,7 +10716,7 @@ function growl(msg, options, fn) {
10156
10716
  };
10157
10717
 
10158
10718
  }).call(this,require('_process'))
10159
- },{"_process":67,"child_process":42,"fs":42,"os":65,"path":42}],50:[function(require,module,exports){
10719
+ },{"_process":81,"child_process":42,"fs":42,"os":79,"path":42}],64:[function(require,module,exports){
10160
10720
  exports.read = function (buffer, offset, isLE, mLen, nBytes) {
10161
10721
  var e, m
10162
10722
  var eLen = nBytes * 8 - mLen - 1
@@ -10242,7 +10802,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
10242
10802
  buffer[offset + i - d] |= s * 128
10243
10803
  }
10244
10804
 
10245
- },{}],51:[function(require,module,exports){
10805
+ },{}],65:[function(require,module,exports){
10246
10806
  if (typeof Object.create === 'function') {
10247
10807
  // implementation from standard node.js 'util' module
10248
10808
  module.exports = function inherits(ctor, superCtor) {
@@ -10267,7 +10827,7 @@ if (typeof Object.create === 'function') {
10267
10827
  }
10268
10828
  }
10269
10829
 
10270
- },{}],52:[function(require,module,exports){
10830
+ },{}],66:[function(require,module,exports){
10271
10831
  /*!
10272
10832
  * Determine if an object is a Buffer
10273
10833
  *
@@ -10290,14 +10850,14 @@ function isSlowBuffer (obj) {
10290
10850
  return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
10291
10851
  }
10292
10852
 
10293
- },{}],53:[function(require,module,exports){
10853
+ },{}],67:[function(require,module,exports){
10294
10854
  var toString = {}.toString;
10295
10855
 
10296
10856
  module.exports = Array.isArray || function (arr) {
10297
10857
  return toString.call(arr) == '[object Array]';
10298
10858
  };
10299
10859
 
10300
- },{}],54:[function(require,module,exports){
10860
+ },{}],68:[function(require,module,exports){
10301
10861
  (function (global){
10302
10862
  /*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
10303
10863
  ;(function () {
@@ -11203,7 +11763,64 @@ module.exports = Array.isArray || function (arr) {
11203
11763
  }).call(this);
11204
11764
 
11205
11765
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11206
- },{}],55:[function(require,module,exports){
11766
+ },{}],69:[function(require,module,exports){
11767
+ /**
11768
+ * lodash 3.1.1 (Custom Build) <https://lodash.com/>
11769
+ * Build: `lodash modern modularize exports="npm" -o ./`
11770
+ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
11771
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
11772
+ * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11773
+ * Available under MIT license <https://lodash.com/license>
11774
+ */
11775
+ var baseAssign = require('lodash._baseassign'),
11776
+ baseCreate = require('lodash._basecreate'),
11777
+ isIterateeCall = require('lodash._isiterateecall');
11778
+
11779
+ /**
11780
+ * Creates an object that inherits from the given `prototype` object. If a
11781
+ * `properties` object is provided its own enumerable properties are assigned
11782
+ * to the created object.
11783
+ *
11784
+ * @static
11785
+ * @memberOf _
11786
+ * @category Object
11787
+ * @param {Object} prototype The object to inherit from.
11788
+ * @param {Object} [properties] The properties to assign to the object.
11789
+ * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
11790
+ * @returns {Object} Returns the new object.
11791
+ * @example
11792
+ *
11793
+ * function Shape() {
11794
+ * this.x = 0;
11795
+ * this.y = 0;
11796
+ * }
11797
+ *
11798
+ * function Circle() {
11799
+ * Shape.call(this);
11800
+ * }
11801
+ *
11802
+ * Circle.prototype = _.create(Shape.prototype, {
11803
+ * 'constructor': Circle
11804
+ * });
11805
+ *
11806
+ * var circle = new Circle;
11807
+ * circle instanceof Circle;
11808
+ * // => true
11809
+ *
11810
+ * circle instanceof Shape;
11811
+ * // => true
11812
+ */
11813
+ function create(prototype, properties, guard) {
11814
+ var result = baseCreate(prototype);
11815
+ if (guard && isIterateeCall(prototype, properties, guard)) {
11816
+ properties = undefined;
11817
+ }
11818
+ return properties ? baseAssign(result, properties) : result;
11819
+ }
11820
+
11821
+ module.exports = create;
11822
+
11823
+ },{"lodash._baseassign":70,"lodash._basecreate":76,"lodash._isiterateecall":77}],70:[function(require,module,exports){
11207
11824
  /**
11208
11825
  * lodash 3.2.0 (Custom Build) <https://lodash.com/>
11209
11826
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11232,7 +11849,7 @@ function baseAssign(object, source) {
11232
11849
 
11233
11850
  module.exports = baseAssign;
11234
11851
 
11235
- },{"lodash._basecopy":56,"lodash.keys":63}],56:[function(require,module,exports){
11852
+ },{"lodash._basecopy":71,"lodash.keys":72}],71:[function(require,module,exports){
11236
11853
  /**
11237
11854
  * lodash 3.0.1 (Custom Build) <https://lodash.com/>
11238
11855
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11266,147 +11883,126 @@ function baseCopy(source, props, object) {
11266
11883
 
11267
11884
  module.exports = baseCopy;
11268
11885
 
11269
- },{}],57:[function(require,module,exports){
11270
- /**
11271
- * lodash 3.0.3 (Custom Build) <https://lodash.com/>
11272
- * Build: `lodash modern modularize exports="npm" -o ./`
11273
- * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
11274
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
11275
- * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11276
- * Available under MIT license <https://lodash.com/license>
11277
- */
11278
-
11279
- /**
11280
- * The base implementation of `_.create` without support for assigning
11281
- * properties to the created object.
11282
- *
11283
- * @private
11284
- * @param {Object} prototype The object to inherit from.
11285
- * @returns {Object} Returns the new object.
11286
- */
11287
- var baseCreate = (function() {
11288
- function object() {}
11289
- return function(prototype) {
11290
- if (isObject(prototype)) {
11291
- object.prototype = prototype;
11292
- var result = new object;
11293
- object.prototype = undefined;
11294
- }
11295
- return result || {};
11296
- };
11297
- }());
11298
-
11886
+ },{}],72:[function(require,module,exports){
11299
11887
  /**
11300
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
11301
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11302
- *
11303
- * @static
11304
- * @memberOf _
11305
- * @category Lang
11306
- * @param {*} value The value to check.
11307
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11308
- * @example
11309
- *
11310
- * _.isObject({});
11311
- * // => true
11312
- *
11313
- * _.isObject([1, 2, 3]);
11314
- * // => true
11315
- *
11316
- * _.isObject(1);
11317
- * // => false
11318
- */
11319
- function isObject(value) {
11320
- // Avoid a V8 JIT bug in Chrome 19-20.
11321
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
11322
- var type = typeof value;
11323
- return !!value && (type == 'object' || type == 'function');
11324
- }
11325
-
11326
- module.exports = baseCreate;
11327
-
11328
- },{}],58:[function(require,module,exports){
11329
- /**
11330
- * lodash 3.9.1 (Custom Build) <https://lodash.com/>
11888
+ * lodash 3.1.2 (Custom Build) <https://lodash.com/>
11331
11889
  * Build: `lodash modern modularize exports="npm" -o ./`
11332
11890
  * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
11333
11891
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
11334
11892
  * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11335
11893
  * Available under MIT license <https://lodash.com/license>
11336
11894
  */
11895
+ var getNative = require('lodash._getnative'),
11896
+ isArguments = require('lodash.isarguments'),
11897
+ isArray = require('lodash.isarray');
11337
11898
 
11338
- /** `Object#toString` result references. */
11339
- var funcTag = '[object Function]';
11340
-
11341
- /** Used to detect host constructors (Safari > 5). */
11342
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
11343
-
11344
- /**
11345
- * Checks if `value` is object-like.
11346
- *
11347
- * @private
11348
- * @param {*} value The value to check.
11349
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11350
- */
11351
- function isObjectLike(value) {
11352
- return !!value && typeof value == 'object';
11353
- }
11899
+ /** Used to detect unsigned integer values. */
11900
+ var reIsUint = /^\d+$/;
11354
11901
 
11355
11902
  /** Used for native method references. */
11356
11903
  var objectProto = Object.prototype;
11357
11904
 
11358
- /** Used to resolve the decompiled source of functions. */
11359
- var fnToString = Function.prototype.toString;
11360
-
11361
11905
  /** Used to check objects for own properties. */
11362
11906
  var hasOwnProperty = objectProto.hasOwnProperty;
11363
11907
 
11908
+ /* Native method references for those with the same name as other `lodash` methods. */
11909
+ var nativeKeys = getNative(Object, 'keys');
11910
+
11364
11911
  /**
11365
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
11366
- * of values.
11912
+ * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
11913
+ * of an array-like value.
11367
11914
  */
11368
- var objToString = objectProto.toString;
11915
+ var MAX_SAFE_INTEGER = 9007199254740991;
11369
11916
 
11370
- /** Used to detect if a method is native. */
11371
- var reIsNative = RegExp('^' +
11372
- fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
11373
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11374
- );
11917
+ /**
11918
+ * The base implementation of `_.property` without support for deep paths.
11919
+ *
11920
+ * @private
11921
+ * @param {string} key The key of the property to get.
11922
+ * @returns {Function} Returns the new function.
11923
+ */
11924
+ function baseProperty(key) {
11925
+ return function(object) {
11926
+ return object == null ? undefined : object[key];
11927
+ };
11928
+ }
11375
11929
 
11376
11930
  /**
11377
- * Gets the native function at `key` of `object`.
11931
+ * Gets the "length" property value of `object`.
11932
+ *
11933
+ * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
11934
+ * that affects Safari on at least iOS 8.1-8.3 ARM64.
11378
11935
  *
11379
11936
  * @private
11380
11937
  * @param {Object} object The object to query.
11381
- * @param {string} key The key of the method to get.
11382
- * @returns {*} Returns the function if it's native, else `undefined`.
11938
+ * @returns {*} Returns the "length" value.
11383
11939
  */
11384
- function getNative(object, key) {
11385
- var value = object == null ? undefined : object[key];
11386
- return isNative(value) ? value : undefined;
11940
+ var getLength = baseProperty('length');
11941
+
11942
+ /**
11943
+ * Checks if `value` is array-like.
11944
+ *
11945
+ * @private
11946
+ * @param {*} value The value to check.
11947
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11948
+ */
11949
+ function isArrayLike(value) {
11950
+ return value != null && isLength(getLength(value));
11387
11951
  }
11388
11952
 
11389
11953
  /**
11390
- * Checks if `value` is classified as a `Function` object.
11954
+ * Checks if `value` is a valid array-like index.
11391
11955
  *
11392
- * @static
11393
- * @memberOf _
11394
- * @category Lang
11956
+ * @private
11395
11957
  * @param {*} value The value to check.
11396
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
11397
- * @example
11958
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
11959
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
11960
+ */
11961
+ function isIndex(value, length) {
11962
+ value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
11963
+ length = length == null ? MAX_SAFE_INTEGER : length;
11964
+ return value > -1 && value % 1 == 0 && value < length;
11965
+ }
11966
+
11967
+ /**
11968
+ * Checks if `value` is a valid array-like length.
11398
11969
  *
11399
- * _.isFunction(_);
11400
- * // => true
11970
+ * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
11401
11971
  *
11402
- * _.isFunction(/abc/);
11403
- * // => false
11972
+ * @private
11973
+ * @param {*} value The value to check.
11974
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
11404
11975
  */
11405
- function isFunction(value) {
11406
- // The use of `Object#toString` avoids issues with the `typeof` operator
11407
- // in older versions of Chrome and Safari which return 'function' for regexes
11408
- // and Safari 8 equivalents which return 'object' for typed array constructors.
11409
- return isObject(value) && objToString.call(value) == funcTag;
11976
+ function isLength(value) {
11977
+ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
11978
+ }
11979
+
11980
+ /**
11981
+ * A fallback implementation of `Object.keys` which creates an array of the
11982
+ * own enumerable property names of `object`.
11983
+ *
11984
+ * @private
11985
+ * @param {Object} object The object to query.
11986
+ * @returns {Array} Returns the array of property names.
11987
+ */
11988
+ function shimKeys(object) {
11989
+ var props = keysIn(object),
11990
+ propsLength = props.length,
11991
+ length = propsLength && object.length;
11992
+
11993
+ var allowIndexes = !!length && isLength(length) &&
11994
+ (isArray(object) || isArguments(object));
11995
+
11996
+ var index = -1,
11997
+ result = [];
11998
+
11999
+ while (++index < propsLength) {
12000
+ var key = props[index];
12001
+ if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
12002
+ result.push(key);
12003
+ }
12004
+ }
12005
+ return result;
11410
12006
  }
11411
12007
 
11412
12008
  /**
@@ -11437,36 +12033,97 @@ function isObject(value) {
11437
12033
  }
11438
12034
 
11439
12035
  /**
11440
- * Checks if `value` is a native function.
12036
+ * Creates an array of the own enumerable property names of `object`.
12037
+ *
12038
+ * **Note:** Non-object values are coerced to objects. See the
12039
+ * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
12040
+ * for more details.
11441
12041
  *
11442
12042
  * @static
11443
12043
  * @memberOf _
11444
- * @category Lang
11445
- * @param {*} value The value to check.
11446
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
12044
+ * @category Object
12045
+ * @param {Object} object The object to query.
12046
+ * @returns {Array} Returns the array of property names.
11447
12047
  * @example
11448
12048
  *
11449
- * _.isNative(Array.prototype.push);
11450
- * // => true
12049
+ * function Foo() {
12050
+ * this.a = 1;
12051
+ * this.b = 2;
12052
+ * }
11451
12053
  *
11452
- * _.isNative(_);
11453
- * // => false
12054
+ * Foo.prototype.c = 3;
12055
+ *
12056
+ * _.keys(new Foo);
12057
+ * // => ['a', 'b'] (iteration order is not guaranteed)
12058
+ *
12059
+ * _.keys('hi');
12060
+ * // => ['0', '1']
11454
12061
  */
11455
- function isNative(value) {
11456
- if (value == null) {
11457
- return false;
12062
+ var keys = !nativeKeys ? shimKeys : function(object) {
12063
+ var Ctor = object == null ? undefined : object.constructor;
12064
+ if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
12065
+ (typeof object != 'function' && isArrayLike(object))) {
12066
+ return shimKeys(object);
11458
12067
  }
11459
- if (isFunction(value)) {
11460
- return reIsNative.test(fnToString.call(value));
12068
+ return isObject(object) ? nativeKeys(object) : [];
12069
+ };
12070
+
12071
+ /**
12072
+ * Creates an array of the own and inherited enumerable property names of `object`.
12073
+ *
12074
+ * **Note:** Non-object values are coerced to objects.
12075
+ *
12076
+ * @static
12077
+ * @memberOf _
12078
+ * @category Object
12079
+ * @param {Object} object The object to query.
12080
+ * @returns {Array} Returns the array of property names.
12081
+ * @example
12082
+ *
12083
+ * function Foo() {
12084
+ * this.a = 1;
12085
+ * this.b = 2;
12086
+ * }
12087
+ *
12088
+ * Foo.prototype.c = 3;
12089
+ *
12090
+ * _.keysIn(new Foo);
12091
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12092
+ */
12093
+ function keysIn(object) {
12094
+ if (object == null) {
12095
+ return [];
11461
12096
  }
11462
- return isObjectLike(value) && reIsHostCtor.test(value);
12097
+ if (!isObject(object)) {
12098
+ object = Object(object);
12099
+ }
12100
+ var length = object.length;
12101
+ length = (length && isLength(length) &&
12102
+ (isArray(object) || isArguments(object)) && length) || 0;
12103
+
12104
+ var Ctor = object.constructor,
12105
+ index = -1,
12106
+ isProto = typeof Ctor == 'function' && Ctor.prototype === object,
12107
+ result = Array(length),
12108
+ skipIndexes = length > 0;
12109
+
12110
+ while (++index < length) {
12111
+ result[index] = (index + '');
12112
+ }
12113
+ for (var key in object) {
12114
+ if (!(skipIndexes && isIndex(key, length)) &&
12115
+ !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
12116
+ result.push(key);
12117
+ }
12118
+ }
12119
+ return result;
11463
12120
  }
11464
12121
 
11465
- module.exports = getNative;
12122
+ module.exports = keys;
11466
12123
 
11467
- },{}],59:[function(require,module,exports){
12124
+ },{"lodash._getnative":73,"lodash.isarguments":74,"lodash.isarray":75}],73:[function(require,module,exports){
11468
12125
  /**
11469
- * lodash 3.0.9 (Custom Build) <https://lodash.com/>
12126
+ * lodash 3.9.1 (Custom Build) <https://lodash.com/>
11470
12127
  * Build: `lodash modern modularize exports="npm" -o ./`
11471
12128
  * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
11472
12129
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@@ -11474,99 +12131,78 @@ module.exports = getNative;
11474
12131
  * Available under MIT license <https://lodash.com/license>
11475
12132
  */
11476
12133
 
11477
- /** Used to detect unsigned integer values. */
11478
- var reIsUint = /^\d+$/;
12134
+ /** `Object#toString` result references. */
12135
+ var funcTag = '[object Function]';
11479
12136
 
11480
- /**
11481
- * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
11482
- * of an array-like value.
11483
- */
11484
- var MAX_SAFE_INTEGER = 9007199254740991;
12137
+ /** Used to detect host constructors (Safari > 5). */
12138
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
11485
12139
 
11486
12140
  /**
11487
- * The base implementation of `_.property` without support for deep paths.
12141
+ * Checks if `value` is object-like.
11488
12142
  *
11489
12143
  * @private
11490
- * @param {string} key The key of the property to get.
11491
- * @returns {Function} Returns the new function.
12144
+ * @param {*} value The value to check.
12145
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
11492
12146
  */
11493
- function baseProperty(key) {
11494
- return function(object) {
11495
- return object == null ? undefined : object[key];
11496
- };
12147
+ function isObjectLike(value) {
12148
+ return !!value && typeof value == 'object';
11497
12149
  }
11498
12150
 
11499
- /**
11500
- * Gets the "length" property value of `object`.
11501
- *
11502
- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
11503
- * that affects Safari on at least iOS 8.1-8.3 ARM64.
11504
- *
11505
- * @private
11506
- * @param {Object} object The object to query.
11507
- * @returns {*} Returns the "length" value.
11508
- */
11509
- var getLength = baseProperty('length');
12151
+ /** Used for native method references. */
12152
+ var objectProto = Object.prototype;
11510
12153
 
11511
- /**
11512
- * Checks if `value` is array-like.
11513
- *
11514
- * @private
11515
- * @param {*} value The value to check.
11516
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
11517
- */
11518
- function isArrayLike(value) {
11519
- return value != null && isLength(getLength(value));
11520
- }
12154
+ /** Used to resolve the decompiled source of functions. */
12155
+ var fnToString = Function.prototype.toString;
12156
+
12157
+ /** Used to check objects for own properties. */
12158
+ var hasOwnProperty = objectProto.hasOwnProperty;
11521
12159
 
11522
12160
  /**
11523
- * Checks if `value` is a valid array-like index.
11524
- *
11525
- * @private
11526
- * @param {*} value The value to check.
11527
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
11528
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
12161
+ * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
12162
+ * of values.
11529
12163
  */
11530
- function isIndex(value, length) {
11531
- value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
11532
- length = length == null ? MAX_SAFE_INTEGER : length;
11533
- return value > -1 && value % 1 == 0 && value < length;
11534
- }
12164
+ var objToString = objectProto.toString;
12165
+
12166
+ /** Used to detect if a method is native. */
12167
+ var reIsNative = RegExp('^' +
12168
+ fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
12169
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
12170
+ );
11535
12171
 
11536
12172
  /**
11537
- * Checks if the provided arguments are from an iteratee call.
12173
+ * Gets the native function at `key` of `object`.
11538
12174
  *
11539
12175
  * @private
11540
- * @param {*} value The potential iteratee value argument.
11541
- * @param {*} index The potential iteratee index or key argument.
11542
- * @param {*} object The potential iteratee object argument.
11543
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
12176
+ * @param {Object} object The object to query.
12177
+ * @param {string} key The key of the method to get.
12178
+ * @returns {*} Returns the function if it's native, else `undefined`.
11544
12179
  */
11545
- function isIterateeCall(value, index, object) {
11546
- if (!isObject(object)) {
11547
- return false;
11548
- }
11549
- var type = typeof index;
11550
- if (type == 'number'
11551
- ? (isArrayLike(object) && isIndex(index, object.length))
11552
- : (type == 'string' && index in object)) {
11553
- var other = object[index];
11554
- return value === value ? (value === other) : (other !== other);
11555
- }
11556
- return false;
12180
+ function getNative(object, key) {
12181
+ var value = object == null ? undefined : object[key];
12182
+ return isNative(value) ? value : undefined;
11557
12183
  }
11558
12184
 
11559
12185
  /**
11560
- * Checks if `value` is a valid array-like length.
11561
- *
11562
- * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
12186
+ * Checks if `value` is classified as a `Function` object.
11563
12187
  *
11564
- * @private
12188
+ * @static
12189
+ * @memberOf _
12190
+ * @category Lang
11565
12191
  * @param {*} value The value to check.
11566
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12192
+ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
12193
+ * @example
12194
+ *
12195
+ * _.isFunction(_);
12196
+ * // => true
12197
+ *
12198
+ * _.isFunction(/abc/);
12199
+ * // => false
11567
12200
  */
11568
- function isLength(value) {
11569
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
12201
+ function isFunction(value) {
12202
+ // The use of `Object#toString` avoids issues with the `typeof` operator
12203
+ // in older versions of Chrome and Safari which return 'function' for regexes
12204
+ // and Safari 8 equivalents which return 'object' for typed array constructors.
12205
+ return isObject(value) && objToString.call(value) == funcTag;
11570
12206
  }
11571
12207
 
11572
12208
  /**
@@ -11596,66 +12232,35 @@ function isObject(value) {
11596
12232
  return !!value && (type == 'object' || type == 'function');
11597
12233
  }
11598
12234
 
11599
- module.exports = isIterateeCall;
11600
-
11601
- },{}],60:[function(require,module,exports){
11602
- /**
11603
- * lodash 3.1.1 (Custom Build) <https://lodash.com/>
11604
- * Build: `lodash modern modularize exports="npm" -o ./`
11605
- * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
11606
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
11607
- * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
11608
- * Available under MIT license <https://lodash.com/license>
11609
- */
11610
- var baseAssign = require('lodash._baseassign'),
11611
- baseCreate = require('lodash._basecreate'),
11612
- isIterateeCall = require('lodash._isiterateecall');
11613
-
11614
12235
  /**
11615
- * Creates an object that inherits from the given `prototype` object. If a
11616
- * `properties` object is provided its own enumerable properties are assigned
11617
- * to the created object.
12236
+ * Checks if `value` is a native function.
11618
12237
  *
11619
12238
  * @static
11620
12239
  * @memberOf _
11621
- * @category Object
11622
- * @param {Object} prototype The object to inherit from.
11623
- * @param {Object} [properties] The properties to assign to the object.
11624
- * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
11625
- * @returns {Object} Returns the new object.
12240
+ * @category Lang
12241
+ * @param {*} value The value to check.
12242
+ * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
11626
12243
  * @example
11627
12244
  *
11628
- * function Shape() {
11629
- * this.x = 0;
11630
- * this.y = 0;
11631
- * }
11632
- *
11633
- * function Circle() {
11634
- * Shape.call(this);
11635
- * }
11636
- *
11637
- * Circle.prototype = _.create(Shape.prototype, {
11638
- * 'constructor': Circle
11639
- * });
11640
- *
11641
- * var circle = new Circle;
11642
- * circle instanceof Circle;
12245
+ * _.isNative(Array.prototype.push);
11643
12246
  * // => true
11644
12247
  *
11645
- * circle instanceof Shape;
11646
- * // => true
12248
+ * _.isNative(_);
12249
+ * // => false
11647
12250
  */
11648
- function create(prototype, properties, guard) {
11649
- var result = baseCreate(prototype);
11650
- if (guard && isIterateeCall(prototype, properties, guard)) {
11651
- properties = undefined;
12251
+ function isNative(value) {
12252
+ if (value == null) {
12253
+ return false;
11652
12254
  }
11653
- return properties ? baseAssign(result, properties) : result;
12255
+ if (isFunction(value)) {
12256
+ return reIsNative.test(fnToString.call(value));
12257
+ }
12258
+ return isObjectLike(value) && reIsHostCtor.test(value);
11654
12259
  }
11655
12260
 
11656
- module.exports = create;
12261
+ module.exports = getNative;
11657
12262
 
11658
- },{"lodash._baseassign":55,"lodash._basecreate":57,"lodash._isiterateecall":59}],61:[function(require,module,exports){
12263
+ },{}],74:[function(require,module,exports){
11659
12264
  /**
11660
12265
  * lodash (Custom Build) <https://lodash.com/>
11661
12266
  * Build: `lodash modularize exports="npm" -o ./`
@@ -11886,7 +12491,7 @@ function isObjectLike(value) {
11886
12491
 
11887
12492
  module.exports = isArguments;
11888
12493
 
11889
- },{}],62:[function(require,module,exports){
12494
+ },{}],75:[function(require,module,exports){
11890
12495
  /**
11891
12496
  * lodash 3.0.4 (Custom Build) <https://lodash.com/>
11892
12497
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -12068,33 +12673,80 @@ function isNative(value) {
12068
12673
 
12069
12674
  module.exports = isArray;
12070
12675
 
12071
- },{}],63:[function(require,module,exports){
12676
+ },{}],76:[function(require,module,exports){
12072
12677
  /**
12073
- * lodash 3.1.2 (Custom Build) <https://lodash.com/>
12678
+ * lodash 3.0.3 (Custom Build) <https://lodash.com/>
12074
12679
  * Build: `lodash modern modularize exports="npm" -o ./`
12075
12680
  * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
12076
12681
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
12077
12682
  * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12078
12683
  * Available under MIT license <https://lodash.com/license>
12079
12684
  */
12080
- var getNative = require('lodash._getnative'),
12081
- isArguments = require('lodash.isarguments'),
12082
- isArray = require('lodash.isarray');
12083
12685
 
12084
- /** Used to detect unsigned integer values. */
12085
- var reIsUint = /^\d+$/;
12686
+ /**
12687
+ * The base implementation of `_.create` without support for assigning
12688
+ * properties to the created object.
12689
+ *
12690
+ * @private
12691
+ * @param {Object} prototype The object to inherit from.
12692
+ * @returns {Object} Returns the new object.
12693
+ */
12694
+ var baseCreate = (function() {
12695
+ function object() {}
12696
+ return function(prototype) {
12697
+ if (isObject(prototype)) {
12698
+ object.prototype = prototype;
12699
+ var result = new object;
12700
+ object.prototype = undefined;
12701
+ }
12702
+ return result || {};
12703
+ };
12704
+ }());
12086
12705
 
12087
- /** Used for native method references. */
12088
- var objectProto = Object.prototype;
12706
+ /**
12707
+ * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
12708
+ * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
12709
+ *
12710
+ * @static
12711
+ * @memberOf _
12712
+ * @category Lang
12713
+ * @param {*} value The value to check.
12714
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
12715
+ * @example
12716
+ *
12717
+ * _.isObject({});
12718
+ * // => true
12719
+ *
12720
+ * _.isObject([1, 2, 3]);
12721
+ * // => true
12722
+ *
12723
+ * _.isObject(1);
12724
+ * // => false
12725
+ */
12726
+ function isObject(value) {
12727
+ // Avoid a V8 JIT bug in Chrome 19-20.
12728
+ // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
12729
+ var type = typeof value;
12730
+ return !!value && (type == 'object' || type == 'function');
12731
+ }
12089
12732
 
12090
- /** Used to check objects for own properties. */
12091
- var hasOwnProperty = objectProto.hasOwnProperty;
12733
+ module.exports = baseCreate;
12092
12734
 
12093
- /* Native method references for those with the same name as other `lodash` methods. */
12094
- var nativeKeys = getNative(Object, 'keys');
12735
+ },{}],77:[function(require,module,exports){
12736
+ /**
12737
+ * lodash 3.0.9 (Custom Build) <https://lodash.com/>
12738
+ * Build: `lodash modern modularize exports="npm" -o ./`
12739
+ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
12740
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
12741
+ * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
12742
+ * Available under MIT license <https://lodash.com/license>
12743
+ */
12744
+
12745
+ /** Used to detect unsigned integer values. */
12746
+ var reIsUint = /^\d+$/;
12095
12747
 
12096
12748
  /**
12097
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
12749
+ * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
12098
12750
  * of an array-like value.
12099
12751
  */
12100
12752
  var MAX_SAFE_INTEGER = 9007199254740991;
@@ -12150,44 +12802,39 @@ function isIndex(value, length) {
12150
12802
  }
12151
12803
 
12152
12804
  /**
12153
- * Checks if `value` is a valid array-like length.
12154
- *
12155
- * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
12805
+ * Checks if the provided arguments are from an iteratee call.
12156
12806
  *
12157
12807
  * @private
12158
- * @param {*} value The value to check.
12159
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12808
+ * @param {*} value The potential iteratee value argument.
12809
+ * @param {*} index The potential iteratee index or key argument.
12810
+ * @param {*} object The potential iteratee object argument.
12811
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
12160
12812
  */
12161
- function isLength(value) {
12162
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
12813
+ function isIterateeCall(value, index, object) {
12814
+ if (!isObject(object)) {
12815
+ return false;
12816
+ }
12817
+ var type = typeof index;
12818
+ if (type == 'number'
12819
+ ? (isArrayLike(object) && isIndex(index, object.length))
12820
+ : (type == 'string' && index in object)) {
12821
+ var other = object[index];
12822
+ return value === value ? (value === other) : (other !== other);
12823
+ }
12824
+ return false;
12163
12825
  }
12164
12826
 
12165
12827
  /**
12166
- * A fallback implementation of `Object.keys` which creates an array of the
12167
- * own enumerable property names of `object`.
12828
+ * Checks if `value` is a valid array-like length.
12829
+ *
12830
+ * **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength).
12168
12831
  *
12169
12832
  * @private
12170
- * @param {Object} object The object to query.
12171
- * @returns {Array} Returns the array of property names.
12172
- */
12173
- function shimKeys(object) {
12174
- var props = keysIn(object),
12175
- propsLength = props.length,
12176
- length = propsLength && object.length;
12177
-
12178
- var allowIndexes = !!length && isLength(length) &&
12179
- (isArray(object) || isArguments(object));
12180
-
12181
- var index = -1,
12182
- result = [];
12183
-
12184
- while (++index < propsLength) {
12185
- var key = props[index];
12186
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
12187
- result.push(key);
12188
- }
12189
- }
12190
- return result;
12833
+ * @param {*} value The value to check.
12834
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12835
+ */
12836
+ function isLength(value) {
12837
+ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
12191
12838
  }
12192
12839
 
12193
12840
  /**
@@ -12217,96 +12864,9 @@ function isObject(value) {
12217
12864
  return !!value && (type == 'object' || type == 'function');
12218
12865
  }
12219
12866
 
12220
- /**
12221
- * Creates an array of the own enumerable property names of `object`.
12222
- *
12223
- * **Note:** Non-object values are coerced to objects. See the
12224
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
12225
- * for more details.
12226
- *
12227
- * @static
12228
- * @memberOf _
12229
- * @category Object
12230
- * @param {Object} object The object to query.
12231
- * @returns {Array} Returns the array of property names.
12232
- * @example
12233
- *
12234
- * function Foo() {
12235
- * this.a = 1;
12236
- * this.b = 2;
12237
- * }
12238
- *
12239
- * Foo.prototype.c = 3;
12240
- *
12241
- * _.keys(new Foo);
12242
- * // => ['a', 'b'] (iteration order is not guaranteed)
12243
- *
12244
- * _.keys('hi');
12245
- * // => ['0', '1']
12246
- */
12247
- var keys = !nativeKeys ? shimKeys : function(object) {
12248
- var Ctor = object == null ? undefined : object.constructor;
12249
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
12250
- (typeof object != 'function' && isArrayLike(object))) {
12251
- return shimKeys(object);
12252
- }
12253
- return isObject(object) ? nativeKeys(object) : [];
12254
- };
12255
-
12256
- /**
12257
- * Creates an array of the own and inherited enumerable property names of `object`.
12258
- *
12259
- * **Note:** Non-object values are coerced to objects.
12260
- *
12261
- * @static
12262
- * @memberOf _
12263
- * @category Object
12264
- * @param {Object} object The object to query.
12265
- * @returns {Array} Returns the array of property names.
12266
- * @example
12267
- *
12268
- * function Foo() {
12269
- * this.a = 1;
12270
- * this.b = 2;
12271
- * }
12272
- *
12273
- * Foo.prototype.c = 3;
12274
- *
12275
- * _.keysIn(new Foo);
12276
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12277
- */
12278
- function keysIn(object) {
12279
- if (object == null) {
12280
- return [];
12281
- }
12282
- if (!isObject(object)) {
12283
- object = Object(object);
12284
- }
12285
- var length = object.length;
12286
- length = (length && isLength(length) &&
12287
- (isArray(object) || isArguments(object)) && length) || 0;
12288
-
12289
- var Ctor = object.constructor,
12290
- index = -1,
12291
- isProto = typeof Ctor == 'function' && Ctor.prototype === object,
12292
- result = Array(length),
12293
- skipIndexes = length > 0;
12294
-
12295
- while (++index < length) {
12296
- result[index] = (index + '');
12297
- }
12298
- for (var key in object) {
12299
- if (!(skipIndexes && isIndex(key, length)) &&
12300
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
12301
- result.push(key);
12302
- }
12303
- }
12304
- return result;
12305
- }
12306
-
12307
- module.exports = keys;
12867
+ module.exports = isIterateeCall;
12308
12868
 
12309
- },{"lodash._getnative":58,"lodash.isarguments":61,"lodash.isarray":62}],64:[function(require,module,exports){
12869
+ },{}],78:[function(require,module,exports){
12310
12870
  (function (process){
12311
12871
  var path = require('path');
12312
12872
  var fs = require('fs');
@@ -12408,7 +12968,7 @@ mkdirP.sync = function sync (p, opts, made) {
12408
12968
  };
12409
12969
 
12410
12970
  }).call(this,require('_process'))
12411
- },{"_process":67,"fs":42,"path":42}],65:[function(require,module,exports){
12971
+ },{"_process":81,"fs":42,"path":42}],79:[function(require,module,exports){
12412
12972
  exports.endianness = function () { return 'LE' };
12413
12973
 
12414
12974
  exports.hostname = function () {
@@ -12455,7 +13015,7 @@ exports.tmpdir = exports.tmpDir = function () {
12455
13015
 
12456
13016
  exports.EOL = '\n';
12457
13017
 
12458
- },{}],66:[function(require,module,exports){
13018
+ },{}],80:[function(require,module,exports){
12459
13019
  (function (process){
12460
13020
  'use strict';
12461
13021
 
@@ -12502,7 +13062,7 @@ function nextTick(fn, arg1, arg2, arg3) {
12502
13062
  }
12503
13063
 
12504
13064
  }).call(this,require('_process'))
12505
- },{"_process":67}],67:[function(require,module,exports){
13065
+ },{"_process":81}],81:[function(require,module,exports){
12506
13066
  // shim for using process in browser
12507
13067
  var process = module.exports = {};
12508
13068
 
@@ -12673,6 +13233,10 @@ process.off = noop;
12673
13233
  process.removeListener = noop;
12674
13234
  process.removeAllListeners = noop;
12675
13235
  process.emit = noop;
13236
+ process.prependListener = noop;
13237
+ process.prependOnceListener = noop;
13238
+
13239
+ process.listeners = function (name) { return [] }
12676
13240
 
12677
13241
  process.binding = function (name) {
12678
13242
  throw new Error('process.binding is not supported');
@@ -12684,10 +13248,10 @@ process.chdir = function (dir) {
12684
13248
  };
12685
13249
  process.umask = function() { return 0; };
12686
13250
 
12687
- },{}],68:[function(require,module,exports){
12688
- module.exports = require("./lib/_stream_duplex.js")
13251
+ },{}],82:[function(require,module,exports){
13252
+ module.exports = require('./lib/_stream_duplex.js');
12689
13253
 
12690
- },{"./lib/_stream_duplex.js":69}],69:[function(require,module,exports){
13254
+ },{"./lib/_stream_duplex.js":83}],83:[function(require,module,exports){
12691
13255
  // a duplex stream is just a stream that is both readable and writable.
12692
13256
  // Since JS doesn't have multiple prototypal inheritance, this class
12693
13257
  // prototypally inherits from Readable, and then parasitically from
@@ -12763,7 +13327,7 @@ function forEach(xs, f) {
12763
13327
  f(xs[i], i);
12764
13328
  }
12765
13329
  }
12766
- },{"./_stream_readable":71,"./_stream_writable":73,"core-util-is":45,"inherits":51,"process-nextick-args":66}],70:[function(require,module,exports){
13330
+ },{"./_stream_readable":85,"./_stream_writable":87,"core-util-is":44,"inherits":65,"process-nextick-args":80}],84:[function(require,module,exports){
12767
13331
  // a passthrough stream.
12768
13332
  // basically just the most minimal sort of Transform stream.
12769
13333
  // Every written chunk gets output as-is.
@@ -12790,7 +13354,7 @@ function PassThrough(options) {
12790
13354
  PassThrough.prototype._transform = function (chunk, encoding, cb) {
12791
13355
  cb(null, chunk);
12792
13356
  };
12793
- },{"./_stream_transform":72,"core-util-is":45,"inherits":51}],71:[function(require,module,exports){
13357
+ },{"./_stream_transform":86,"core-util-is":44,"inherits":65}],85:[function(require,module,exports){
12794
13358
  (function (process){
12795
13359
  'use strict';
12796
13360
 
@@ -12804,6 +13368,10 @@ var processNextTick = require('process-nextick-args');
12804
13368
  var isArray = require('isarray');
12805
13369
  /*</replacement>*/
12806
13370
 
13371
+ /*<replacement>*/
13372
+ var Duplex;
13373
+ /*</replacement>*/
13374
+
12807
13375
  Readable.ReadableState = ReadableState;
12808
13376
 
12809
13377
  /*<replacement>*/
@@ -12815,19 +13383,11 @@ var EElistenerCount = function (emitter, type) {
12815
13383
  /*</replacement>*/
12816
13384
 
12817
13385
  /*<replacement>*/
12818
- var Stream;
12819
- (function () {
12820
- try {
12821
- Stream = require('st' + 'ream');
12822
- } catch (_) {} finally {
12823
- if (!Stream) Stream = require('events').EventEmitter;
12824
- }
12825
- })();
13386
+ var Stream = require('./internal/streams/stream');
12826
13387
  /*</replacement>*/
12827
13388
 
12828
- var Buffer = require('buffer').Buffer;
12829
13389
  /*<replacement>*/
12830
- var bufferShim = require('buffer-shims');
13390
+ var Buffer = require('safe-buffer').Buffer;
12831
13391
  /*</replacement>*/
12832
13392
 
12833
13393
  /*<replacement>*/
@@ -12850,7 +13410,11 @@ var StringDecoder;
12850
13410
 
12851
13411
  util.inherits(Readable, Stream);
12852
13412
 
13413
+ var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
13414
+
12853
13415
  function prependListener(emitter, event, fn) {
13416
+ // Sadly this is not cacheable as some libraries bundle their own
13417
+ // event emitter implementation with them.
12854
13418
  if (typeof emitter.prependListener === 'function') {
12855
13419
  return emitter.prependListener(event, fn);
12856
13420
  } else {
@@ -12862,7 +13426,6 @@ function prependListener(emitter, event, fn) {
12862
13426
  }
12863
13427
  }
12864
13428
 
12865
- var Duplex;
12866
13429
  function ReadableState(options, stream) {
12867
13430
  Duplex = Duplex || require('./_stream_duplex');
12868
13431
 
@@ -12881,7 +13444,7 @@ function ReadableState(options, stream) {
12881
13444
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
12882
13445
 
12883
13446
  // cast to ints.
12884
- this.highWaterMark = ~ ~this.highWaterMark;
13447
+ this.highWaterMark = ~~this.highWaterMark;
12885
13448
 
12886
13449
  // A linked list is used to store data chunks instead of an array because the
12887
13450
  // linked list can remove elements from the beginning faster than
@@ -12932,7 +13495,6 @@ function ReadableState(options, stream) {
12932
13495
  }
12933
13496
  }
12934
13497
 
12935
- var Duplex;
12936
13498
  function Readable(options) {
12937
13499
  Duplex = Duplex || require('./_stream_duplex');
12938
13500
 
@@ -12958,7 +13520,7 @@ Readable.prototype.push = function (chunk, encoding) {
12958
13520
  if (!state.objectMode && typeof chunk === 'string') {
12959
13521
  encoding = encoding || state.defaultEncoding;
12960
13522
  if (encoding !== state.encoding) {
12961
- chunk = bufferShim.from(chunk, encoding);
13523
+ chunk = Buffer.from(chunk, encoding);
12962
13524
  encoding = '';
12963
13525
  }
12964
13526
  }
@@ -13255,7 +13817,7 @@ function maybeReadMore_(stream, state) {
13255
13817
  // for virtual (non-string, non-buffer) streams, "length" is somewhat
13256
13818
  // arbitrary, and perhaps not very meaningful.
13257
13819
  Readable.prototype._read = function (n) {
13258
- this.emit('error', new Error('not implemented'));
13820
+ this.emit('error', new Error('_read() is not implemented'));
13259
13821
  };
13260
13822
 
13261
13823
  Readable.prototype.pipe = function (dest, pipeOpts) {
@@ -13278,7 +13840,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
13278
13840
 
13279
13841
  var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
13280
13842
 
13281
- var endFn = doEnd ? onend : cleanup;
13843
+ var endFn = doEnd ? onend : unpipe;
13282
13844
  if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
13283
13845
 
13284
13846
  dest.on('unpipe', onunpipe);
@@ -13311,7 +13873,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
13311
13873
  dest.removeListener('error', onerror);
13312
13874
  dest.removeListener('unpipe', onunpipe);
13313
13875
  src.removeListener('end', onend);
13314
- src.removeListener('end', cleanup);
13876
+ src.removeListener('end', unpipe);
13315
13877
  src.removeListener('data', ondata);
13316
13878
 
13317
13879
  cleanedUp = true;
@@ -13433,16 +13995,16 @@ Readable.prototype.unpipe = function (dest) {
13433
13995
  state.pipesCount = 0;
13434
13996
  state.flowing = false;
13435
13997
 
13436
- for (var _i = 0; _i < len; _i++) {
13437
- dests[_i].emit('unpipe', this);
13998
+ for (var i = 0; i < len; i++) {
13999
+ dests[i].emit('unpipe', this);
13438
14000
  }return this;
13439
14001
  }
13440
14002
 
13441
14003
  // try to find the right one.
13442
- var i = indexOf(state.pipes, dest);
13443
- if (i === -1) return this;
14004
+ var index = indexOf(state.pipes, dest);
14005
+ if (index === -1) return this;
13444
14006
 
13445
- state.pipes.splice(i, 1);
14007
+ state.pipes.splice(index, 1);
13446
14008
  state.pipesCount -= 1;
13447
14009
  if (state.pipesCount === 1) state.pipes = state.pipes[0];
13448
14010
 
@@ -13574,10 +14136,9 @@ Readable.prototype.wrap = function (stream) {
13574
14136
  }
13575
14137
 
13576
14138
  // proxy certain important events.
13577
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
13578
- forEach(events, function (ev) {
13579
- stream.on(ev, self.emit.bind(self, ev));
13580
- });
14139
+ for (var n = 0; n < kProxyEvents.length; n++) {
14140
+ stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
14141
+ }
13581
14142
 
13582
14143
  // when we try to consume some more bytes, simply unpause the
13583
14144
  // underlying stream.
@@ -13669,7 +14230,7 @@ function copyFromBufferString(n, list) {
13669
14230
  // This function is designed to be inlinable, so please take care when making
13670
14231
  // changes to the function body.
13671
14232
  function copyFromBuffer(n, list) {
13672
- var ret = bufferShim.allocUnsafe(n);
14233
+ var ret = Buffer.allocUnsafe(n);
13673
14234
  var p = list.head;
13674
14235
  var c = 1;
13675
14236
  p.data.copy(ret);
@@ -13730,7 +14291,7 @@ function indexOf(xs, x) {
13730
14291
  return -1;
13731
14292
  }
13732
14293
  }).call(this,require('_process'))
13733
- },{"./_stream_duplex":69,"./internal/streams/BufferList":74,"_process":67,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":48,"inherits":51,"isarray":53,"process-nextick-args":66,"string_decoder/":80,"util":40}],72:[function(require,module,exports){
14294
+ },{"./_stream_duplex":83,"./internal/streams/BufferList":88,"./internal/streams/stream":89,"_process":81,"core-util-is":44,"events":62,"inherits":65,"isarray":67,"process-nextick-args":80,"safe-buffer":94,"string_decoder/":96,"util":40}],86:[function(require,module,exports){
13734
14295
  // a transform stream is a readable/writable stream where you do
13735
14296
  // something with the data. Sometimes it's called a "filter",
13736
14297
  // but that's not a great name for it, since that implies a thing where
@@ -13827,7 +14388,6 @@ function Transform(options) {
13827
14388
 
13828
14389
  this._transformState = new TransformState(this);
13829
14390
 
13830
- // when the writable side finishes, then flush out anything remaining.
13831
14391
  var stream = this;
13832
14392
 
13833
14393
  // start out asking for a readable event once data is transformed.
@@ -13844,9 +14404,10 @@ function Transform(options) {
13844
14404
  if (typeof options.flush === 'function') this._flush = options.flush;
13845
14405
  }
13846
14406
 
14407
+ // When the writable side finishes, then flush out anything remaining.
13847
14408
  this.once('prefinish', function () {
13848
- if (typeof this._flush === 'function') this._flush(function (er) {
13849
- done(stream, er);
14409
+ if (typeof this._flush === 'function') this._flush(function (er, data) {
14410
+ done(stream, er, data);
13850
14411
  });else done(stream);
13851
14412
  });
13852
14413
  }
@@ -13867,7 +14428,7 @@ Transform.prototype.push = function (chunk, encoding) {
13867
14428
  // an error, then that'll put the hurt on the whole operation. If you
13868
14429
  // never call cb(), then you'll never get another chunk.
13869
14430
  Transform.prototype._transform = function (chunk, encoding, cb) {
13870
- throw new Error('Not implemented');
14431
+ throw new Error('_transform() is not implemented');
13871
14432
  };
13872
14433
 
13873
14434
  Transform.prototype._write = function (chunk, encoding, cb) {
@@ -13897,9 +14458,11 @@ Transform.prototype._read = function (n) {
13897
14458
  }
13898
14459
  };
13899
14460
 
13900
- function done(stream, er) {
14461
+ function done(stream, er, data) {
13901
14462
  if (er) return stream.emit('error', er);
13902
14463
 
14464
+ if (data !== null && data !== undefined) stream.push(data);
14465
+
13903
14466
  // if there's nothing in the write buffer, then that means
13904
14467
  // that nothing more will ever be provided
13905
14468
  var ws = stream._writableState;
@@ -13911,7 +14474,7 @@ function done(stream, er) {
13911
14474
 
13912
14475
  return stream.push(null);
13913
14476
  }
13914
- },{"./_stream_duplex":69,"core-util-is":45,"inherits":51}],73:[function(require,module,exports){
14477
+ },{"./_stream_duplex":83,"core-util-is":44,"inherits":65}],87:[function(require,module,exports){
13915
14478
  (function (process){
13916
14479
  // A bit simpler than readable streams.
13917
14480
  // Implement an async ._write(chunk, encoding, cb), and it'll handle all
@@ -13929,6 +14492,10 @@ var processNextTick = require('process-nextick-args');
13929
14492
  var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
13930
14493
  /*</replacement>*/
13931
14494
 
14495
+ /*<replacement>*/
14496
+ var Duplex;
14497
+ /*</replacement>*/
14498
+
13932
14499
  Writable.WritableState = WritableState;
13933
14500
 
13934
14501
  /*<replacement>*/
@@ -13943,19 +14510,11 @@ var internalUtil = {
13943
14510
  /*</replacement>*/
13944
14511
 
13945
14512
  /*<replacement>*/
13946
- var Stream;
13947
- (function () {
13948
- try {
13949
- Stream = require('st' + 'ream');
13950
- } catch (_) {} finally {
13951
- if (!Stream) Stream = require('events').EventEmitter;
13952
- }
13953
- })();
14513
+ var Stream = require('./internal/streams/stream');
13954
14514
  /*</replacement>*/
13955
14515
 
13956
- var Buffer = require('buffer').Buffer;
13957
14516
  /*<replacement>*/
13958
- var bufferShim = require('buffer-shims');
14517
+ var Buffer = require('safe-buffer').Buffer;
13959
14518
  /*</replacement>*/
13960
14519
 
13961
14520
  util.inherits(Writable, Stream);
@@ -13969,7 +14528,6 @@ function WriteReq(chunk, encoding, cb) {
13969
14528
  this.next = null;
13970
14529
  }
13971
14530
 
13972
- var Duplex;
13973
14531
  function WritableState(options, stream) {
13974
14532
  Duplex = Duplex || require('./_stream_duplex');
13975
14533
 
@@ -13989,8 +14547,9 @@ function WritableState(options, stream) {
13989
14547
  this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
13990
14548
 
13991
14549
  // cast to ints.
13992
- this.highWaterMark = ~ ~this.highWaterMark;
14550
+ this.highWaterMark = ~~this.highWaterMark;
13993
14551
 
14552
+ // drain event flag.
13994
14553
  this.needDrain = false;
13995
14554
  // at the start of calling end()
13996
14555
  this.ending = false;
@@ -14065,7 +14624,7 @@ function WritableState(options, stream) {
14065
14624
  this.corkedRequestsFree = new CorkedRequest(this);
14066
14625
  }
14067
14626
 
14068
- WritableState.prototype.getBuffer = function writableStateGetBuffer() {
14627
+ WritableState.prototype.getBuffer = function getBuffer() {
14069
14628
  var current = this.bufferedRequest;
14070
14629
  var out = [];
14071
14630
  while (current) {
@@ -14085,13 +14644,37 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
14085
14644
  } catch (_) {}
14086
14645
  })();
14087
14646
 
14088
- var Duplex;
14647
+ // Test _writableState for inheritance to account for Duplex streams,
14648
+ // whose prototype chain only points to Readable.
14649
+ var realHasInstance;
14650
+ if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
14651
+ realHasInstance = Function.prototype[Symbol.hasInstance];
14652
+ Object.defineProperty(Writable, Symbol.hasInstance, {
14653
+ value: function (object) {
14654
+ if (realHasInstance.call(this, object)) return true;
14655
+
14656
+ return object && object._writableState instanceof WritableState;
14657
+ }
14658
+ });
14659
+ } else {
14660
+ realHasInstance = function (object) {
14661
+ return object instanceof this;
14662
+ };
14663
+ }
14664
+
14089
14665
  function Writable(options) {
14090
14666
  Duplex = Duplex || require('./_stream_duplex');
14091
14667
 
14092
- // Writable ctor is applied to Duplexes, though they're not
14093
- // instanceof Writable, they're instanceof Readable.
14094
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
14668
+ // Writable ctor is applied to Duplexes, too.
14669
+ // `realHasInstance` is necessary because using plain `instanceof`
14670
+ // would return false, as no `_writableState` property is attached.
14671
+
14672
+ // Trying to use the custom `instanceof` for Writable here will also break the
14673
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
14674
+ // `_writableState` that would lead to infinite recursion.
14675
+ if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
14676
+ return new Writable(options);
14677
+ }
14095
14678
 
14096
14679
  this._writableState = new WritableState(options, this);
14097
14680
 
@@ -14119,20 +14702,16 @@ function writeAfterEnd(stream, cb) {
14119
14702
  processNextTick(cb, er);
14120
14703
  }
14121
14704
 
14122
- // If we get something that is not a buffer, string, null, or undefined,
14123
- // and we're not in objectMode, then that's an error.
14124
- // Otherwise stream chunks are all considered to be of length=1, and the
14125
- // watermarks determine how many objects to keep in the buffer, rather than
14126
- // how many bytes or characters.
14705
+ // Checks that a user-supplied chunk is valid, especially for the particular
14706
+ // mode the stream is in. Currently this means that `null` is never accepted
14707
+ // and undefined/non-string values are only allowed in object mode.
14127
14708
  function validChunk(stream, state, chunk, cb) {
14128
14709
  var valid = true;
14129
14710
  var er = false;
14130
- // Always throw error if a null is written
14131
- // if we are not in object mode then throw
14132
- // if it is not a buffer, string, or undefined.
14711
+
14133
14712
  if (chunk === null) {
14134
14713
  er = new TypeError('May not write null values to stream');
14135
- } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
14714
+ } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
14136
14715
  er = new TypeError('Invalid non-string/buffer chunk');
14137
14716
  }
14138
14717
  if (er) {
@@ -14146,19 +14725,20 @@ function validChunk(stream, state, chunk, cb) {
14146
14725
  Writable.prototype.write = function (chunk, encoding, cb) {
14147
14726
  var state = this._writableState;
14148
14727
  var ret = false;
14728
+ var isBuf = Buffer.isBuffer(chunk);
14149
14729
 
14150
14730
  if (typeof encoding === 'function') {
14151
14731
  cb = encoding;
14152
14732
  encoding = null;
14153
14733
  }
14154
14734
 
14155
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
14735
+ if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
14156
14736
 
14157
14737
  if (typeof cb !== 'function') cb = nop;
14158
14738
 
14159
- if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
14739
+ if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
14160
14740
  state.pendingcb++;
14161
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
14741
+ ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
14162
14742
  }
14163
14743
 
14164
14744
  return ret;
@@ -14190,7 +14770,7 @@ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
14190
14770
 
14191
14771
  function decodeChunk(state, chunk, encoding) {
14192
14772
  if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
14193
- chunk = bufferShim.from(chunk, encoding);
14773
+ chunk = Buffer.from(chunk, encoding);
14194
14774
  }
14195
14775
  return chunk;
14196
14776
  }
@@ -14198,10 +14778,11 @@ function decodeChunk(state, chunk, encoding) {
14198
14778
  // if we're already writing something, then just put this
14199
14779
  // in the queue, and wait our turn. Otherwise, call _write
14200
14780
  // If we return false, then we need a drain event, so set that flag.
14201
- function writeOrBuffer(stream, state, chunk, encoding, cb) {
14202
- chunk = decodeChunk(state, chunk, encoding);
14203
-
14204
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
14781
+ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
14782
+ if (!isBuf) {
14783
+ chunk = decodeChunk(state, chunk, encoding);
14784
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';
14785
+ }
14205
14786
  var len = state.objectMode ? 1 : chunk.length;
14206
14787
 
14207
14788
  state.length += len;
@@ -14270,8 +14851,8 @@ function onwrite(stream, er) {
14270
14851
  asyncWrite(afterWrite, stream, state, finished, cb);
14271
14852
  /*</replacement>*/
14272
14853
  } else {
14273
- afterWrite(stream, state, finished, cb);
14274
- }
14854
+ afterWrite(stream, state, finished, cb);
14855
+ }
14275
14856
  }
14276
14857
  }
14277
14858
 
@@ -14351,7 +14932,7 @@ function clearBuffer(stream, state) {
14351
14932
  }
14352
14933
 
14353
14934
  Writable.prototype._write = function (chunk, encoding, cb) {
14354
- cb(new Error('not implemented'));
14935
+ cb(new Error('_write() is not implemented'));
14355
14936
  };
14356
14937
 
14357
14938
  Writable.prototype._writev = null;
@@ -14422,7 +15003,6 @@ function CorkedRequest(state) {
14422
15003
 
14423
15004
  this.next = null;
14424
15005
  this.entry = null;
14425
-
14426
15006
  this.finish = function (err) {
14427
15007
  var entry = _this.entry;
14428
15008
  _this.entry = null;
@@ -14440,12 +15020,12 @@ function CorkedRequest(state) {
14440
15020
  };
14441
15021
  }
14442
15022
  }).call(this,require('_process'))
14443
- },{"./_stream_duplex":69,"_process":67,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":48,"inherits":51,"process-nextick-args":66,"util-deprecate":81}],74:[function(require,module,exports){
15023
+ },{"./_stream_duplex":83,"./internal/streams/stream":89,"_process":81,"core-util-is":44,"inherits":65,"process-nextick-args":80,"safe-buffer":94,"util-deprecate":98}],88:[function(require,module,exports){
14444
15024
  'use strict';
14445
15025
 
14446
- var Buffer = require('buffer').Buffer;
14447
15026
  /*<replacement>*/
14448
- var bufferShim = require('buffer-shims');
15027
+
15028
+ var Buffer = require('safe-buffer').Buffer;
14449
15029
  /*</replacement>*/
14450
15030
 
14451
15031
  module.exports = BufferList;
@@ -14493,9 +15073,9 @@ BufferList.prototype.join = function (s) {
14493
15073
  };
14494
15074
 
14495
15075
  BufferList.prototype.concat = function (n) {
14496
- if (this.length === 0) return bufferShim.alloc(0);
15076
+ if (this.length === 0) return Buffer.alloc(0);
14497
15077
  if (this.length === 1) return this.head.data;
14498
- var ret = bufferShim.allocUnsafe(n >>> 0);
15078
+ var ret = Buffer.allocUnsafe(n >>> 0);
14499
15079
  var p = this.head;
14500
15080
  var i = 0;
14501
15081
  while (p) {
@@ -14505,36 +15085,31 @@ BufferList.prototype.concat = function (n) {
14505
15085
  }
14506
15086
  return ret;
14507
15087
  };
14508
- },{"buffer":44,"buffer-shims":43}],75:[function(require,module,exports){
14509
- module.exports = require("./lib/_stream_passthrough.js")
15088
+ },{"safe-buffer":94}],89:[function(require,module,exports){
15089
+ module.exports = require('events').EventEmitter;
14510
15090
 
14511
- },{"./lib/_stream_passthrough.js":70}],76:[function(require,module,exports){
14512
- (function (process){
14513
- var Stream = (function (){
14514
- try {
14515
- return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
14516
- } catch(_){}
14517
- }());
15091
+ },{"events":62}],90:[function(require,module,exports){
15092
+ module.exports = require('./readable').PassThrough
15093
+
15094
+ },{"./readable":91}],91:[function(require,module,exports){
14518
15095
  exports = module.exports = require('./lib/_stream_readable.js');
14519
- exports.Stream = Stream || exports;
15096
+ exports.Stream = exports;
14520
15097
  exports.Readable = exports;
14521
15098
  exports.Writable = require('./lib/_stream_writable.js');
14522
15099
  exports.Duplex = require('./lib/_stream_duplex.js');
14523
15100
  exports.Transform = require('./lib/_stream_transform.js');
14524
15101
  exports.PassThrough = require('./lib/_stream_passthrough.js');
14525
15102
 
14526
- if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
14527
- module.exports = Stream;
14528
- }
15103
+ },{"./lib/_stream_duplex.js":83,"./lib/_stream_passthrough.js":84,"./lib/_stream_readable.js":85,"./lib/_stream_transform.js":86,"./lib/_stream_writable.js":87}],92:[function(require,module,exports){
15104
+ module.exports = require('./readable').Transform
14529
15105
 
14530
- }).call(this,require('_process'))
14531
- },{"./lib/_stream_duplex.js":69,"./lib/_stream_passthrough.js":70,"./lib/_stream_readable.js":71,"./lib/_stream_transform.js":72,"./lib/_stream_writable.js":73,"_process":67}],77:[function(require,module,exports){
14532
- module.exports = require("./lib/_stream_transform.js")
15106
+ },{"./readable":91}],93:[function(require,module,exports){
15107
+ module.exports = require('./lib/_stream_writable.js');
14533
15108
 
14534
- },{"./lib/_stream_transform.js":72}],78:[function(require,module,exports){
14535
- module.exports = require("./lib/_stream_writable.js")
15109
+ },{"./lib/_stream_writable.js":87}],94:[function(require,module,exports){
15110
+ module.exports = require('buffer')
14536
15111
 
14537
- },{"./lib/_stream_writable.js":73}],79:[function(require,module,exports){
15112
+ },{"buffer":43}],95:[function(require,module,exports){
14538
15113
  // Copyright Joyent, Inc. and other Node contributors.
14539
15114
  //
14540
15115
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -14663,230 +15238,344 @@ Stream.prototype.pipe = function(dest, options) {
14663
15238
  return dest;
14664
15239
  };
14665
15240
 
14666
- },{"events":48,"inherits":51,"readable-stream/duplex.js":68,"readable-stream/passthrough.js":75,"readable-stream/readable.js":76,"readable-stream/transform.js":77,"readable-stream/writable.js":78}],80:[function(require,module,exports){
14667
- // Copyright Joyent, Inc. and other Node contributors.
14668
- //
14669
- // Permission is hereby granted, free of charge, to any person obtaining a
14670
- // copy of this software and associated documentation files (the
14671
- // "Software"), to deal in the Software without restriction, including
14672
- // without limitation the rights to use, copy, modify, merge, publish,
14673
- // distribute, sublicense, and/or sell copies of the Software, and to permit
14674
- // persons to whom the Software is furnished to do so, subject to the
14675
- // following conditions:
14676
- //
14677
- // The above copyright notice and this permission notice shall be included
14678
- // in all copies or substantial portions of the Software.
14679
- //
14680
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14681
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14682
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
14683
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14684
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14685
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
14686
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
14687
-
14688
- var Buffer = require('buffer').Buffer;
15241
+ },{"events":62,"inherits":65,"readable-stream/duplex.js":82,"readable-stream/passthrough.js":90,"readable-stream/readable.js":91,"readable-stream/transform.js":92,"readable-stream/writable.js":93}],96:[function(require,module,exports){
15242
+ 'use strict';
14689
15243
 
14690
- var isBufferEncoding = Buffer.isEncoding
14691
- || function(encoding) {
14692
- switch (encoding && encoding.toLowerCase()) {
14693
- 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': return true;
14694
- default: return false;
14695
- }
14696
- }
15244
+ var Buffer = require('safe-buffer').Buffer;
14697
15245
 
15246
+ var isEncoding = Buffer.isEncoding || function (encoding) {
15247
+ encoding = '' + encoding;
15248
+ switch (encoding && encoding.toLowerCase()) {
15249
+ 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':
15250
+ return true;
15251
+ default:
15252
+ return false;
15253
+ }
15254
+ };
14698
15255
 
14699
- function assertEncoding(encoding) {
14700
- if (encoding && !isBufferEncoding(encoding)) {
14701
- throw new Error('Unknown encoding: ' + encoding);
15256
+ function _normalizeEncoding(enc) {
15257
+ if (!enc) return 'utf8';
15258
+ var retried;
15259
+ while (true) {
15260
+ switch (enc) {
15261
+ case 'utf8':
15262
+ case 'utf-8':
15263
+ return 'utf8';
15264
+ case 'ucs2':
15265
+ case 'ucs-2':
15266
+ case 'utf16le':
15267
+ case 'utf-16le':
15268
+ return 'utf16le';
15269
+ case 'latin1':
15270
+ case 'binary':
15271
+ return 'latin1';
15272
+ case 'base64':
15273
+ case 'ascii':
15274
+ case 'hex':
15275
+ return enc;
15276
+ default:
15277
+ if (retried) return; // undefined
15278
+ enc = ('' + enc).toLowerCase();
15279
+ retried = true;
15280
+ }
14702
15281
  }
15282
+ };
15283
+
15284
+ // Do not cache `Buffer.isEncoding` when checking encoding names as some
15285
+ // modules monkey-patch it to support additional encodings
15286
+ function normalizeEncoding(enc) {
15287
+ var nenc = _normalizeEncoding(enc);
15288
+ if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
15289
+ return nenc || enc;
14703
15290
  }
14704
15291
 
14705
15292
  // StringDecoder provides an interface for efficiently splitting a series of
14706
15293
  // buffers into a series of JS strings without breaking apart multi-byte
14707
- // characters. CESU-8 is handled as part of the UTF-8 encoding.
14708
- //
14709
- // @TODO Handling all encodings inside a single object makes it very difficult
14710
- // to reason about this code, so it should be split up in the future.
14711
- // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
14712
- // points as used by CESU-8.
14713
- var StringDecoder = exports.StringDecoder = function(encoding) {
14714
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
14715
- assertEncoding(encoding);
15294
+ // characters.
15295
+ exports.StringDecoder = StringDecoder;
15296
+ function StringDecoder(encoding) {
15297
+ this.encoding = normalizeEncoding(encoding);
15298
+ var nb;
14716
15299
  switch (this.encoding) {
14717
- case 'utf8':
14718
- // CESU-8 represents each of Surrogate Pair by 3-bytes
14719
- this.surrogateSize = 3;
14720
- break;
14721
- case 'ucs2':
14722
15300
  case 'utf16le':
14723
- // UTF-16 represents each of Surrogate Pair by 2-bytes
14724
- this.surrogateSize = 2;
14725
- this.detectIncompleteChar = utf16DetectIncompleteChar;
15301
+ this.text = utf16Text;
15302
+ this.end = utf16End;
15303
+ nb = 4;
15304
+ break;
15305
+ case 'utf8':
15306
+ this.fillLast = utf8FillLast;
15307
+ nb = 4;
14726
15308
  break;
14727
15309
  case 'base64':
14728
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
14729
- this.surrogateSize = 3;
14730
- this.detectIncompleteChar = base64DetectIncompleteChar;
15310
+ this.text = base64Text;
15311
+ this.end = base64End;
15312
+ nb = 3;
14731
15313
  break;
14732
15314
  default:
14733
- this.write = passThroughWrite;
15315
+ this.write = simpleWrite;
15316
+ this.end = simpleEnd;
14734
15317
  return;
14735
15318
  }
15319
+ this.lastNeed = 0;
15320
+ this.lastTotal = 0;
15321
+ this.lastChar = Buffer.allocUnsafe(nb);
15322
+ }
14736
15323
 
14737
- // Enough space to store all bytes of a single character. UTF-8 needs 4
14738
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
14739
- this.charBuffer = new Buffer(6);
14740
- // Number of bytes received for the current incomplete multi-byte character.
14741
- this.charReceived = 0;
14742
- // Number of bytes expected for the current incomplete multi-byte character.
14743
- this.charLength = 0;
15324
+ StringDecoder.prototype.write = function (buf) {
15325
+ if (buf.length === 0) return '';
15326
+ var r;
15327
+ var i;
15328
+ if (this.lastNeed) {
15329
+ r = this.fillLast(buf);
15330
+ if (r === undefined) return '';
15331
+ i = this.lastNeed;
15332
+ this.lastNeed = 0;
15333
+ } else {
15334
+ i = 0;
15335
+ }
15336
+ if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
15337
+ return r || '';
14744
15338
  };
14745
15339
 
15340
+ StringDecoder.prototype.end = utf8End;
14746
15341
 
14747
- // write decodes the given buffer and returns it as JS string that is
14748
- // guaranteed to not contain any partial multi-byte characters. Any partial
14749
- // character found at the end of the buffer is buffered up, and will be
14750
- // returned when calling write again with the remaining bytes.
14751
- //
14752
- // Note: Converting a Buffer containing an orphan surrogate to a String
14753
- // currently works, but converting a String to a Buffer (via `new Buffer`, or
14754
- // Buffer#write) will replace incomplete surrogates with the unicode
14755
- // replacement character. See https://codereview.chromium.org/121173009/ .
14756
- StringDecoder.prototype.write = function(buffer) {
14757
- var charStr = '';
14758
- // if our last write ended with an incomplete multibyte character
14759
- while (this.charLength) {
14760
- // determine how many remaining bytes this buffer has to offer for this char
14761
- var available = (buffer.length >= this.charLength - this.charReceived) ?
14762
- this.charLength - this.charReceived :
14763
- buffer.length;
14764
-
14765
- // add the new bytes to the char buffer
14766
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
14767
- this.charReceived += available;
14768
-
14769
- if (this.charReceived < this.charLength) {
14770
- // still not enough chars in this buffer? wait for more ...
14771
- return '';
14772
- }
14773
-
14774
- // remove bytes belonging to the current character from the buffer
14775
- buffer = buffer.slice(available, buffer.length);
14776
-
14777
- // get the character that was split
14778
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
14779
-
14780
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
14781
- var charCode = charStr.charCodeAt(charStr.length - 1);
14782
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
14783
- this.charLength += this.surrogateSize;
14784
- charStr = '';
14785
- continue;
14786
- }
14787
- this.charReceived = this.charLength = 0;
15342
+ // Returns only complete characters in a Buffer
15343
+ StringDecoder.prototype.text = utf8Text;
14788
15344
 
14789
- // if there are no more bytes in this buffer, just emit our char
14790
- if (buffer.length === 0) {
14791
- return charStr;
14792
- }
14793
- break;
15345
+ // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
15346
+ StringDecoder.prototype.fillLast = function (buf) {
15347
+ if (this.lastNeed <= buf.length) {
15348
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
15349
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
14794
15350
  }
15351
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
15352
+ this.lastNeed -= buf.length;
15353
+ };
14795
15354
 
14796
- // determine and set charLength / charReceived
14797
- this.detectIncompleteChar(buffer);
15355
+ // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
15356
+ // continuation byte.
15357
+ function utf8CheckByte(byte) {
15358
+ 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;
15359
+ return -1;
15360
+ }
14798
15361
 
14799
- var end = buffer.length;
14800
- if (this.charLength) {
14801
- // buffer the incomplete character bytes we got
14802
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
14803
- end -= this.charReceived;
15362
+ // Checks at most 3 bytes at the end of a Buffer in order to detect an
15363
+ // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
15364
+ // needed to complete the UTF-8 character (if applicable) are returned.
15365
+ function utf8CheckIncomplete(self, buf, i) {
15366
+ var j = buf.length - 1;
15367
+ if (j < i) return 0;
15368
+ var nb = utf8CheckByte(buf[j]);
15369
+ if (nb >= 0) {
15370
+ if (nb > 0) self.lastNeed = nb - 1;
15371
+ return nb;
14804
15372
  }
15373
+ if (--j < i) return 0;
15374
+ nb = utf8CheckByte(buf[j]);
15375
+ if (nb >= 0) {
15376
+ if (nb > 0) self.lastNeed = nb - 2;
15377
+ return nb;
15378
+ }
15379
+ if (--j < i) return 0;
15380
+ nb = utf8CheckByte(buf[j]);
15381
+ if (nb >= 0) {
15382
+ if (nb > 0) {
15383
+ if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
15384
+ }
15385
+ return nb;
15386
+ }
15387
+ return 0;
15388
+ }
14805
15389
 
14806
- charStr += buffer.toString(this.encoding, 0, end);
14807
-
14808
- var end = charStr.length - 1;
14809
- var charCode = charStr.charCodeAt(end);
14810
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
14811
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
14812
- var size = this.surrogateSize;
14813
- this.charLength += size;
14814
- this.charReceived += size;
14815
- this.charBuffer.copy(this.charBuffer, size, 0, size);
14816
- buffer.copy(this.charBuffer, 0, 0, size);
14817
- return charStr.substring(0, end);
15390
+ // Validates as many continuation bytes for a multi-byte UTF-8 character as
15391
+ // needed or are available. If we see a non-continuation byte where we expect
15392
+ // one, we "replace" the validated continuation bytes we've seen so far with
15393
+ // UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
15394
+ // behavior. The continuation byte check is included three times in the case
15395
+ // where all of the continuation bytes for a character exist in the same buffer.
15396
+ // It is also done this way as a slight performance increase instead of using a
15397
+ // loop.
15398
+ function utf8CheckExtraBytes(self, buf, p) {
15399
+ if ((buf[0] & 0xC0) !== 0x80) {
15400
+ self.lastNeed = 0;
15401
+ return '\ufffd'.repeat(p);
15402
+ }
15403
+ if (self.lastNeed > 1 && buf.length > 1) {
15404
+ if ((buf[1] & 0xC0) !== 0x80) {
15405
+ self.lastNeed = 1;
15406
+ return '\ufffd'.repeat(p + 1);
15407
+ }
15408
+ if (self.lastNeed > 2 && buf.length > 2) {
15409
+ if ((buf[2] & 0xC0) !== 0x80) {
15410
+ self.lastNeed = 2;
15411
+ return '\ufffd'.repeat(p + 2);
15412
+ }
15413
+ }
14818
15414
  }
15415
+ }
14819
15416
 
14820
- // or just emit the charStr
14821
- return charStr;
14822
- };
15417
+ // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
15418
+ function utf8FillLast(buf) {
15419
+ var p = this.lastTotal - this.lastNeed;
15420
+ var r = utf8CheckExtraBytes(this, buf, p);
15421
+ if (r !== undefined) return r;
15422
+ if (this.lastNeed <= buf.length) {
15423
+ buf.copy(this.lastChar, p, 0, this.lastNeed);
15424
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
15425
+ }
15426
+ buf.copy(this.lastChar, p, 0, buf.length);
15427
+ this.lastNeed -= buf.length;
15428
+ }
15429
+
15430
+ // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
15431
+ // partial character, the character's bytes are buffered until the required
15432
+ // number of bytes are available.
15433
+ function utf8Text(buf, i) {
15434
+ var total = utf8CheckIncomplete(this, buf, i);
15435
+ if (!this.lastNeed) return buf.toString('utf8', i);
15436
+ this.lastTotal = total;
15437
+ var end = buf.length - (total - this.lastNeed);
15438
+ buf.copy(this.lastChar, 0, end);
15439
+ return buf.toString('utf8', i, end);
15440
+ }
15441
+
15442
+ // For UTF-8, a replacement character for each buffered byte of a (partial)
15443
+ // character needs to be added to the output.
15444
+ function utf8End(buf) {
15445
+ var r = buf && buf.length ? this.write(buf) : '';
15446
+ if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
15447
+ return r;
15448
+ }
15449
+
15450
+ // UTF-16LE typically needs two bytes per character, but even if we have an even
15451
+ // number of bytes available, we need to check if we end on a leading/high
15452
+ // surrogate. In that case, we need to wait for the next two bytes in order to
15453
+ // decode the last character properly.
15454
+ function utf16Text(buf, i) {
15455
+ if ((buf.length - i) % 2 === 0) {
15456
+ var r = buf.toString('utf16le', i);
15457
+ if (r) {
15458
+ var c = r.charCodeAt(r.length - 1);
15459
+ if (c >= 0xD800 && c <= 0xDBFF) {
15460
+ this.lastNeed = 2;
15461
+ this.lastTotal = 4;
15462
+ this.lastChar[0] = buf[buf.length - 2];
15463
+ this.lastChar[1] = buf[buf.length - 1];
15464
+ return r.slice(0, -1);
15465
+ }
15466
+ }
15467
+ return r;
15468
+ }
15469
+ this.lastNeed = 1;
15470
+ this.lastTotal = 2;
15471
+ this.lastChar[0] = buf[buf.length - 1];
15472
+ return buf.toString('utf16le', i, buf.length - 1);
15473
+ }
14823
15474
 
14824
- // detectIncompleteChar determines if there is an incomplete UTF-8 character at
14825
- // the end of the given buffer. If so, it sets this.charLength to the byte
14826
- // length that character, and sets this.charReceived to the number of bytes
14827
- // that are available for this character.
14828
- StringDecoder.prototype.detectIncompleteChar = function(buffer) {
14829
- // determine how many bytes we have to check at the end of this buffer
14830
- var i = (buffer.length >= 3) ? 3 : buffer.length;
15475
+ // For UTF-16LE we do not explicitly append special replacement characters if we
15476
+ // end on a partial character, we simply let v8 handle that.
15477
+ function utf16End(buf) {
15478
+ var r = buf && buf.length ? this.write(buf) : '';
15479
+ if (this.lastNeed) {
15480
+ var end = this.lastTotal - this.lastNeed;
15481
+ return r + this.lastChar.toString('utf16le', 0, end);
15482
+ }
15483
+ return r;
15484
+ }
14831
15485
 
14832
- // Figure out if one of the last i bytes of our buffer announces an
14833
- // incomplete char.
14834
- for (; i > 0; i--) {
14835
- var c = buffer[buffer.length - i];
15486
+ function base64Text(buf, i) {
15487
+ var n = (buf.length - i) % 3;
15488
+ if (n === 0) return buf.toString('base64', i);
15489
+ this.lastNeed = 3 - n;
15490
+ this.lastTotal = 3;
15491
+ if (n === 1) {
15492
+ this.lastChar[0] = buf[buf.length - 1];
15493
+ } else {
15494
+ this.lastChar[0] = buf[buf.length - 2];
15495
+ this.lastChar[1] = buf[buf.length - 1];
15496
+ }
15497
+ return buf.toString('base64', i, buf.length - n);
15498
+ }
14836
15499
 
14837
- // See http://en.wikipedia.org/wiki/UTF-8#Description
15500
+ function base64End(buf) {
15501
+ var r = buf && buf.length ? this.write(buf) : '';
15502
+ if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
15503
+ return r;
15504
+ }
14838
15505
 
14839
- // 110XXXXX
14840
- if (i == 1 && c >> 5 == 0x06) {
14841
- this.charLength = 2;
14842
- break;
14843
- }
15506
+ // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
15507
+ function simpleWrite(buf) {
15508
+ return buf.toString(this.encoding);
15509
+ }
14844
15510
 
14845
- // 1110XXXX
14846
- if (i <= 2 && c >> 4 == 0x0E) {
14847
- this.charLength = 3;
14848
- break;
14849
- }
15511
+ function simpleEnd(buf) {
15512
+ return buf && buf.length ? this.write(buf) : '';
15513
+ }
15514
+ },{"safe-buffer":97}],97:[function(require,module,exports){
15515
+ /* eslint-disable node/no-deprecated-api */
15516
+ var buffer = require('buffer')
15517
+ var Buffer = buffer.Buffer
14850
15518
 
14851
- // 11110XXX
14852
- if (i <= 3 && c >> 3 == 0x1E) {
14853
- this.charLength = 4;
14854
- break;
14855
- }
15519
+ // alternative to using Object.keys for old browsers
15520
+ function copyProps (src, dst) {
15521
+ for (var key in src) {
15522
+ dst[key] = src[key]
14856
15523
  }
14857
- this.charReceived = i;
14858
- };
15524
+ }
15525
+ if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
15526
+ module.exports = buffer
15527
+ } else {
15528
+ // Copy properties from require('buffer')
15529
+ copyProps(buffer, exports)
15530
+ exports.Buffer = SafeBuffer
15531
+ }
14859
15532
 
14860
- StringDecoder.prototype.end = function(buffer) {
14861
- var res = '';
14862
- if (buffer && buffer.length)
14863
- res = this.write(buffer);
15533
+ function SafeBuffer (arg, encodingOrOffset, length) {
15534
+ return Buffer(arg, encodingOrOffset, length)
15535
+ }
14864
15536
 
14865
- if (this.charReceived) {
14866
- var cr = this.charReceived;
14867
- var buf = this.charBuffer;
14868
- var enc = this.encoding;
14869
- res += buf.slice(0, cr).toString(enc);
14870
- }
15537
+ // Copy static methods from Buffer
15538
+ copyProps(Buffer, SafeBuffer)
14871
15539
 
14872
- return res;
14873
- };
15540
+ SafeBuffer.from = function (arg, encodingOrOffset, length) {
15541
+ if (typeof arg === 'number') {
15542
+ throw new TypeError('Argument must not be a number')
15543
+ }
15544
+ return Buffer(arg, encodingOrOffset, length)
15545
+ }
14874
15546
 
14875
- function passThroughWrite(buffer) {
14876
- return buffer.toString(this.encoding);
15547
+ SafeBuffer.alloc = function (size, fill, encoding) {
15548
+ if (typeof size !== 'number') {
15549
+ throw new TypeError('Argument must be a number')
15550
+ }
15551
+ var buf = Buffer(size)
15552
+ if (fill !== undefined) {
15553
+ if (typeof encoding === 'string') {
15554
+ buf.fill(fill, encoding)
15555
+ } else {
15556
+ buf.fill(fill)
15557
+ }
15558
+ } else {
15559
+ buf.fill(0)
15560
+ }
15561
+ return buf
14877
15562
  }
14878
15563
 
14879
- function utf16DetectIncompleteChar(buffer) {
14880
- this.charReceived = buffer.length % 2;
14881
- this.charLength = this.charReceived ? 2 : 0;
15564
+ SafeBuffer.allocUnsafe = function (size) {
15565
+ if (typeof size !== 'number') {
15566
+ throw new TypeError('Argument must be a number')
15567
+ }
15568
+ return Buffer(size)
14882
15569
  }
14883
15570
 
14884
- function base64DetectIncompleteChar(buffer) {
14885
- this.charReceived = buffer.length % 3;
14886
- this.charLength = this.charReceived ? 3 : 0;
15571
+ SafeBuffer.allocUnsafeSlow = function (size) {
15572
+ if (typeof size !== 'number') {
15573
+ throw new TypeError('Argument must be a number')
15574
+ }
15575
+ return buffer.SlowBuffer(size)
14887
15576
  }
14888
15577
 
14889
- },{"buffer":44}],81:[function(require,module,exports){
15578
+ },{"buffer":43}],98:[function(require,module,exports){
14890
15579
  (function (global){
14891
15580
 
14892
15581
  /**
@@ -14957,16 +15646,16 @@ function config (name) {
14957
15646
  }
14958
15647
 
14959
15648
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14960
- },{}],82:[function(require,module,exports){
14961
- arguments[4][51][0].apply(exports,arguments)
14962
- },{"dup":51}],83:[function(require,module,exports){
15649
+ },{}],99:[function(require,module,exports){
15650
+ arguments[4][65][0].apply(exports,arguments)
15651
+ },{"dup":65}],100:[function(require,module,exports){
14963
15652
  module.exports = function isBuffer(arg) {
14964
15653
  return arg && typeof arg === 'object'
14965
15654
  && typeof arg.copy === 'function'
14966
15655
  && typeof arg.fill === 'function'
14967
15656
  && typeof arg.readUInt8 === 'function';
14968
15657
  }
14969
- },{}],84:[function(require,module,exports){
15658
+ },{}],101:[function(require,module,exports){
14970
15659
  (function (process,global){
14971
15660
  // Copyright Joyent, Inc. and other Node contributors.
14972
15661
  //
@@ -15556,4 +16245,4 @@ function hasOwnProperty(obj, prop) {
15556
16245
  }
15557
16246
 
15558
16247
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
15559
- },{"./support/isBuffer":83,"_process":67,"inherits":82}]},{},[1]);
16248
+ },{"./support/isBuffer":100,"_process":81,"inherits":99}]},{},[1]);