mocha 3.1.2 → 3.4.2

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":82,"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":69}],7:[function(require,module,exports){
651
651
  'use strict';
652
652
 
653
653
  /**
@@ -833,7 +833,7 @@ module.exports = function (suites, context, mocha) {
833
833
  * This is only present if flag --delay is passed into Mocha. It triggers
834
834
  * root suite execution.
835
835
  *
836
- * @param {Suite} suite The root wuite.
836
+ * @param {Suite} suite The root suite.
837
837
  * @return {Function} A function which runs the root suite
838
838
  */
839
839
  runWithSuite: function runWithSuite (suite) {
@@ -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') {
@@ -1782,7 +1790,7 @@ Mocha.prototype.run = function (fn) {
1782
1790
  };
1783
1791
 
1784
1792
  }).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){
1793
+ },{"./context":6,"./hook":7,"./interfaces":11,"./reporters":21,"./runnable":33,"./runner":34,"./suite":35,"./test":36,"./utils":38,"_process":82,"escape-string-regexp":62,"growl":64,"path":42}],15:[function(require,module,exports){
1786
1794
  'use strict';
1787
1795
 
1788
1796
  /**
@@ -2427,7 +2435,7 @@ function sameType (a, b) {
2427
2435
  }
2428
2436
 
2429
2437
  }).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){
2438
+ },{"../ms":15,"../utils":38,"_process":82,"diff":56,"supports-color":42,"tty":5}],18:[function(require,module,exports){
2431
2439
  'use strict';
2432
2440
 
2433
2441
  /**
@@ -2565,7 +2573,7 @@ function Dot (runner) {
2565
2573
  inherits(Dot, Base);
2566
2574
 
2567
2575
  }).call(this,require('_process'))
2568
- },{"../utils":38,"./base":17,"_process":67}],20:[function(require,module,exports){
2576
+ },{"../utils":38,"./base":17,"_process":82}],20:[function(require,module,exports){
2569
2577
  (function (global){
2570
2578
  'use strict';
2571
2579
 
@@ -2610,6 +2618,8 @@ var statsTemplate = '<ul id="mocha-stats">' +
2610
2618
  '<li class="duration">duration: <em>0</em>s</li>' +
2611
2619
  '</ul>';
2612
2620
 
2621
+ var playIcon = '&#x2023;';
2622
+
2613
2623
  /**
2614
2624
  * Initialize a new `HTML` reporter.
2615
2625
  *
@@ -2705,7 +2715,7 @@ function HTML (runner) {
2705
2715
  runner.on('pass', function (test) {
2706
2716
  var url = self.testURL(test);
2707
2717
  var markup = '<li class="test pass %e"><h2>%e<span class="duration">%ems</span> ' +
2708
- '<a href="%s" class="replay">‣</a></h2></li>';
2718
+ '<a href="%s" class="replay">' + playIcon + '</a></h2></li>';
2709
2719
  var el = fragment(markup, test.speed, test.title, test.duration, url);
2710
2720
  self.addCodeToggle(el, test.body);
2711
2721
  appendToStack(el);
@@ -2713,7 +2723,7 @@ function HTML (runner) {
2713
2723
  });
2714
2724
 
2715
2725
  runner.on('fail', function (test) {
2716
- var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">‣</a></h2></li>',
2726
+ var el = fragment('<li class="test fail"><h2>%e <a href="%e" class="replay">' + playIcon + '</a></h2></li>',
2717
2727
  test.title, self.testURL(test));
2718
2728
  var stackString; // Note: Includes leading newline
2719
2729
  var message = test.err.toString();
@@ -2915,7 +2925,7 @@ function on (el, event, fn) {
2915
2925
  }
2916
2926
 
2917
2927
  }).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){
2928
+ },{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":62}],21:[function(require,module,exports){
2919
2929
  'use strict';
2920
2930
 
2921
2931
  // Alias exports to a their normalized format Mocha#reporter to prevent a need
@@ -3003,7 +3013,7 @@ function clean (test) {
3003
3013
  }
3004
3014
 
3005
3015
  }).call(this,require('_process'))
3006
- },{"./base":17,"_process":67,"json3":54}],23:[function(require,module,exports){
3016
+ },{"./base":17,"_process":82,"json3":69}],23:[function(require,module,exports){
3007
3017
  (function (process){
3008
3018
  'use strict';
3009
3019
 
@@ -3099,7 +3109,7 @@ function errorJSON (err) {
3099
3109
  }
3100
3110
 
3101
3111
  }).call(this,require('_process'))
3102
- },{"./base":17,"_process":67}],24:[function(require,module,exports){
3112
+ },{"./base":17,"_process":82}],24:[function(require,module,exports){
3103
3113
  (function (process){
3104
3114
  'use strict';
3105
3115
 
@@ -3197,7 +3207,7 @@ function Landing (runner) {
3197
3207
  inherits(Landing, Base);
3198
3208
 
3199
3209
  }).call(this,require('_process'))
3200
- },{"../utils":38,"./base":17,"_process":67}],25:[function(require,module,exports){
3210
+ },{"../utils":38,"./base":17,"_process":82}],25:[function(require,module,exports){
3201
3211
  (function (process){
3202
3212
  'use strict';
3203
3213
 
@@ -3243,7 +3253,7 @@ function List (runner) {
3243
3253
  });
3244
3254
 
3245
3255
  runner.on('pass', function (test) {
3246
- var fmt = color('checkmark', ' ' + Base.symbols.dot) +
3256
+ var fmt = color('checkmark', ' ' + Base.symbols.ok) +
3247
3257
  color('pass', ' %s: ') +
3248
3258
  color(test.speed, '%dms');
3249
3259
  cursor.CR();
@@ -3264,7 +3274,7 @@ function List (runner) {
3264
3274
  inherits(List, Base);
3265
3275
 
3266
3276
  }).call(this,require('_process'))
3267
- },{"../utils":38,"./base":17,"_process":67}],26:[function(require,module,exports){
3277
+ },{"../utils":38,"./base":17,"_process":82}],26:[function(require,module,exports){
3268
3278
  (function (process){
3269
3279
  'use strict';
3270
3280
 
@@ -3367,7 +3377,7 @@ function Markdown (runner) {
3367
3377
  }
3368
3378
 
3369
3379
  }).call(this,require('_process'))
3370
- },{"../utils":38,"./base":17,"_process":67}],27:[function(require,module,exports){
3380
+ },{"../utils":38,"./base":17,"_process":82}],27:[function(require,module,exports){
3371
3381
  (function (process){
3372
3382
  'use strict';
3373
3383
 
@@ -3409,7 +3419,7 @@ function Min (runner) {
3409
3419
  inherits(Min, Base);
3410
3420
 
3411
3421
  }).call(this,require('_process'))
3412
- },{"../utils":38,"./base":17,"_process":67}],28:[function(require,module,exports){
3422
+ },{"../utils":38,"./base":17,"_process":82}],28:[function(require,module,exports){
3413
3423
  (function (process){
3414
3424
  'use strict';
3415
3425
 
@@ -3676,7 +3686,7 @@ function write (string) {
3676
3686
  }
3677
3687
 
3678
3688
  }).call(this,require('_process'))
3679
- },{"../utils":38,"./base":17,"_process":67}],29:[function(require,module,exports){
3689
+ },{"../utils":38,"./base":17,"_process":82}],29:[function(require,module,exports){
3680
3690
  (function (process){
3681
3691
  'use strict';
3682
3692
 
@@ -3771,7 +3781,7 @@ function Progress (runner, options) {
3771
3781
  inherits(Progress, Base);
3772
3782
 
3773
3783
  }).call(this,require('_process'))
3774
- },{"../utils":38,"./base":17,"_process":67}],30:[function(require,module,exports){
3784
+ },{"../utils":38,"./base":17,"_process":82}],30:[function(require,module,exports){
3775
3785
  'use strict';
3776
3786
 
3777
3787
  /**
@@ -3973,7 +3983,7 @@ function XUnit (runner, options) {
3973
3983
  var tests = [];
3974
3984
  var self = this;
3975
3985
 
3976
- if (options.reporterOptions && options.reporterOptions.output) {
3986
+ if (options && options.reporterOptions && options.reporterOptions.output) {
3977
3987
  if (!fs.createWriteStream) {
3978
3988
  throw new Error('file output not supported in browser');
3979
3989
  }
@@ -4098,7 +4108,7 @@ function tag (name, attrs, close, content) {
4098
4108
  }
4099
4109
 
4100
4110
  }).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){
4111
+ },{"../utils":38,"./base":17,"_process":82,"fs":42,"mkdirp":79,"path":42}],33:[function(require,module,exports){
4102
4112
  (function (global){
4103
4113
  'use strict';
4104
4114
 
@@ -4331,7 +4341,8 @@ Runnable.prototype.resetTimeout = function () {
4331
4341
  if (!self._enableTimeouts) {
4332
4342
  return;
4333
4343
  }
4334
- self.callback(new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.'));
4344
+ self.callback(new Error('Timeout of ' + ms +
4345
+ 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.'));
4335
4346
  self.timedOut = true;
4336
4347
  }, ms);
4337
4348
  };
@@ -4390,7 +4401,8 @@ Runnable.prototype.run = function (fn) {
4390
4401
  self.duration = new Date() - start;
4391
4402
  finished = true;
4392
4403
  if (!err && self.duration > ms && self._enableTimeouts) {
4393
- err = new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.');
4404
+ err = new Error('Timeout of ' + ms +
4405
+ 'ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.');
4394
4406
  }
4395
4407
  fn(err);
4396
4408
  }
@@ -4424,8 +4436,11 @@ Runnable.prototype.run = function (fn) {
4424
4436
  }
4425
4437
 
4426
4438
  if (this.allowUncaught) {
4427
- callFn(this.fn);
4428
- done();
4439
+ if (this.isPending()) {
4440
+ done();
4441
+ } else {
4442
+ callFn(this.fn);
4443
+ }
4429
4444
  return;
4430
4445
  }
4431
4446
 
@@ -4486,7 +4501,7 @@ Runnable.prototype.run = function (fn) {
4486
4501
  };
4487
4502
 
4488
4503
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
4489
- },{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":54,"lodash.create":60}],34:[function(require,module,exports){
4504
+ },{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":69,"lodash.create":75}],34:[function(require,module,exports){
4490
4505
  (function (process,global){
4491
4506
  'use strict';
4492
4507
 
@@ -4922,15 +4937,14 @@ Runner.prototype.runTest = function (fn) {
4922
4937
  if (this.asyncOnly) {
4923
4938
  test.asyncOnly = true;
4924
4939
  }
4925
-
4940
+ test.on('error', function (err) {
4941
+ self.fail(test, err);
4942
+ });
4926
4943
  if (this.allowUncaught) {
4927
4944
  test.allowUncaught = true;
4928
4945
  return test.run(fn);
4929
4946
  }
4930
4947
  try {
4931
- test.on('error', function (err) {
4932
- self.fail(test, err);
4933
- });
4934
4948
  test.run(fn);
4935
4949
  } catch (err) {
4936
4950
  fn(err);
@@ -5171,9 +5185,9 @@ Runner.prototype.runSuite = function (suite, fn) {
5171
5185
  */
5172
5186
  Runner.prototype.uncaught = function (err) {
5173
5187
  if (err) {
5174
- debug('uncaught exception %s', err !== function () {
5188
+ debug('uncaught exception %s', err === (function () {
5175
5189
  return this;
5176
- }.call(err) ? err : (err.message || err));
5190
+ }.call(err)) ? (err.message || err) : err);
5177
5191
  } else {
5178
5192
  debug('uncaught undefined exception');
5179
5193
  err = undefinedError();
@@ -5453,7 +5467,7 @@ function extraGlobals () {
5453
5467
  }
5454
5468
 
5455
5469
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
5456
- },{"./pending":16,"./runnable":33,"./utils":38,"_process":67,"debug":2,"events":3}],35:[function(require,module,exports){
5470
+ },{"./pending":16,"./runnable":33,"./utils":38,"_process":82,"debug":2,"events":3}],35:[function(require,module,exports){
5457
5471
  'use strict';
5458
5472
 
5459
5473
  /**
@@ -5911,7 +5925,7 @@ Test.prototype.clone = function () {
5911
5925
  return test;
5912
5926
  };
5913
5927
 
5914
- },{"./runnable":33,"./utils":38,"lodash.create":60}],37:[function(require,module,exports){
5928
+ },{"./runnable":33,"./utils":38,"lodash.create":75}],37:[function(require,module,exports){
5915
5929
  'use strict';
5916
5930
 
5917
5931
  /**
@@ -5970,6 +5984,7 @@ var join = path.join;
5970
5984
  var readdirSync = require('fs').readdirSync;
5971
5985
  var statSync = require('fs').statSync;
5972
5986
  var watchFile = require('fs').watchFile;
5987
+ var lstatSync = require('fs').lstatSync;
5973
5988
  var toISOString = require('./to-iso-string');
5974
5989
 
5975
5990
  /**
@@ -6206,7 +6221,7 @@ exports.files = function (dir, ext, ret) {
6206
6221
  .filter(ignored)
6207
6222
  .forEach(function (path) {
6208
6223
  path = join(dir, path);
6209
- if (statSync(path).isDirectory()) {
6224
+ if (lstatSync(path).isDirectory()) {
6210
6225
  exports.files(path, ext, ret);
6211
6226
  } else if (path.match(re)) {
6212
6227
  ret.push(path);
@@ -6275,7 +6290,9 @@ exports.parseQuery = function (qs) {
6275
6290
  var key = pair.slice(0, i);
6276
6291
  var val = pair.slice(++i);
6277
6292
 
6278
- obj[key] = decodeURIComponent(val);
6293
+ // Due to how the URLSearchParams API treats spaces
6294
+ obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
6295
+
6279
6296
  return obj;
6280
6297
  }, {});
6281
6298
  };
@@ -6369,7 +6386,7 @@ var type = exports.type = function type (value) {
6369
6386
  return 'buffer';
6370
6387
  }
6371
6388
  return Object.prototype.toString.call(value)
6372
- .replace(/^\[.+\s(.+?)\]$/, '$1')
6389
+ .replace(/^\[.+\s(.+?)]$/, '$1')
6373
6390
  .toLowerCase();
6374
6391
  };
6375
6392
 
@@ -6694,7 +6711,9 @@ exports.stackTraceFilter = function () {
6694
6711
  if (is.node) {
6695
6712
  cwd = process.cwd() + slash;
6696
6713
  } else {
6697
- cwd = (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
6714
+ cwd = (typeof location === 'undefined'
6715
+ ? window.location
6716
+ : location).href.replace(/\/[^/]*$/, '/');
6698
6717
  slash = '/';
6699
6718
  }
6700
6719
 
@@ -6756,7 +6775,7 @@ exports.isPromise = function isPromise (value) {
6756
6775
  exports.noop = function () {};
6757
6776
 
6758
6777
  }).call(this,require('_process'),require("buffer").Buffer)
6759
- },{"./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){
6778
+ },{"./to-iso-string":37,"_process":82,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":69,"path":42,"util":99}],39:[function(require,module,exports){
6760
6779
  'use strict'
6761
6780
 
6762
6781
  exports.byteLength = byteLength
@@ -6903,7 +6922,7 @@ BrowserStdout.prototype._write = function(chunks, encoding, cb) {
6903
6922
  }
6904
6923
 
6905
6924
  }).call(this,require('_process'))
6906
- },{"_process":67,"stream":79,"util":84}],42:[function(require,module,exports){
6925
+ },{"_process":82,"stream":94,"util":99}],42:[function(require,module,exports){
6907
6926
  arguments[4][40][0].apply(exports,arguments)
6908
6927
  },{"dup":40}],43:[function(require,module,exports){
6909
6928
  (function (global){
@@ -8810,7 +8829,7 @@ function isnan (val) {
8810
8829
  }
8811
8830
 
8812
8831
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
8813
- },{"base64-js":39,"ieee754":50,"isarray":53}],45:[function(require,module,exports){
8832
+ },{"base64-js":39,"ieee754":65,"isarray":68}],45:[function(require,module,exports){
8814
8833
  (function (Buffer){
8815
8834
  // Copyright Joyent, Inc. and other Node contributors.
8816
8835
  //
@@ -8921,43 +8940,249 @@ function objectToString(o) {
8921
8940
  }
8922
8941
 
8923
8942
  }).call(this,{"isBuffer":require("../../is-buffer/index.js")})
8924
- },{"../../is-buffer/index.js":52}],46:[function(require,module,exports){
8925
- /* See LICENSE file for terms of use */
8943
+ },{"../../is-buffer/index.js":67}],46:[function(require,module,exports){
8944
+ /*istanbul ignore start*/"use strict";
8945
+
8946
+ exports.__esModule = true;
8947
+ exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
8948
+ // See: http://code.google.com/p/google-diff-match-patch/wiki/API
8949
+ function convertChangesToDMP(changes) {
8950
+ var ret = [],
8951
+ change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
8952
+ operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
8953
+ for (var i = 0; i < changes.length; i++) {
8954
+ change = changes[i];
8955
+ if (change.added) {
8956
+ operation = 1;
8957
+ } else if (change.removed) {
8958
+ operation = -1;
8959
+ } else {
8960
+ operation = 0;
8961
+ }
8926
8962
 
8927
- /*
8928
- * Text diff implementation.
8929
- *
8930
- * This library supports the following APIS:
8931
- * JsDiff.diffChars: Character by character diff
8932
- * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
8933
- * JsDiff.diffLines: Line based diff
8934
- *
8935
- * JsDiff.diffCss: Diff targeted at CSS content
8936
- *
8937
- * These methods are based on the implementation proposed in
8938
- * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
8939
- * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
8940
- */
8941
- (function(global, undefined) {
8942
- var objectPrototypeToString = Object.prototype.toString;
8963
+ ret.push([operation, change.value]);
8964
+ }
8965
+ return ret;
8966
+ }
8967
+
8968
+
8969
+ },{}],47:[function(require,module,exports){
8970
+ /*istanbul ignore start*/'use strict';
8943
8971
 
8944
- /*istanbul ignore next*/
8945
- function map(arr, mapper, that) {
8946
- if (Array.prototype.map) {
8947
- return Array.prototype.map.call(arr, mapper, that);
8972
+ exports.__esModule = true;
8973
+ exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
8974
+ function convertChangesToXML(changes) {
8975
+ var ret = [];
8976
+ for (var i = 0; i < changes.length; i++) {
8977
+ var change = changes[i];
8978
+ if (change.added) {
8979
+ ret.push('<ins>');
8980
+ } else if (change.removed) {
8981
+ ret.push('<del>');
8948
8982
  }
8949
8983
 
8950
- var other = new Array(arr.length);
8984
+ ret.push(escapeHTML(change.value));
8951
8985
 
8952
- for (var i = 0, n = arr.length; i < n; i++) {
8953
- other[i] = mapper.call(that, arr[i], i, arr);
8986
+ if (change.added) {
8987
+ ret.push('</ins>');
8988
+ } else if (change.removed) {
8989
+ ret.push('</del>');
8954
8990
  }
8955
- return other;
8956
8991
  }
8957
- function clonePath(path) {
8958
- return { newPos: path.newPos, components: path.components.slice(0) };
8959
- }
8960
- function removeEmpty(array) {
8992
+ return ret.join('');
8993
+ }
8994
+
8995
+ function escapeHTML(s) {
8996
+ var n = s;
8997
+ n = n.replace(/&/g, '&amp;');
8998
+ n = n.replace(/</g, '&lt;');
8999
+ n = n.replace(/>/g, '&gt;');
9000
+ n = n.replace(/"/g, '&quot;');
9001
+
9002
+ return n;
9003
+ }
9004
+
9005
+
9006
+ },{}],48:[function(require,module,exports){
9007
+ /*istanbul ignore start*/'use strict';
9008
+
9009
+ exports.__esModule = true;
9010
+ exports.arrayDiff = undefined;
9011
+ exports. /*istanbul ignore end*/diffArrays = diffArrays;
9012
+
9013
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9014
+
9015
+ /*istanbul ignore start*/
9016
+ var _base2 = _interopRequireDefault(_base);
9017
+
9018
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9019
+
9020
+ /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9021
+ arrayDiff.tokenize = arrayDiff.join = function (value) {
9022
+ return value.slice();
9023
+ };
9024
+
9025
+ function diffArrays(oldArr, newArr, callback) {
9026
+ return arrayDiff.diff(oldArr, newArr, callback);
9027
+ }
9028
+
9029
+
9030
+ },{"./base":49}],49:[function(require,module,exports){
9031
+ /*istanbul ignore start*/'use strict';
9032
+
9033
+ exports.__esModule = true;
9034
+ exports['default'] = /*istanbul ignore end*/Diff;
9035
+ function Diff() {}
9036
+
9037
+ Diff.prototype = { /*istanbul ignore start*/
9038
+ /*istanbul ignore end*/diff: function diff(oldString, newString) {
9039
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
9040
+
9041
+ var callback = options.callback;
9042
+ if (typeof options === 'function') {
9043
+ callback = options;
9044
+ options = {};
9045
+ }
9046
+ this.options = options;
9047
+
9048
+ var self = this;
9049
+
9050
+ function done(value) {
9051
+ if (callback) {
9052
+ setTimeout(function () {
9053
+ callback(undefined, value);
9054
+ }, 0);
9055
+ return true;
9056
+ } else {
9057
+ return value;
9058
+ }
9059
+ }
9060
+
9061
+ // Allow subclasses to massage the input prior to running
9062
+ oldString = this.castInput(oldString);
9063
+ newString = this.castInput(newString);
9064
+
9065
+ oldString = this.removeEmpty(this.tokenize(oldString));
9066
+ newString = this.removeEmpty(this.tokenize(newString));
9067
+
9068
+ var newLen = newString.length,
9069
+ oldLen = oldString.length;
9070
+ var editLength = 1;
9071
+ var maxEditLength = newLen + oldLen;
9072
+ var bestPath = [{ newPos: -1, components: [] }];
9073
+
9074
+ // Seed editLength = 0, i.e. the content starts with the same values
9075
+ var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
9076
+ if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
9077
+ // Identity per the equality and tokenizer
9078
+ return done([{ value: this.join(newString), count: newString.length }]);
9079
+ }
9080
+
9081
+ // Main worker method. checks all permutations of a given edit length for acceptance.
9082
+ function execEditLength() {
9083
+ for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
9084
+ var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9085
+ var addPath = bestPath[diagonalPath - 1],
9086
+ removePath = bestPath[diagonalPath + 1],
9087
+ _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
9088
+ if (addPath) {
9089
+ // No one else is going to attempt to use this value, clear it
9090
+ bestPath[diagonalPath - 1] = undefined;
9091
+ }
9092
+
9093
+ var canAdd = addPath && addPath.newPos + 1 < newLen,
9094
+ canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
9095
+ if (!canAdd && !canRemove) {
9096
+ // If this path is a terminal then prune
9097
+ bestPath[diagonalPath] = undefined;
9098
+ continue;
9099
+ }
9100
+
9101
+ // Select the diagonal that we want to branch from. We select the prior
9102
+ // path whose position in the new string is the farthest from the origin
9103
+ // and does not pass the bounds of the diff graph
9104
+ if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
9105
+ basePath = clonePath(removePath);
9106
+ self.pushComponent(basePath.components, undefined, true);
9107
+ } else {
9108
+ basePath = addPath; // No need to clone, we've pulled it from the list
9109
+ basePath.newPos++;
9110
+ self.pushComponent(basePath.components, true, undefined);
9111
+ }
9112
+
9113
+ _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
9114
+
9115
+ // If we have hit the end of both strings, then we are done
9116
+ if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
9117
+ return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
9118
+ } else {
9119
+ // Otherwise track this path as a potential candidate and continue.
9120
+ bestPath[diagonalPath] = basePath;
9121
+ }
9122
+ }
9123
+
9124
+ editLength++;
9125
+ }
9126
+
9127
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
9128
+ // sync and async mode which is never fun. Loops over execEditLength until a value
9129
+ // is produced.
9130
+ if (callback) {
9131
+ (function exec() {
9132
+ setTimeout(function () {
9133
+ // This should not happen, but we want to be safe.
9134
+ /* istanbul ignore next */
9135
+ if (editLength > maxEditLength) {
9136
+ return callback();
9137
+ }
9138
+
9139
+ if (!execEditLength()) {
9140
+ exec();
9141
+ }
9142
+ }, 0);
9143
+ })();
9144
+ } else {
9145
+ while (editLength <= maxEditLength) {
9146
+ var ret = execEditLength();
9147
+ if (ret) {
9148
+ return ret;
9149
+ }
9150
+ }
9151
+ }
9152
+ },
9153
+ /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
9154
+ var last = components[components.length - 1];
9155
+ if (last && last.added === added && last.removed === removed) {
9156
+ // We need to clone here as the component clone operation is just
9157
+ // as shallow array clone
9158
+ components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
9159
+ } else {
9160
+ components.push({ count: 1, added: added, removed: removed });
9161
+ }
9162
+ },
9163
+ /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
9164
+ var newLen = newString.length,
9165
+ oldLen = oldString.length,
9166
+ newPos = basePath.newPos,
9167
+ oldPos = newPos - diagonalPath,
9168
+ commonCount = 0;
9169
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
9170
+ newPos++;
9171
+ oldPos++;
9172
+ commonCount++;
9173
+ }
9174
+
9175
+ if (commonCount) {
9176
+ basePath.components.push({ count: commonCount });
9177
+ }
9178
+
9179
+ basePath.newPos = newPos;
9180
+ return oldPos;
9181
+ },
9182
+ /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
9183
+ return left === right;
9184
+ },
9185
+ /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
8961
9186
  var ret = [];
8962
9187
  for (var i = 0; i < array.length; i++) {
8963
9188
  if (array[i]) {
@@ -8965,584 +9190,1008 @@ function objectToString(o) {
8965
9190
  }
8966
9191
  }
8967
9192
  return ret;
9193
+ },
9194
+ /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
9195
+ return value;
9196
+ },
9197
+ /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
9198
+ return value.split('');
9199
+ },
9200
+ /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
9201
+ return chars.join('');
8968
9202
  }
8969
- function escapeHTML(s) {
8970
- var n = s;
8971
- n = n.replace(/&/g, '&amp;');
8972
- n = n.replace(/</g, '&lt;');
8973
- n = n.replace(/>/g, '&gt;');
8974
- n = n.replace(/"/g, '&quot;');
8975
-
8976
- return n;
8977
- }
9203
+ };
8978
9204
 
8979
- // This function handles the presence of circular references by bailing out when encountering an
8980
- // object that is already on the "stack" of items being processed.
8981
- function canonicalize(obj, stack, replacementStack) {
8982
- stack = stack || [];
8983
- replacementStack = replacementStack || [];
9205
+ function buildValues(diff, components, newString, oldString, useLongestToken) {
9206
+ var componentPos = 0,
9207
+ componentLen = components.length,
9208
+ newPos = 0,
9209
+ oldPos = 0;
8984
9210
 
8985
- var i;
9211
+ for (; componentPos < componentLen; componentPos++) {
9212
+ var component = components[componentPos];
9213
+ if (!component.removed) {
9214
+ if (!component.added && useLongestToken) {
9215
+ var value = newString.slice(newPos, newPos + component.count);
9216
+ value = value.map(function (value, i) {
9217
+ var oldValue = oldString[oldPos + i];
9218
+ return oldValue.length > value.length ? oldValue : value;
9219
+ });
8986
9220
 
8987
- for (i = 0; i < stack.length; i += 1) {
8988
- if (stack[i] === obj) {
8989
- return replacementStack[i];
9221
+ component.value = diff.join(value);
9222
+ } else {
9223
+ component.value = diff.join(newString.slice(newPos, newPos + component.count));
8990
9224
  }
8991
- }
8992
-
8993
- var canonicalizedObj;
9225
+ newPos += component.count;
8994
9226
 
8995
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
8996
- stack.push(obj);
8997
- canonicalizedObj = new Array(obj.length);
8998
- replacementStack.push(canonicalizedObj);
8999
- for (i = 0; i < obj.length; i += 1) {
9000
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
9001
- }
9002
- stack.pop();
9003
- replacementStack.pop();
9004
- } else if (typeof obj === 'object' && obj !== null) {
9005
- stack.push(obj);
9006
- canonicalizedObj = {};
9007
- replacementStack.push(canonicalizedObj);
9008
- var sortedKeys = [],
9009
- key;
9010
- for (key in obj) {
9011
- sortedKeys.push(key);
9012
- }
9013
- sortedKeys.sort();
9014
- for (i = 0; i < sortedKeys.length; i += 1) {
9015
- key = sortedKeys[i];
9016
- canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
9227
+ // Common case
9228
+ if (!component.added) {
9229
+ oldPos += component.count;
9017
9230
  }
9018
- stack.pop();
9019
- replacementStack.pop();
9020
9231
  } else {
9021
- canonicalizedObj = obj;
9232
+ component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
9233
+ oldPos += component.count;
9234
+
9235
+ // Reverse add and remove so removes are output first to match common convention
9236
+ // The diffing algorithm is tied to add then remove output and this is the simplest
9237
+ // route to get the desired output with minimal overhead.
9238
+ if (componentPos && components[componentPos - 1].added) {
9239
+ var tmp = components[componentPos - 1];
9240
+ components[componentPos - 1] = components[componentPos];
9241
+ components[componentPos] = tmp;
9242
+ }
9022
9243
  }
9023
- return canonicalizedObj;
9024
9244
  }
9025
9245
 
9026
- function buildValues(components, newString, oldString, useLongestToken) {
9027
- var componentPos = 0,
9028
- componentLen = components.length,
9029
- newPos = 0,
9030
- oldPos = 0;
9246
+ // Special case handle for when one terminal is ignored. For this case we merge the
9247
+ // terminal into the prior string and drop the change.
9248
+ var lastComponent = components[componentLen - 1];
9249
+ if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
9250
+ components[componentLen - 2].value += lastComponent.value;
9251
+ components.pop();
9252
+ }
9031
9253
 
9032
- for (; componentPos < componentLen; componentPos++) {
9033
- var component = components[componentPos];
9034
- if (!component.removed) {
9035
- if (!component.added && useLongestToken) {
9036
- var value = newString.slice(newPos, newPos + component.count);
9037
- value = map(value, function(value, i) {
9038
- var oldValue = oldString[oldPos + i];
9039
- return oldValue.length > value.length ? oldValue : value;
9040
- });
9254
+ return components;
9255
+ }
9041
9256
 
9042
- component.value = value.join('');
9043
- } else {
9044
- component.value = newString.slice(newPos, newPos + component.count).join('');
9045
- }
9046
- newPos += component.count;
9257
+ function clonePath(path) {
9258
+ return { newPos: path.newPos, components: path.components.slice(0) };
9259
+ }
9047
9260
 
9048
- // Common case
9049
- if (!component.added) {
9050
- oldPos += component.count;
9051
- }
9052
- } else {
9053
- component.value = oldString.slice(oldPos, oldPos + component.count).join('');
9054
- oldPos += component.count;
9055
9261
 
9056
- // Reverse add and remove so removes are output first to match common convention
9057
- // The diffing algorithm is tied to add then remove output and this is the simplest
9058
- // route to get the desired output with minimal overhead.
9059
- if (componentPos && components[componentPos - 1].added) {
9060
- var tmp = components[componentPos - 1];
9061
- components[componentPos - 1] = components[componentPos];
9062
- components[componentPos] = tmp;
9063
- }
9064
- }
9262
+ },{}],50:[function(require,module,exports){
9263
+ /*istanbul ignore start*/'use strict';
9264
+
9265
+ exports.__esModule = true;
9266
+ exports.characterDiff = undefined;
9267
+ exports. /*istanbul ignore end*/diffChars = diffChars;
9268
+
9269
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9270
+
9271
+ /*istanbul ignore start*/
9272
+ var _base2 = _interopRequireDefault(_base);
9273
+
9274
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9275
+
9276
+ /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9277
+ function diffChars(oldStr, newStr, callback) {
9278
+ return characterDiff.diff(oldStr, newStr, callback);
9279
+ }
9280
+
9281
+
9282
+ },{"./base":49}],51:[function(require,module,exports){
9283
+ /*istanbul ignore start*/'use strict';
9284
+
9285
+ exports.__esModule = true;
9286
+ exports.cssDiff = undefined;
9287
+ exports. /*istanbul ignore end*/diffCss = diffCss;
9288
+
9289
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9290
+
9291
+ /*istanbul ignore start*/
9292
+ var _base2 = _interopRequireDefault(_base);
9293
+
9294
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9295
+
9296
+ /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9297
+ cssDiff.tokenize = function (value) {
9298
+ return value.split(/([{}:;,]|\s+)/);
9299
+ };
9300
+
9301
+ function diffCss(oldStr, newStr, callback) {
9302
+ return cssDiff.diff(oldStr, newStr, callback);
9303
+ }
9304
+
9305
+
9306
+ },{"./base":49}],52:[function(require,module,exports){
9307
+ /*istanbul ignore start*/'use strict';
9308
+
9309
+ exports.__esModule = true;
9310
+ exports.jsonDiff = undefined;
9311
+
9312
+ 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; };
9313
+
9314
+ exports. /*istanbul ignore end*/diffJson = diffJson;
9315
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
9316
+
9317
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9318
+
9319
+ /*istanbul ignore start*/
9320
+ var _base2 = _interopRequireDefault(_base);
9321
+
9322
+ /*istanbul ignore end*/
9323
+ var /*istanbul ignore start*/_line = require('./line') /*istanbul ignore end*/;
9324
+
9325
+ /*istanbul ignore start*/
9326
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9327
+
9328
+ /*istanbul ignore end*/
9329
+
9330
+ var objectPrototypeToString = Object.prototype.toString;
9331
+
9332
+ var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9333
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
9334
+ // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
9335
+ jsonDiff.useLongestToken = true;
9336
+
9337
+ jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff. /*istanbul ignore end*/tokenize;
9338
+ jsonDiff.castInput = function (value) {
9339
+ /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement;
9340
+
9341
+
9342
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
9343
+ if (typeof v === 'undefined') {
9344
+ return undefinedReplacement;
9065
9345
  }
9066
9346
 
9067
- return components;
9347
+ return v;
9348
+ }, ' ');
9349
+ };
9350
+ jsonDiff.equals = function (left, right) {
9351
+ return (/*istanbul ignore start*/_base2['default']. /*istanbul ignore end*/prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
9352
+ );
9353
+ };
9354
+
9355
+ function diffJson(oldObj, newObj, options) {
9356
+ return jsonDiff.diff(oldObj, newObj, options);
9357
+ }
9358
+
9359
+ // This function handles the presence of circular references by bailing out when encountering an
9360
+ // object that is already on the "stack" of items being processed.
9361
+ function canonicalize(obj, stack, replacementStack) {
9362
+ stack = stack || [];
9363
+ replacementStack = replacementStack || [];
9364
+
9365
+ var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9366
+
9367
+ for (i = 0; i < stack.length; i += 1) {
9368
+ if (stack[i] === obj) {
9369
+ return replacementStack[i];
9370
+ }
9068
9371
  }
9069
9372
 
9070
- function Diff(ignoreWhitespace) {
9071
- this.ignoreWhitespace = ignoreWhitespace;
9373
+ var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9374
+
9375
+ if ('[object Array]' === objectPrototypeToString.call(obj)) {
9376
+ stack.push(obj);
9377
+ canonicalizedObj = new Array(obj.length);
9378
+ replacementStack.push(canonicalizedObj);
9379
+ for (i = 0; i < obj.length; i += 1) {
9380
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
9381
+ }
9382
+ stack.pop();
9383
+ replacementStack.pop();
9384
+ return canonicalizedObj;
9072
9385
  }
9073
- Diff.prototype = {
9074
- diff: function(oldString, newString, callback) {
9075
- var self = this;
9076
9386
 
9077
- function done(value) {
9078
- if (callback) {
9079
- setTimeout(function() { callback(undefined, value); }, 0);
9080
- return true;
9081
- } else {
9082
- return value;
9083
- }
9084
- }
9387
+ if (obj && obj.toJSON) {
9388
+ obj = obj.toJSON();
9389
+ }
9085
9390
 
9086
- // Handle the identity case (this is due to unrolling editLength == 0
9087
- if (newString === oldString) {
9088
- return done([{ value: newString }]);
9089
- }
9090
- if (!newString) {
9091
- return done([{ value: oldString, removed: true }]);
9092
- }
9093
- if (!oldString) {
9094
- return done([{ value: newString, added: true }]);
9391
+ if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
9392
+ stack.push(obj);
9393
+ canonicalizedObj = {};
9394
+ replacementStack.push(canonicalizedObj);
9395
+ var sortedKeys = [],
9396
+ key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9397
+ for (key in obj) {
9398
+ /* istanbul ignore else */
9399
+ if (obj.hasOwnProperty(key)) {
9400
+ sortedKeys.push(key);
9095
9401
  }
9402
+ }
9403
+ sortedKeys.sort();
9404
+ for (i = 0; i < sortedKeys.length; i += 1) {
9405
+ key = sortedKeys[i];
9406
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
9407
+ }
9408
+ stack.pop();
9409
+ replacementStack.pop();
9410
+ } else {
9411
+ canonicalizedObj = obj;
9412
+ }
9413
+ return canonicalizedObj;
9414
+ }
9096
9415
 
9097
- newString = this.tokenize(newString);
9098
- oldString = this.tokenize(oldString);
9099
9416
 
9100
- var newLen = newString.length, oldLen = oldString.length;
9101
- var editLength = 1;
9102
- var maxEditLength = newLen + oldLen;
9103
- var bestPath = [{ newPos: -1, components: [] }];
9417
+ },{"./base":49,"./line":53}],53:[function(require,module,exports){
9418
+ /*istanbul ignore start*/'use strict';
9104
9419
 
9105
- // Seed editLength = 0, i.e. the content starts with the same values
9106
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
9107
- if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
9108
- // Identity per the equality and tokenizer
9109
- return done([{value: newString.join('')}]);
9110
- }
9420
+ exports.__esModule = true;
9421
+ exports.lineDiff = undefined;
9422
+ exports. /*istanbul ignore end*/diffLines = diffLines;
9423
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
9111
9424
 
9112
- // Main worker method. checks all permutations of a given edit length for acceptance.
9113
- function execEditLength() {
9114
- for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
9115
- var basePath;
9116
- var addPath = bestPath[diagonalPath - 1],
9117
- removePath = bestPath[diagonalPath + 1],
9118
- oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
9119
- if (addPath) {
9120
- // No one else is going to attempt to use this value, clear it
9121
- bestPath[diagonalPath - 1] = undefined;
9122
- }
9425
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9123
9426
 
9124
- var canAdd = addPath && addPath.newPos + 1 < newLen,
9125
- canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
9126
- if (!canAdd && !canRemove) {
9127
- // If this path is a terminal then prune
9128
- bestPath[diagonalPath] = undefined;
9129
- continue;
9130
- }
9427
+ /*istanbul ignore start*/
9428
+ var _base2 = _interopRequireDefault(_base);
9131
9429
 
9132
- // Select the diagonal that we want to branch from. We select the prior
9133
- // path whose position in the new string is the farthest from the origin
9134
- // and does not pass the bounds of the diff graph
9135
- if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
9136
- basePath = clonePath(removePath);
9137
- self.pushComponent(basePath.components, undefined, true);
9138
- } else {
9139
- basePath = addPath; // No need to clone, we've pulled it from the list
9140
- basePath.newPos++;
9141
- self.pushComponent(basePath.components, true, undefined);
9142
- }
9430
+ /*istanbul ignore end*/
9431
+ var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
9143
9432
 
9144
- oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
9433
+ /*istanbul ignore start*/
9434
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9145
9435
 
9146
- // If we have hit the end of both strings, then we are done
9147
- if (basePath.newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
9148
- return done(buildValues(basePath.components, newString, oldString, self.useLongestToken));
9149
- } else {
9150
- // Otherwise track this path as a potential candidate and continue.
9151
- bestPath[diagonalPath] = basePath;
9152
- }
9153
- }
9436
+ /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9437
+ lineDiff.tokenize = function (value) {
9438
+ var retLines = [],
9439
+ linesAndNewlines = value.split(/(\n|\r\n)/);
9154
9440
 
9155
- editLength++;
9156
- }
9441
+ // Ignore the final empty token that occurs if the string ends with a new line
9442
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
9443
+ linesAndNewlines.pop();
9444
+ }
9157
9445
 
9158
- // Performs the length of edit iteration. Is a bit fugly as this has to support the
9159
- // sync and async mode which is never fun. Loops over execEditLength until a value
9160
- // is produced.
9161
- if (callback) {
9162
- (function exec() {
9163
- setTimeout(function() {
9164
- // This should not happen, but we want to be safe.
9165
- /*istanbul ignore next */
9166
- if (editLength > maxEditLength) {
9167
- return callback();
9168
- }
9446
+ // Merge the content and line separators into single tokens
9447
+ for (var i = 0; i < linesAndNewlines.length; i++) {
9448
+ var line = linesAndNewlines[i];
9169
9449
 
9170
- if (!execEditLength()) {
9171
- exec();
9172
- }
9173
- }, 0);
9174
- }());
9175
- } else {
9176
- while (editLength <= maxEditLength) {
9177
- var ret = execEditLength();
9178
- if (ret) {
9179
- return ret;
9180
- }
9181
- }
9450
+ if (i % 2 && !this.options.newlineIsToken) {
9451
+ retLines[retLines.length - 1] += line;
9452
+ } else {
9453
+ if (this.options.ignoreWhitespace) {
9454
+ line = line.trim();
9182
9455
  }
9183
- },
9456
+ retLines.push(line);
9457
+ }
9458
+ }
9184
9459
 
9185
- pushComponent: function(components, added, removed) {
9186
- var last = components[components.length - 1];
9187
- if (last && last.added === added && last.removed === removed) {
9188
- // We need to clone here as the component clone operation is just
9189
- // as shallow array clone
9190
- components[components.length - 1] = {count: last.count + 1, added: added, removed: removed };
9191
- } else {
9192
- components.push({count: 1, added: added, removed: removed });
9193
- }
9194
- },
9195
- extractCommon: function(basePath, newString, oldString, diagonalPath) {
9196
- var newLen = newString.length,
9197
- oldLen = oldString.length,
9198
- newPos = basePath.newPos,
9199
- oldPos = newPos - diagonalPath,
9200
-
9201
- commonCount = 0;
9202
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
9203
- newPos++;
9204
- oldPos++;
9205
- commonCount++;
9206
- }
9460
+ return retLines;
9461
+ };
9207
9462
 
9208
- if (commonCount) {
9209
- basePath.components.push({count: commonCount});
9210
- }
9463
+ function diffLines(oldStr, newStr, callback) {
9464
+ return lineDiff.diff(oldStr, newStr, callback);
9465
+ }
9466
+ function diffTrimmedLines(oldStr, newStr, callback) {
9467
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
9468
+ return lineDiff.diff(oldStr, newStr, options);
9469
+ }
9211
9470
 
9212
- basePath.newPos = newPos;
9213
- return oldPos;
9214
- },
9215
9471
 
9216
- equals: function(left, right) {
9217
- var reWhitespace = /\S/;
9218
- return left === right || (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right));
9219
- },
9220
- tokenize: function(value) {
9221
- return value.split('');
9472
+ },{"../util/params":61,"./base":49}],54:[function(require,module,exports){
9473
+ /*istanbul ignore start*/'use strict';
9474
+
9475
+ exports.__esModule = true;
9476
+ exports.sentenceDiff = undefined;
9477
+ exports. /*istanbul ignore end*/diffSentences = diffSentences;
9478
+
9479
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9480
+
9481
+ /*istanbul ignore start*/
9482
+ var _base2 = _interopRequireDefault(_base);
9483
+
9484
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9485
+
9486
+ /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9487
+ sentenceDiff.tokenize = function (value) {
9488
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
9489
+ };
9490
+
9491
+ function diffSentences(oldStr, newStr, callback) {
9492
+ return sentenceDiff.diff(oldStr, newStr, callback);
9493
+ }
9494
+
9495
+
9496
+ },{"./base":49}],55:[function(require,module,exports){
9497
+ /*istanbul ignore start*/'use strict';
9498
+
9499
+ exports.__esModule = true;
9500
+ exports.wordDiff = undefined;
9501
+ exports. /*istanbul ignore end*/diffWords = diffWords;
9502
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
9503
+
9504
+ var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
9505
+
9506
+ /*istanbul ignore start*/
9507
+ var _base2 = _interopRequireDefault(_base);
9508
+
9509
+ /*istanbul ignore end*/
9510
+ var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
9511
+
9512
+ /*istanbul ignore start*/
9513
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9514
+
9515
+ /*istanbul ignore end*/
9516
+
9517
+ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
9518
+ //
9519
+ // Ranges and exceptions:
9520
+ // Latin-1 Supplement, 0080–00FF
9521
+ // - U+00D7 × Multiplication sign
9522
+ // - U+00F7 ÷ Division sign
9523
+ // Latin Extended-A, 0100–017F
9524
+ // Latin Extended-B, 0180–024F
9525
+ // IPA Extensions, 0250–02AF
9526
+ // Spacing Modifier Letters, 02B0–02FF
9527
+ // - U+02C7 ˇ &#711; Caron
9528
+ // - U+02D8 ˘ &#728; Breve
9529
+ // - U+02D9 ˙ &#729; Dot Above
9530
+ // - U+02DA ˚ &#730; Ring Above
9531
+ // - U+02DB ˛ &#731; Ogonek
9532
+ // - U+02DC ˜ &#732; Small Tilde
9533
+ // - U+02DD ˝ &#733; Double Acute Accent
9534
+ // Latin Extended Additional, 1E00–1EFF
9535
+ var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
9536
+
9537
+ var reWhitespace = /\S/;
9538
+
9539
+ var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
9540
+ wordDiff.equals = function (left, right) {
9541
+ return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
9542
+ };
9543
+ wordDiff.tokenize = function (value) {
9544
+ var tokens = value.split(/(\s+|\b)/);
9545
+
9546
+ // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
9547
+ for (var i = 0; i < tokens.length - 1; i++) {
9548
+ // If we have an empty string in the next field and we have only word chars before and after, merge
9549
+ if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
9550
+ tokens[i] += tokens[i + 2];
9551
+ tokens.splice(i + 1, 2);
9552
+ i--;
9222
9553
  }
9223
- };
9554
+ }
9224
9555
 
9225
- var CharDiff = new Diff();
9556
+ return tokens;
9557
+ };
9226
9558
 
9227
- var WordDiff = new Diff(true);
9228
- var WordWithSpaceDiff = new Diff();
9229
- WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {
9230
- return removeEmpty(value.split(/(\s+|\b)/));
9231
- };
9559
+ function diffWords(oldStr, newStr, callback) {
9560
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
9561
+ return wordDiff.diff(oldStr, newStr, options);
9562
+ }
9563
+ function diffWordsWithSpace(oldStr, newStr, callback) {
9564
+ return wordDiff.diff(oldStr, newStr, callback);
9565
+ }
9232
9566
 
9233
- var CssDiff = new Diff(true);
9234
- CssDiff.tokenize = function(value) {
9235
- return removeEmpty(value.split(/([{}:;,]|\s+)/));
9236
- };
9237
9567
 
9238
- var LineDiff = new Diff();
9568
+ },{"../util/params":61,"./base":49}],56:[function(require,module,exports){
9569
+ /*istanbul ignore start*/'use strict';
9239
9570
 
9240
- var TrimmedLineDiff = new Diff();
9241
- TrimmedLineDiff.ignoreTrim = true;
9571
+ exports.__esModule = true;
9572
+ 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;
9573
+ /*istanbul ignore end*/
9574
+ var /*istanbul ignore start*/_base = require('./diff/base') /*istanbul ignore end*/;
9242
9575
 
9243
- LineDiff.tokenize = TrimmedLineDiff.tokenize = function(value) {
9244
- var retLines = [],
9245
- lines = value.split(/^/m);
9246
- for (var i = 0; i < lines.length; i++) {
9247
- var line = lines[i],
9248
- lastLine = lines[i - 1],
9249
- lastLineLastChar = lastLine && lastLine[lastLine.length - 1];
9576
+ /*istanbul ignore start*/
9577
+ var _base2 = _interopRequireDefault(_base);
9250
9578
 
9251
- // Merge lines that may contain windows new lines
9252
- if (line === '\n' && lastLineLastChar === '\r') {
9253
- retLines[retLines.length - 1] = retLines[retLines.length - 1].slice(0, -1) + '\r\n';
9254
- } else {
9255
- if (this.ignoreTrim) {
9256
- line = line.trim();
9257
- // add a newline unless this is the last line.
9258
- if (i < lines.length - 1) {
9259
- line += '\n';
9579
+ /*istanbul ignore end*/
9580
+ var /*istanbul ignore start*/_character = require('./diff/character') /*istanbul ignore end*/;
9581
+
9582
+ var /*istanbul ignore start*/_word = require('./diff/word') /*istanbul ignore end*/;
9583
+
9584
+ var /*istanbul ignore start*/_line = require('./diff/line') /*istanbul ignore end*/;
9585
+
9586
+ var /*istanbul ignore start*/_sentence = require('./diff/sentence') /*istanbul ignore end*/;
9587
+
9588
+ var /*istanbul ignore start*/_css = require('./diff/css') /*istanbul ignore end*/;
9589
+
9590
+ var /*istanbul ignore start*/_json = require('./diff/json') /*istanbul ignore end*/;
9591
+
9592
+ var /*istanbul ignore start*/_array = require('./diff/array') /*istanbul ignore end*/;
9593
+
9594
+ var /*istanbul ignore start*/_apply = require('./patch/apply') /*istanbul ignore end*/;
9595
+
9596
+ var /*istanbul ignore start*/_parse = require('./patch/parse') /*istanbul ignore end*/;
9597
+
9598
+ var /*istanbul ignore start*/_create = require('./patch/create') /*istanbul ignore end*/;
9599
+
9600
+ var /*istanbul ignore start*/_dmp = require('./convert/dmp') /*istanbul ignore end*/;
9601
+
9602
+ var /*istanbul ignore start*/_xml = require('./convert/xml') /*istanbul ignore end*/;
9603
+
9604
+ /*istanbul ignore start*/
9605
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9606
+
9607
+ exports. /*istanbul ignore end*/Diff = _base2['default'];
9608
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
9609
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
9610
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
9611
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
9612
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
9613
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
9614
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
9615
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
9616
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
9617
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
9618
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
9619
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
9620
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
9621
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
9622
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
9623
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
9624
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
9625
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize; /* See LICENSE file for terms of use */
9626
+
9627
+ /*
9628
+ * Text diff implementation.
9629
+ *
9630
+ * This library supports the following APIS:
9631
+ * JsDiff.diffChars: Character by character diff
9632
+ * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
9633
+ * JsDiff.diffLines: Line based diff
9634
+ *
9635
+ * JsDiff.diffCss: Diff targeted at CSS content
9636
+ *
9637
+ * These methods are based on the implementation proposed in
9638
+ * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
9639
+ * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
9640
+ */
9641
+
9642
+
9643
+ },{"./convert/dmp":46,"./convert/xml":47,"./diff/array":48,"./diff/base":49,"./diff/character":50,"./diff/css":51,"./diff/json":52,"./diff/line":53,"./diff/sentence":54,"./diff/word":55,"./patch/apply":57,"./patch/create":58,"./patch/parse":59}],57:[function(require,module,exports){
9644
+ /*istanbul ignore start*/'use strict';
9645
+
9646
+ exports.__esModule = true;
9647
+ exports. /*istanbul ignore end*/applyPatch = applyPatch;
9648
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
9649
+
9650
+ var /*istanbul ignore start*/_parse = require('./parse') /*istanbul ignore end*/;
9651
+
9652
+ var /*istanbul ignore start*/_distanceIterator = require('../util/distance-iterator') /*istanbul ignore end*/;
9653
+
9654
+ /*istanbul ignore start*/
9655
+ var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
9656
+
9657
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9658
+
9659
+ /*istanbul ignore end*/function applyPatch(source, uniDiff) {
9660
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
9661
+
9662
+ if (typeof uniDiff === 'string') {
9663
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
9664
+ }
9665
+
9666
+ if (Array.isArray(uniDiff)) {
9667
+ if (uniDiff.length > 1) {
9668
+ throw new Error('applyPatch only works with a single input.');
9669
+ }
9670
+
9671
+ uniDiff = uniDiff[0];
9672
+ }
9673
+
9674
+ // Apply the diff to the input
9675
+ var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
9676
+ delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
9677
+ hunks = uniDiff.hunks,
9678
+ compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
9679
+ return (/*istanbul ignore end*/line === patchContent
9680
+ );
9681
+ },
9682
+ errorCount = 0,
9683
+ fuzzFactor = options.fuzzFactor || 0,
9684
+ minLine = 0,
9685
+ offset = 0,
9686
+ removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
9687
+ addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9688
+
9689
+ /**
9690
+ * Checks if the hunk exactly fits on the provided location
9691
+ */
9692
+ function hunkFits(hunk, toPos) {
9693
+ for (var j = 0; j < hunk.lines.length; j++) {
9694
+ var line = hunk.lines[j],
9695
+ operation = line[0],
9696
+ content = line.substr(1);
9697
+
9698
+ if (operation === ' ' || operation === '-') {
9699
+ // Context sanity check
9700
+ if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
9701
+ errorCount++;
9702
+
9703
+ if (errorCount > fuzzFactor) {
9704
+ return false;
9260
9705
  }
9261
9706
  }
9262
- retLines.push(line);
9707
+ toPos++;
9263
9708
  }
9264
9709
  }
9265
9710
 
9266
- return retLines;
9267
- };
9711
+ return true;
9712
+ }
9713
+
9714
+ // Search best fit offsets for each hunk based on the previous ones
9715
+ for (var i = 0; i < hunks.length; i++) {
9716
+ var hunk = hunks[i],
9717
+ maxLine = lines.length - hunk.oldLines,
9718
+ localOffset = 0,
9719
+ toPos = offset + hunk.oldStart - 1;
9268
9720
 
9269
- var PatchDiff = new Diff();
9270
- PatchDiff.tokenize = function(value) {
9271
- var ret = [],
9272
- linesAndNewlines = value.split(/(\n|\r\n)/);
9721
+ var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
9273
9722
 
9274
- // Ignore the final empty token that occurs if the string ends with a new line
9275
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
9276
- linesAndNewlines.pop();
9723
+ for (; localOffset !== undefined; localOffset = iterator()) {
9724
+ if (hunkFits(hunk, toPos + localOffset)) {
9725
+ hunk.offset = offset += localOffset;
9726
+ break;
9727
+ }
9277
9728
  }
9278
9729
 
9279
- // Merge the content and line separators into single tokens
9280
- for (var i = 0; i < linesAndNewlines.length; i++) {
9281
- var line = linesAndNewlines[i];
9730
+ if (localOffset === undefined) {
9731
+ return false;
9732
+ }
9282
9733
 
9283
- if (i % 2) {
9284
- ret[ret.length - 1] += line;
9285
- } else {
9286
- ret.push(line);
9287
- }
9734
+ // Set lower text limit to end of the current hunk, so next ones don't try
9735
+ // to fit over already patched text
9736
+ minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
9737
+ }
9738
+
9739
+ // Apply patch hunks
9740
+ for (var _i = 0; _i < hunks.length; _i++) {
9741
+ var _hunk = hunks[_i],
9742
+ _toPos = _hunk.offset + _hunk.newStart - 1;
9743
+ if (_hunk.newLines == 0) {
9744
+ _toPos++;
9745
+ }
9746
+
9747
+ for (var j = 0; j < _hunk.lines.length; j++) {
9748
+ var line = _hunk.lines[j],
9749
+ operation = line[0],
9750
+ content = line.substr(1),
9751
+ delimiter = _hunk.linedelimiters[j];
9752
+
9753
+ if (operation === ' ') {
9754
+ _toPos++;
9755
+ } else if (operation === '-') {
9756
+ lines.splice(_toPos, 1);
9757
+ delimiters.splice(_toPos, 1);
9758
+ /* istanbul ignore else */
9759
+ } else if (operation === '+') {
9760
+ lines.splice(_toPos, 0, content);
9761
+ delimiters.splice(_toPos, 0, delimiter);
9762
+ _toPos++;
9763
+ } else if (operation === '\\') {
9764
+ var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
9765
+ if (previousOperation === '+') {
9766
+ removeEOFNL = true;
9767
+ } else if (previousOperation === '-') {
9768
+ addEOFNL = true;
9769
+ }
9770
+ }
9288
9771
  }
9289
- return ret;
9290
- };
9772
+ }
9291
9773
 
9292
- var SentenceDiff = new Diff();
9293
- SentenceDiff.tokenize = function(value) {
9294
- return removeEmpty(value.split(/(\S.+?[.!?])(?=\s+|$)/));
9295
- };
9774
+ // Handle EOFNL insertion/removal
9775
+ if (removeEOFNL) {
9776
+ while (!lines[lines.length - 1]) {
9777
+ lines.pop();
9778
+ delimiters.pop();
9779
+ }
9780
+ } else if (addEOFNL) {
9781
+ lines.push('');
9782
+ delimiters.push('\n');
9783
+ }
9784
+ for (var _k = 0; _k < lines.length - 1; _k++) {
9785
+ lines[_k] = lines[_k] + delimiters[_k];
9786
+ }
9787
+ return lines.join('');
9788
+ }
9296
9789
 
9297
- var JsonDiff = new Diff();
9298
- // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
9299
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
9300
- JsonDiff.useLongestToken = true;
9301
- JsonDiff.tokenize = LineDiff.tokenize;
9302
- JsonDiff.equals = function(left, right) {
9303
- return LineDiff.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
9304
- };
9790
+ // Wrapper that supports multiple file patches via callbacks.
9791
+ function applyPatches(uniDiff, options) {
9792
+ if (typeof uniDiff === 'string') {
9793
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
9794
+ }
9305
9795
 
9306
- var JsDiff = {
9307
- Diff: Diff,
9796
+ var currentIndex = 0;
9797
+ function processIndex() {
9798
+ var index = uniDiff[currentIndex++];
9799
+ if (!index) {
9800
+ return options.complete();
9801
+ }
9308
9802
 
9309
- diffChars: function(oldStr, newStr, callback) { return CharDiff.diff(oldStr, newStr, callback); },
9310
- diffWords: function(oldStr, newStr, callback) { return WordDiff.diff(oldStr, newStr, callback); },
9311
- diffWordsWithSpace: function(oldStr, newStr, callback) { return WordWithSpaceDiff.diff(oldStr, newStr, callback); },
9312
- diffLines: function(oldStr, newStr, callback) { return LineDiff.diff(oldStr, newStr, callback); },
9313
- diffTrimmedLines: function(oldStr, newStr, callback) { return TrimmedLineDiff.diff(oldStr, newStr, callback); },
9803
+ options.loadFile(index, function (err, data) {
9804
+ if (err) {
9805
+ return options.complete(err);
9806
+ }
9314
9807
 
9315
- diffSentences: function(oldStr, newStr, callback) { return SentenceDiff.diff(oldStr, newStr, callback); },
9808
+ var updatedContent = applyPatch(data, index, options);
9809
+ options.patched(index, updatedContent, function (err) {
9810
+ if (err) {
9811
+ return options.complete(err);
9812
+ }
9316
9813
 
9317
- diffCss: function(oldStr, newStr, callback) { return CssDiff.diff(oldStr, newStr, callback); },
9318
- diffJson: function(oldObj, newObj, callback) {
9319
- return JsonDiff.diff(
9320
- typeof oldObj === 'string' ? oldObj : JSON.stringify(canonicalize(oldObj), undefined, ' '),
9321
- typeof newObj === 'string' ? newObj : JSON.stringify(canonicalize(newObj), undefined, ' '),
9322
- callback
9323
- );
9324
- },
9814
+ processIndex();
9815
+ });
9816
+ });
9817
+ }
9818
+ processIndex();
9819
+ }
9325
9820
 
9326
- createTwoFilesPatch: function(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader) {
9327
- var ret = [];
9328
9821
 
9329
- if (oldFileName == newFileName) {
9330
- ret.push('Index: ' + oldFileName);
9331
- }
9332
- ret.push('===================================================================');
9333
- ret.push('--- ' + oldFileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader));
9334
- ret.push('+++ ' + newFileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader));
9822
+ },{"../util/distance-iterator":60,"./parse":59}],58:[function(require,module,exports){
9823
+ /*istanbul ignore start*/'use strict';
9335
9824
 
9336
- var diff = PatchDiff.diff(oldStr, newStr);
9337
- diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier
9825
+ exports.__esModule = true;
9826
+ exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
9827
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
9828
+ /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
9338
9829
 
9339
- // Formats a given set of lines for printing as context lines in a patch
9340
- function contextLines(lines) {
9341
- return map(lines, function(entry) { return ' ' + entry; });
9342
- }
9830
+ var /*istanbul ignore start*/_line = require('../diff/line') /*istanbul ignore end*/;
9343
9831
 
9344
- // Outputs the no newline at end of file warning if needed
9345
- function eofNL(curRange, i, current) {
9346
- var last = diff[diff.length - 2],
9347
- isLast = i === diff.length - 2,
9348
- isLastOfType = i === diff.length - 3 && current.added !== last.added;
9832
+ /*istanbul ignore start*/
9833
+ 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); } }
9349
9834
 
9350
- // Figure out if this is the last line for the given file and missing NL
9351
- if (!(/\n$/.test(current.value)) && (isLast || isLastOfType)) {
9352
- curRange.push('\');
9835
+ /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
9836
+ if (!options) {
9837
+ options = {};
9838
+ }
9839
+ if (typeof options.context === 'undefined') {
9840
+ options.context = 4;
9841
+ }
9842
+
9843
+ var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
9844
+ diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
9845
+
9846
+ function contextLines(lines) {
9847
+ return lines.map(function (entry) {
9848
+ return ' ' + entry;
9849
+ });
9850
+ }
9851
+
9852
+ var hunks = [];
9853
+ var oldRangeStart = 0,
9854
+ newRangeStart = 0,
9855
+ curRange = [],
9856
+ oldLine = 1,
9857
+ newLine = 1;
9858
+ /*istanbul ignore start*/
9859
+ var _loop = function _loop( /*istanbul ignore end*/i) {
9860
+ var current = diff[i],
9861
+ lines = current.lines || current.value.replace(/\n$/, '').split('\n');
9862
+ current.lines = lines;
9863
+
9864
+ if (current.added || current.removed) {
9865
+ /*istanbul ignore start*/
9866
+ var _curRange;
9867
+
9868
+ /*istanbul ignore end*/
9869
+ // If we have previous context, start with that
9870
+ if (!oldRangeStart) {
9871
+ var prev = diff[i - 1];
9872
+ oldRangeStart = oldLine;
9873
+ newRangeStart = newLine;
9874
+
9875
+ if (prev) {
9876
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
9877
+ oldRangeStart -= curRange.length;
9878
+ newRangeStart -= curRange.length;
9353
9879
  }
9354
9880
  }
9355
9881
 
9356
- var oldRangeStart = 0, newRangeStart = 0, curRange = [],
9357
- oldLine = 1, newLine = 1;
9358
- for (var i = 0; i < diff.length; i++) {
9359
- var current = diff[i],
9360
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
9361
- current.lines = lines;
9362
-
9363
- if (current.added || current.removed) {
9364
- // If we have previous context, start with that
9365
- if (!oldRangeStart) {
9366
- var prev = diff[i - 1];
9367
- oldRangeStart = oldLine;
9368
- newRangeStart = newLine;
9369
-
9370
- if (prev) {
9371
- curRange = contextLines(prev.lines.slice(-4));
9372
- oldRangeStart -= curRange.length;
9373
- newRangeStart -= curRange.length;
9374
- }
9375
- }
9376
-
9377
- // Output our changes
9378
- curRange.push.apply(curRange, map(lines, function(entry) {
9379
- return (current.added ? '+' : '-') + entry;
9380
- }));
9381
- eofNL(curRange, i, current);
9882
+ // Output our changes
9883
+ /*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) {
9884
+ return (current.added ? '+' : '-') + entry;
9885
+ })));
9382
9886
 
9383
- // Track the updated file position
9384
- if (current.added) {
9385
- newLine += lines.length;
9386
- } else {
9387
- oldLine += lines.length;
9388
- }
9887
+ // Track the updated file position
9888
+ if (current.added) {
9889
+ newLine += lines.length;
9890
+ } else {
9891
+ oldLine += lines.length;
9892
+ }
9893
+ } else {
9894
+ // Identical context lines. Track line changes
9895
+ if (oldRangeStart) {
9896
+ // Close out any changes that have been output (or join overlapping)
9897
+ if (lines.length <= options.context * 2 && i < diff.length - 2) {
9898
+ /*istanbul ignore start*/
9899
+ var _curRange2;
9900
+
9901
+ /*istanbul ignore end*/
9902
+ // Overlapping
9903
+ /*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)));
9389
9904
  } else {
9390
- // Identical context lines. Track line changes
9391
- if (oldRangeStart) {
9392
- // Close out any changes that have been output (or join overlapping)
9393
- if (lines.length <= 8 && i < diff.length - 2) {
9394
- // Overlapping
9395
- curRange.push.apply(curRange, contextLines(lines));
9396
- } else {
9397
- // end the range and output
9398
- var contextSize = Math.min(lines.length, 4);
9399
- ret.push(
9400
- '@@ -' + oldRangeStart + ',' + (oldLine - oldRangeStart + contextSize)
9401
- + ' +' + newRangeStart + ',' + (newLine - newRangeStart + contextSize)
9402
- + ' @@');
9403
- ret.push.apply(ret, curRange);
9404
- ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
9405
- if (lines.length <= 4) {
9406
- eofNL(ret, i, current);
9407
- }
9408
-
9409
- oldRangeStart = 0;
9410
- newRangeStart = 0;
9411
- curRange = [];
9905
+ /*istanbul ignore start*/
9906
+ var _curRange3;
9907
+
9908
+ /*istanbul ignore end*/
9909
+ // end the range and output
9910
+ var contextSize = Math.min(lines.length, options.context);
9911
+ /*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))));
9912
+
9913
+ var hunk = {
9914
+ oldStart: oldRangeStart,
9915
+ oldLines: oldLine - oldRangeStart + contextSize,
9916
+ newStart: newRangeStart,
9917
+ newLines: newLine - newRangeStart + contextSize,
9918
+ lines: curRange
9919
+ };
9920
+ if (i >= diff.length - 2 && lines.length <= options.context) {
9921
+ // EOF is inside this hunk
9922
+ var oldEOFNewline = /\n$/.test(oldStr);
9923
+ var newEOFNewline = /\n$/.test(newStr);
9924
+ if (lines.length == 0 && !oldEOFNewline) {
9925
+ // special case: old has no eol and no trailing context; no-nl can end up before adds
9926
+ curRange.splice(hunk.oldLines, 0, '\');
9927
+ } else if (!oldEOFNewline || !newEOFNewline) {
9928
+ curRange.push('\');
9412
9929
  }
9413
9930
  }
9414
- oldLine += lines.length;
9415
- newLine += lines.length;
9931
+ hunks.push(hunk);
9932
+
9933
+ oldRangeStart = 0;
9934
+ newRangeStart = 0;
9935
+ curRange = [];
9416
9936
  }
9417
9937
  }
9938
+ oldLine += lines.length;
9939
+ newLine += lines.length;
9940
+ }
9941
+ };
9418
9942
 
9419
- return ret.join('\n') + '\n';
9420
- },
9943
+ for (var i = 0; i < diff.length; i++) {
9944
+ /*istanbul ignore start*/
9945
+ _loop( /*istanbul ignore end*/i);
9946
+ }
9421
9947
 
9422
- createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
9423
- return JsDiff.createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader);
9424
- },
9948
+ return {
9949
+ oldFileName: oldFileName, newFileName: newFileName,
9950
+ oldHeader: oldHeader, newHeader: newHeader,
9951
+ hunks: hunks
9952
+ };
9953
+ }
9425
9954
 
9426
- applyPatch: function(oldStr, uniDiff) {
9427
- var diffstr = uniDiff.split('\n'),
9428
- hunks = [],
9429
- i = 0,
9430
- remEOFNL = false,
9431
- addEOFNL = false;
9955
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
9956
+ var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
9432
9957
 
9433
- // Skip to the first change hunk
9434
- while (i < diffstr.length && !(/^@@/.test(diffstr[i]))) {
9435
- i++;
9958
+ var ret = [];
9959
+ if (oldFileName == newFileName) {
9960
+ ret.push('Index: ' + oldFileName);
9961
+ }
9962
+ ret.push('===================================================================');
9963
+ ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
9964
+ ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
9965
+
9966
+ for (var i = 0; i < diff.hunks.length; i++) {
9967
+ var hunk = diff.hunks[i];
9968
+ ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
9969
+ ret.push.apply(ret, hunk.lines);
9970
+ }
9971
+
9972
+ return ret.join('\n') + '\n';
9973
+ }
9974
+
9975
+ function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
9976
+ return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
9977
+ }
9978
+
9979
+
9980
+ },{"../diff/line":53}],59:[function(require,module,exports){
9981
+ /*istanbul ignore start*/'use strict';
9982
+
9983
+ exports.__esModule = true;
9984
+ exports. /*istanbul ignore end*/parsePatch = parsePatch;
9985
+ function parsePatch(uniDiff) {
9986
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
9987
+
9988
+ var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
9989
+ delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
9990
+ list = [],
9991
+ i = 0;
9992
+
9993
+ function parseIndex() {
9994
+ var index = {};
9995
+ list.push(index);
9996
+
9997
+ // Parse diff metadata
9998
+ while (i < diffstr.length) {
9999
+ var line = diffstr[i];
10000
+
10001
+ // File header found, end parsing diff metadata
10002
+ if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
10003
+ break;
9436
10004
  }
9437
10005
 
9438
- // Parse the unified diff
9439
- for (; i < diffstr.length; i++) {
9440
- if (diffstr[i][0] === '@') {
9441
- var chnukHeader = diffstr[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
9442
- hunks.unshift({
9443
- start: chnukHeader[3],
9444
- oldlength: +chnukHeader[2],
9445
- removed: [],
9446
- newlength: chnukHeader[4],
9447
- added: []
9448
- });
9449
- } else if (diffstr[i][0] === '+') {
9450
- hunks[0].added.push(diffstr[i].substr(1));
9451
- } else if (diffstr[i][0] === '-') {
9452
- hunks[0].removed.push(diffstr[i].substr(1));
9453
- } else if (diffstr[i][0] === ' ') {
9454
- hunks[0].added.push(diffstr[i].substr(1));
9455
- hunks[0].removed.push(diffstr[i].substr(1));
9456
- } else if (diffstr[i][0] === '\\') {
9457
- if (diffstr[i - 1][0] === '+') {
9458
- remEOFNL = true;
9459
- } else if (diffstr[i - 1][0] === '-') {
9460
- addEOFNL = true;
9461
- }
9462
- }
10006
+ // Diff index
10007
+ var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
10008
+ if (header) {
10009
+ index.index = header[1];
9463
10010
  }
9464
10011
 
9465
- // Apply the diff to the input
9466
- var lines = oldStr.split('\n');
9467
- for (i = hunks.length - 1; i >= 0; i--) {
9468
- var hunk = hunks[i];
9469
- // Sanity check the input string. Bail if we don't match.
9470
- for (var j = 0; j < hunk.oldlength; j++) {
9471
- if (lines[hunk.start - 1 + j] !== hunk.removed[j]) {
9472
- return false;
9473
- }
9474
- }
9475
- Array.prototype.splice.apply(lines, [hunk.start - 1, hunk.oldlength].concat(hunk.added));
10012
+ i++;
10013
+ }
10014
+
10015
+ // Parse file headers if they are defined. Unified diff requires them, but
10016
+ // there's no technical issues to have an isolated hunk without file header
10017
+ parseFileHeader(index);
10018
+ parseFileHeader(index);
10019
+
10020
+ // Parse hunks
10021
+ index.hunks = [];
10022
+
10023
+ while (i < diffstr.length) {
10024
+ var _line = diffstr[i];
10025
+
10026
+ if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
10027
+ break;
10028
+ } else if (/^@@/.test(_line)) {
10029
+ index.hunks.push(parseHunk());
10030
+ } else if (_line && options.strict) {
10031
+ // Ignore unexpected content unless in strict mode
10032
+ throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
10033
+ } else {
10034
+ i++;
9476
10035
  }
10036
+ }
10037
+ }
10038
+
10039
+ // Parses the --- and +++ headers, if none are found, no lines
10040
+ // are consumed.
10041
+ function parseFileHeader(index) {
10042
+ var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
10043
+ var fileHeader = headerPattern.exec(diffstr[i]);
10044
+ if (fileHeader) {
10045
+ var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
10046
+ index[keyPrefix + 'FileName'] = fileHeader[2];
10047
+ index[keyPrefix + 'Header'] = fileHeader[3];
9477
10048
 
9478
- // Handle EOFNL insertion/removal
9479
- if (remEOFNL) {
9480
- while (!lines[lines.length - 1]) {
9481
- lines.pop();
10049
+ i++;
10050
+ }
10051
+ }
10052
+
10053
+ // Parses a hunk
10054
+ // This assumes that we are at the start of a hunk.
10055
+ function parseHunk() {
10056
+ var chunkHeaderIndex = i,
10057
+ chunkHeaderLine = diffstr[i++],
10058
+ chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
10059
+
10060
+ var hunk = {
10061
+ oldStart: +chunkHeader[1],
10062
+ oldLines: +chunkHeader[2] || 1,
10063
+ newStart: +chunkHeader[3],
10064
+ newLines: +chunkHeader[4] || 1,
10065
+ lines: [],
10066
+ linedelimiters: []
10067
+ };
10068
+
10069
+ var addCount = 0,
10070
+ removeCount = 0;
10071
+ for (; i < diffstr.length; i++) {
10072
+ // Lines starting with '---' could be mistaken for the "remove line" operation
10073
+ // But they could be the header for the next file. Therefore prune such cases out.
10074
+ if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
10075
+ break;
10076
+ }
10077
+ var operation = diffstr[i][0];
10078
+
10079
+ if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
10080
+ hunk.lines.push(diffstr[i]);
10081
+ hunk.linedelimiters.push(delimiters[i] || '\n');
10082
+
10083
+ if (operation === '+') {
10084
+ addCount++;
10085
+ } else if (operation === '-') {
10086
+ removeCount++;
10087
+ } else if (operation === ' ') {
10088
+ addCount++;
10089
+ removeCount++;
9482
10090
  }
9483
- } else if (addEOFNL) {
9484
- lines.push('');
10091
+ } else {
10092
+ break;
9485
10093
  }
9486
- return lines.join('\n');
9487
- },
10094
+ }
9488
10095
 
9489
- convertChangesToXML: function(changes) {
9490
- var ret = [];
9491
- for (var i = 0; i < changes.length; i++) {
9492
- var change = changes[i];
9493
- if (change.added) {
9494
- ret.push('<ins>');
9495
- } else if (change.removed) {
9496
- ret.push('<del>');
9497
- }
10096
+ // Handle the empty block count case
10097
+ if (!addCount && hunk.newLines === 1) {
10098
+ hunk.newLines = 0;
10099
+ }
10100
+ if (!removeCount && hunk.oldLines === 1) {
10101
+ hunk.oldLines = 0;
10102
+ }
9498
10103
 
9499
- ret.push(escapeHTML(change.value));
10104
+ // Perform optional sanity checking
10105
+ if (options.strict) {
10106
+ if (addCount !== hunk.newLines) {
10107
+ throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
10108
+ }
10109
+ if (removeCount !== hunk.oldLines) {
10110
+ throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
10111
+ }
10112
+ }
9500
10113
 
9501
- if (change.added) {
9502
- ret.push('</ins>');
9503
- } else if (change.removed) {
9504
- ret.push('</del>');
9505
- }
10114
+ return hunk;
10115
+ }
10116
+
10117
+ while (i < diffstr.length) {
10118
+ parseIndex();
10119
+ }
10120
+
10121
+ return list;
10122
+ }
10123
+
10124
+
10125
+ },{}],60:[function(require,module,exports){
10126
+ /*istanbul ignore start*/"use strict";
10127
+
10128
+ exports.__esModule = true;
10129
+
10130
+ exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
10131
+ var wantForward = true,
10132
+ backwardExhausted = false,
10133
+ forwardExhausted = false,
10134
+ localOffset = 1;
10135
+
10136
+ return function iterator() {
10137
+ if (wantForward && !forwardExhausted) {
10138
+ if (backwardExhausted) {
10139
+ localOffset++;
10140
+ } else {
10141
+ wantForward = false;
9506
10142
  }
9507
- return ret.join('');
9508
- },
9509
10143
 
9510
- // See: http://code.google.com/p/google-diff-match-patch/wiki/API
9511
- convertChangesToDMP: function(changes) {
9512
- var ret = [],
9513
- change,
9514
- operation;
9515
- for (var i = 0; i < changes.length; i++) {
9516
- change = changes[i];
9517
- if (change.added) {
9518
- operation = 1;
9519
- } else if (change.removed) {
9520
- operation = -1;
9521
- } else {
9522
- operation = 0;
9523
- }
10144
+ // Check if trying to fit beyond text length, and if not, check it fits
10145
+ // after offset location (or desired location on first iteration)
10146
+ if (start + localOffset <= maxLine) {
10147
+ return localOffset;
10148
+ }
10149
+
10150
+ forwardExhausted = true;
10151
+ }
9524
10152
 
9525
- ret.push([operation, change.value]);
10153
+ if (!backwardExhausted) {
10154
+ if (!forwardExhausted) {
10155
+ wantForward = true;
10156
+ }
10157
+
10158
+ // Check if trying to fit before text beginning, and if not, check it fits
10159
+ // before offset location
10160
+ if (minLine <= start - localOffset) {
10161
+ return -localOffset++;
9526
10162
  }
9527
- return ret;
9528
- },
9529
10163
 
9530
- canonicalize: canonicalize
10164
+ backwardExhausted = true;
10165
+ return iterator();
10166
+ }
10167
+
10168
+ // We tried to fit hunk before text beginning and beyond text lenght, then
10169
+ // hunk can't fit on the text. Return undefined
9531
10170
  };
10171
+ };
10172
+
9532
10173
 
9533
- /*istanbul ignore next */
9534
- /*global module */
9535
- if (typeof module !== 'undefined' && module.exports) {
9536
- module.exports = JsDiff;
9537
- } else if (false) {
9538
- /*global define */
9539
- define([], function() { return JsDiff; });
9540
- } else if (typeof global.JsDiff === 'undefined') {
9541
- global.JsDiff = JsDiff;
10174
+ },{}],61:[function(require,module,exports){
10175
+ /*istanbul ignore start*/'use strict';
10176
+
10177
+ exports.__esModule = true;
10178
+ exports. /*istanbul ignore end*/generateOptions = generateOptions;
10179
+ function generateOptions(options, defaults) {
10180
+ if (typeof options === 'function') {
10181
+ defaults.callback = options;
10182
+ } else if (options) {
10183
+ for (var name in options) {
10184
+ /* istanbul ignore else */
10185
+ if (options.hasOwnProperty(name)) {
10186
+ defaults[name] = options[name];
10187
+ }
10188
+ }
9542
10189
  }
9543
- }(this));
10190
+ return defaults;
10191
+ }
9544
10192
 
9545
- },{}],47:[function(require,module,exports){
10193
+
10194
+ },{}],62:[function(require,module,exports){
9546
10195
  'use strict';
9547
10196
 
9548
10197
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
@@ -9555,7 +10204,7 @@ module.exports = function (str) {
9555
10204
  return str.replace(matchOperatorsRe, '\\$&');
9556
10205
  };
9557
10206
 
9558
- },{}],48:[function(require,module,exports){
10207
+ },{}],63:[function(require,module,exports){
9559
10208
  // Copyright Joyent, Inc. and other Node contributors.
9560
10209
  //
9561
10210
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -9859,7 +10508,7 @@ function isUndefined(arg) {
9859
10508
  return arg === void 0;
9860
10509
  }
9861
10510
 
9862
- },{}],49:[function(require,module,exports){
10511
+ },{}],64:[function(require,module,exports){
9863
10512
  (function (process){
9864
10513
  // Growl - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
9865
10514
 
@@ -10153,7 +10802,7 @@ function growl(msg, options, fn) {
10153
10802
  };
10154
10803
 
10155
10804
  }).call(this,require('_process'))
10156
- },{"_process":67,"child_process":42,"fs":42,"os":65,"path":42}],50:[function(require,module,exports){
10805
+ },{"_process":82,"child_process":42,"fs":42,"os":80,"path":42}],65:[function(require,module,exports){
10157
10806
  exports.read = function (buffer, offset, isLE, mLen, nBytes) {
10158
10807
  var e, m
10159
10808
  var eLen = nBytes * 8 - mLen - 1
@@ -10239,7 +10888,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
10239
10888
  buffer[offset + i - d] |= s * 128
10240
10889
  }
10241
10890
 
10242
- },{}],51:[function(require,module,exports){
10891
+ },{}],66:[function(require,module,exports){
10243
10892
  if (typeof Object.create === 'function') {
10244
10893
  // implementation from standard node.js 'util' module
10245
10894
  module.exports = function inherits(ctor, superCtor) {
@@ -10264,7 +10913,7 @@ if (typeof Object.create === 'function') {
10264
10913
  }
10265
10914
  }
10266
10915
 
10267
- },{}],52:[function(require,module,exports){
10916
+ },{}],67:[function(require,module,exports){
10268
10917
  /*!
10269
10918
  * Determine if an object is a Buffer
10270
10919
  *
@@ -10287,14 +10936,14 @@ function isSlowBuffer (obj) {
10287
10936
  return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
10288
10937
  }
10289
10938
 
10290
- },{}],53:[function(require,module,exports){
10939
+ },{}],68:[function(require,module,exports){
10291
10940
  var toString = {}.toString;
10292
10941
 
10293
10942
  module.exports = Array.isArray || function (arr) {
10294
10943
  return toString.call(arr) == '[object Array]';
10295
10944
  };
10296
10945
 
10297
- },{}],54:[function(require,module,exports){
10946
+ },{}],69:[function(require,module,exports){
10298
10947
  (function (global){
10299
10948
  /*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
10300
10949
  ;(function () {
@@ -11200,7 +11849,7 @@ module.exports = Array.isArray || function (arr) {
11200
11849
  }).call(this);
11201
11850
 
11202
11851
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
11203
- },{}],55:[function(require,module,exports){
11852
+ },{}],70:[function(require,module,exports){
11204
11853
  /**
11205
11854
  * lodash 3.2.0 (Custom Build) <https://lodash.com/>
11206
11855
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11229,7 +11878,7 @@ function baseAssign(object, source) {
11229
11878
 
11230
11879
  module.exports = baseAssign;
11231
11880
 
11232
- },{"lodash._basecopy":56,"lodash.keys":63}],56:[function(require,module,exports){
11881
+ },{"lodash._basecopy":71,"lodash.keys":78}],71:[function(require,module,exports){
11233
11882
  /**
11234
11883
  * lodash 3.0.1 (Custom Build) <https://lodash.com/>
11235
11884
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11263,7 +11912,7 @@ function baseCopy(source, props, object) {
11263
11912
 
11264
11913
  module.exports = baseCopy;
11265
11914
 
11266
- },{}],57:[function(require,module,exports){
11915
+ },{}],72:[function(require,module,exports){
11267
11916
  /**
11268
11917
  * lodash 3.0.3 (Custom Build) <https://lodash.com/>
11269
11918
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11322,7 +11971,7 @@ function isObject(value) {
11322
11971
 
11323
11972
  module.exports = baseCreate;
11324
11973
 
11325
- },{}],58:[function(require,module,exports){
11974
+ },{}],73:[function(require,module,exports){
11326
11975
  /**
11327
11976
  * lodash 3.9.1 (Custom Build) <https://lodash.com/>
11328
11977
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11461,7 +12110,7 @@ function isNative(value) {
11461
12110
 
11462
12111
  module.exports = getNative;
11463
12112
 
11464
- },{}],59:[function(require,module,exports){
12113
+ },{}],74:[function(require,module,exports){
11465
12114
  /**
11466
12115
  * lodash 3.0.9 (Custom Build) <https://lodash.com/>
11467
12116
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11595,7 +12244,7 @@ function isObject(value) {
11595
12244
 
11596
12245
  module.exports = isIterateeCall;
11597
12246
 
11598
- },{}],60:[function(require,module,exports){
12247
+ },{}],75:[function(require,module,exports){
11599
12248
  /**
11600
12249
  * lodash 3.1.1 (Custom Build) <https://lodash.com/>
11601
12250
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -11652,7 +12301,7 @@ function create(prototype, properties, guard) {
11652
12301
 
11653
12302
  module.exports = create;
11654
12303
 
11655
- },{"lodash._baseassign":55,"lodash._basecreate":57,"lodash._isiterateecall":59}],61:[function(require,module,exports){
12304
+ },{"lodash._baseassign":70,"lodash._basecreate":72,"lodash._isiterateecall":74}],76:[function(require,module,exports){
11656
12305
  /**
11657
12306
  * lodash (Custom Build) <https://lodash.com/>
11658
12307
  * Build: `lodash modularize exports="npm" -o ./`
@@ -11883,7 +12532,7 @@ function isObjectLike(value) {
11883
12532
 
11884
12533
  module.exports = isArguments;
11885
12534
 
11886
- },{}],62:[function(require,module,exports){
12535
+ },{}],77:[function(require,module,exports){
11887
12536
  /**
11888
12537
  * lodash 3.0.4 (Custom Build) <https://lodash.com/>
11889
12538
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -12065,7 +12714,7 @@ function isNative(value) {
12065
12714
 
12066
12715
  module.exports = isArray;
12067
12716
 
12068
- },{}],63:[function(require,module,exports){
12717
+ },{}],78:[function(require,module,exports){
12069
12718
  /**
12070
12719
  * lodash 3.1.2 (Custom Build) <https://lodash.com/>
12071
12720
  * Build: `lodash modern modularize exports="npm" -o ./`
@@ -12303,7 +12952,7 @@ function keysIn(object) {
12303
12952
 
12304
12953
  module.exports = keys;
12305
12954
 
12306
- },{"lodash._getnative":58,"lodash.isarguments":61,"lodash.isarray":62}],64:[function(require,module,exports){
12955
+ },{"lodash._getnative":73,"lodash.isarguments":76,"lodash.isarray":77}],79:[function(require,module,exports){
12307
12956
  (function (process){
12308
12957
  var path = require('path');
12309
12958
  var fs = require('fs');
@@ -12405,7 +13054,7 @@ mkdirP.sync = function sync (p, opts, made) {
12405
13054
  };
12406
13055
 
12407
13056
  }).call(this,require('_process'))
12408
- },{"_process":67,"fs":42,"path":42}],65:[function(require,module,exports){
13057
+ },{"_process":82,"fs":42,"path":42}],80:[function(require,module,exports){
12409
13058
  exports.endianness = function () { return 'LE' };
12410
13059
 
12411
13060
  exports.hostname = function () {
@@ -12452,7 +13101,7 @@ exports.tmpdir = exports.tmpDir = function () {
12452
13101
 
12453
13102
  exports.EOL = '\n';
12454
13103
 
12455
- },{}],66:[function(require,module,exports){
13104
+ },{}],81:[function(require,module,exports){
12456
13105
  (function (process){
12457
13106
  'use strict';
12458
13107
 
@@ -12499,7 +13148,7 @@ function nextTick(fn, arg1, arg2, arg3) {
12499
13148
  }
12500
13149
 
12501
13150
  }).call(this,require('_process'))
12502
- },{"_process":67}],67:[function(require,module,exports){
13151
+ },{"_process":82}],82:[function(require,module,exports){
12503
13152
  // shim for using process in browser
12504
13153
  var process = module.exports = {};
12505
13154
 
@@ -12681,10 +13330,10 @@ process.chdir = function (dir) {
12681
13330
  };
12682
13331
  process.umask = function() { return 0; };
12683
13332
 
12684
- },{}],68:[function(require,module,exports){
13333
+ },{}],83:[function(require,module,exports){
12685
13334
  module.exports = require("./lib/_stream_duplex.js")
12686
13335
 
12687
- },{"./lib/_stream_duplex.js":69}],69:[function(require,module,exports){
13336
+ },{"./lib/_stream_duplex.js":84}],84:[function(require,module,exports){
12688
13337
  // a duplex stream is just a stream that is both readable and writable.
12689
13338
  // Since JS doesn't have multiple prototypal inheritance, this class
12690
13339
  // prototypally inherits from Readable, and then parasitically from
@@ -12760,7 +13409,7 @@ function forEach(xs, f) {
12760
13409
  f(xs[i], i);
12761
13410
  }
12762
13411
  }
12763
- },{"./_stream_readable":71,"./_stream_writable":73,"core-util-is":45,"inherits":51,"process-nextick-args":66}],70:[function(require,module,exports){
13412
+ },{"./_stream_readable":86,"./_stream_writable":88,"core-util-is":45,"inherits":66,"process-nextick-args":81}],85:[function(require,module,exports){
12764
13413
  // a passthrough stream.
12765
13414
  // basically just the most minimal sort of Transform stream.
12766
13415
  // Every written chunk gets output as-is.
@@ -12787,7 +13436,7 @@ function PassThrough(options) {
12787
13436
  PassThrough.prototype._transform = function (chunk, encoding, cb) {
12788
13437
  cb(null, chunk);
12789
13438
  };
12790
- },{"./_stream_transform":72,"core-util-is":45,"inherits":51}],71:[function(require,module,exports){
13439
+ },{"./_stream_transform":87,"core-util-is":45,"inherits":66}],86:[function(require,module,exports){
12791
13440
  (function (process){
12792
13441
  'use strict';
12793
13442
 
@@ -13727,7 +14376,7 @@ function indexOf(xs, x) {
13727
14376
  return -1;
13728
14377
  }
13729
14378
  }).call(this,require('_process'))
13730
- },{"./_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){
14379
+ },{"./_stream_duplex":84,"./internal/streams/BufferList":89,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"isarray":68,"process-nextick-args":81,"string_decoder/":95,"util":40}],87:[function(require,module,exports){
13731
14380
  // a transform stream is a readable/writable stream where you do
13732
14381
  // something with the data. Sometimes it's called a "filter",
13733
14382
  // but that's not a great name for it, since that implies a thing where
@@ -13908,7 +14557,7 @@ function done(stream, er) {
13908
14557
 
13909
14558
  return stream.push(null);
13910
14559
  }
13911
- },{"./_stream_duplex":69,"core-util-is":45,"inherits":51}],73:[function(require,module,exports){
14560
+ },{"./_stream_duplex":84,"core-util-is":45,"inherits":66}],88:[function(require,module,exports){
13912
14561
  (function (process){
13913
14562
  // A bit simpler than readable streams.
13914
14563
  // Implement an async ._write(chunk, encoding, cb), and it'll handle all
@@ -14437,7 +15086,7 @@ function CorkedRequest(state) {
14437
15086
  };
14438
15087
  }
14439
15088
  }).call(this,require('_process'))
14440
- },{"./_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){
15089
+ },{"./_stream_duplex":84,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"process-nextick-args":81,"util-deprecate":96}],89:[function(require,module,exports){
14441
15090
  'use strict';
14442
15091
 
14443
15092
  var Buffer = require('buffer').Buffer;
@@ -14502,10 +15151,10 @@ BufferList.prototype.concat = function (n) {
14502
15151
  }
14503
15152
  return ret;
14504
15153
  };
14505
- },{"buffer":44,"buffer-shims":43}],75:[function(require,module,exports){
15154
+ },{"buffer":44,"buffer-shims":43}],90:[function(require,module,exports){
14506
15155
  module.exports = require("./lib/_stream_passthrough.js")
14507
15156
 
14508
- },{"./lib/_stream_passthrough.js":70}],76:[function(require,module,exports){
15157
+ },{"./lib/_stream_passthrough.js":85}],91:[function(require,module,exports){
14509
15158
  (function (process){
14510
15159
  var Stream = (function (){
14511
15160
  try {
@@ -14525,13 +15174,13 @@ if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
14525
15174
  }
14526
15175
 
14527
15176
  }).call(this,require('_process'))
14528
- },{"./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){
15177
+ },{"./lib/_stream_duplex.js":84,"./lib/_stream_passthrough.js":85,"./lib/_stream_readable.js":86,"./lib/_stream_transform.js":87,"./lib/_stream_writable.js":88,"_process":82}],92:[function(require,module,exports){
14529
15178
  module.exports = require("./lib/_stream_transform.js")
14530
15179
 
14531
- },{"./lib/_stream_transform.js":72}],78:[function(require,module,exports){
15180
+ },{"./lib/_stream_transform.js":87}],93:[function(require,module,exports){
14532
15181
  module.exports = require("./lib/_stream_writable.js")
14533
15182
 
14534
- },{"./lib/_stream_writable.js":73}],79:[function(require,module,exports){
15183
+ },{"./lib/_stream_writable.js":88}],94:[function(require,module,exports){
14535
15184
  // Copyright Joyent, Inc. and other Node contributors.
14536
15185
  //
14537
15186
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -14660,7 +15309,7 @@ Stream.prototype.pipe = function(dest, options) {
14660
15309
  return dest;
14661
15310
  };
14662
15311
 
14663
- },{"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){
15312
+ },{"events":63,"inherits":66,"readable-stream/duplex.js":83,"readable-stream/passthrough.js":90,"readable-stream/readable.js":91,"readable-stream/transform.js":92,"readable-stream/writable.js":93}],95:[function(require,module,exports){
14664
15313
  // Copyright Joyent, Inc. and other Node contributors.
14665
15314
  //
14666
15315
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -14883,7 +15532,7 @@ function base64DetectIncompleteChar(buffer) {
14883
15532
  this.charLength = this.charReceived ? 3 : 0;
14884
15533
  }
14885
15534
 
14886
- },{"buffer":44}],81:[function(require,module,exports){
15535
+ },{"buffer":44}],96:[function(require,module,exports){
14887
15536
  (function (global){
14888
15537
 
14889
15538
  /**
@@ -14954,16 +15603,16 @@ function config (name) {
14954
15603
  }
14955
15604
 
14956
15605
  }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
14957
- },{}],82:[function(require,module,exports){
14958
- arguments[4][51][0].apply(exports,arguments)
14959
- },{"dup":51}],83:[function(require,module,exports){
15606
+ },{}],97:[function(require,module,exports){
15607
+ arguments[4][66][0].apply(exports,arguments)
15608
+ },{"dup":66}],98:[function(require,module,exports){
14960
15609
  module.exports = function isBuffer(arg) {
14961
15610
  return arg && typeof arg === 'object'
14962
15611
  && typeof arg.copy === 'function'
14963
15612
  && typeof arg.fill === 'function'
14964
15613
  && typeof arg.readUInt8 === 'function';
14965
15614
  }
14966
- },{}],84:[function(require,module,exports){
15615
+ },{}],99:[function(require,module,exports){
14967
15616
  (function (process,global){
14968
15617
  // Copyright Joyent, Inc. and other Node contributors.
14969
15618
  //
@@ -15553,4 +16202,4 @@ function hasOwnProperty(obj, prop) {
15553
16202
  }
15554
16203
 
15555
16204
  }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
15556
- },{"./support/isBuffer":83,"_process":67,"inherits":82}]},{},[1]);
16205
+ },{"./support/isBuffer":98,"_process":82,"inherits":97}]},{},[1]);