diff --git a/mocha.js b/mocha.js
index 390f5907a9..07bf7ac288 100644
--- a/mocha.js
+++ b/mocha.js
@@ -189,7 +189,7 @@ global.mocha = mocha;
module.exports = global;
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./lib/mocha":14,"_process":67,"browser-stdout":41}],2:[function(require,module,exports){
+},{"./lib/mocha":14,"_process":82,"browser-stdout":41}],2:[function(require,module,exports){
'use strict';
function noop () {}
@@ -647,7 +647,7 @@ Context.prototype.inspect = function () {
}, 2);
};
-},{"json3":54}],7:[function(require,module,exports){
+},{"json3":69}],7:[function(require,module,exports){
'use strict';
/**
@@ -1412,9 +1412,17 @@ Mocha.prototype.reporter = function (reporter, reporterOptions) {
try {
_reporter = require(reporter);
} catch (err) {
- err.message.indexOf('Cannot find module') !== -1
- ? console.warn('"' + reporter + '" reporter not found')
- : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
+ if (err.message.indexOf('Cannot find module') !== -1) {
+ // Try to load reporters from a path (absolute or relative)
+ try {
+ _reporter = require(path.resolve(process.cwd(), reporter));
+ } catch (_err) {
+ err.message.indexOf('Cannot find module') !== -1 ? console.warn('"' + reporter + '" reporter not found')
+ : console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
+ }
+ } else {
+ console.warn('"' + reporter + '" reporter blew up with error:\n' + err.stack);
+ }
}
}
if (!_reporter && reporter === 'teamcity') {
@@ -1782,7 +1790,7 @@ Mocha.prototype.run = function (fn) {
};
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},"/lib")
-},{"./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){
+},{"./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){
'use strict';
/**
@@ -2427,7 +2435,7 @@ function sameType (a, b) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"../ms":15,"../utils":38,"_process":67,"diff":46,"supports-color":42,"tty":5}],18:[function(require,module,exports){
+},{"../ms":15,"../utils":38,"_process":82,"diff":56,"supports-color":42,"tty":5}],18:[function(require,module,exports){
'use strict';
/**
@@ -2565,7 +2573,7 @@ function Dot (runner) {
inherits(Dot, Base);
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],20:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],20:[function(require,module,exports){
(function (global){
'use strict';
@@ -2610,6 +2618,8 @@ var statsTemplate = '
';
+var playIcon = '‣';
+
/**
* Initialize a new `HTML` reporter.
*
@@ -2705,7 +2715,7 @@ function HTML (runner) {
runner.on('pass', function (test) {
var url = self.testURL(test);
var markup = '%e%ems ' +
- '‣
';
+ '' + playIcon + '';
var el = fragment(markup, test.speed, test.title, test.duration, url);
self.addCodeToggle(el, test.body);
appendToStack(el);
@@ -2713,7 +2723,7 @@ function HTML (runner) {
});
runner.on('fail', function (test) {
- var el = fragment('%e ‣
',
+ var el = fragment('',
test.title, self.testURL(test));
var stackString; // Note: Includes leading newline
var message = test.err.toString();
@@ -2915,7 +2925,7 @@ function on (el, event, fn) {
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":47}],21:[function(require,module,exports){
+},{"../browser/progress":4,"../utils":38,"./base":17,"escape-string-regexp":62}],21:[function(require,module,exports){
'use strict';
// Alias exports to a their normalized format Mocha#reporter to prevent a need
@@ -3003,7 +3013,7 @@ function clean (test) {
}
}).call(this,require('_process'))
-},{"./base":17,"_process":67,"json3":54}],23:[function(require,module,exports){
+},{"./base":17,"_process":82,"json3":69}],23:[function(require,module,exports){
(function (process){
'use strict';
@@ -3099,7 +3109,7 @@ function errorJSON (err) {
}
}).call(this,require('_process'))
-},{"./base":17,"_process":67}],24:[function(require,module,exports){
+},{"./base":17,"_process":82}],24:[function(require,module,exports){
(function (process){
'use strict';
@@ -3197,7 +3207,7 @@ function Landing (runner) {
inherits(Landing, Base);
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],25:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],25:[function(require,module,exports){
(function (process){
'use strict';
@@ -3264,7 +3274,7 @@ function List (runner) {
inherits(List, Base);
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],26:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],26:[function(require,module,exports){
(function (process){
'use strict';
@@ -3367,7 +3377,7 @@ function Markdown (runner) {
}
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],27:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],27:[function(require,module,exports){
(function (process){
'use strict';
@@ -3409,7 +3419,7 @@ function Min (runner) {
inherits(Min, Base);
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],28:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],28:[function(require,module,exports){
(function (process){
'use strict';
@@ -3676,7 +3686,7 @@ function write (string) {
}
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],29:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],29:[function(require,module,exports){
(function (process){
'use strict';
@@ -3771,7 +3781,7 @@ function Progress (runner, options) {
inherits(Progress, Base);
}).call(this,require('_process'))
-},{"../utils":38,"./base":17,"_process":67}],30:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82}],30:[function(require,module,exports){
'use strict';
/**
@@ -4098,7 +4108,7 @@ function tag (name, attrs, close, content) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"../utils":38,"./base":17,"_process":67,"fs":42,"mkdirp":64,"path":42}],33:[function(require,module,exports){
+},{"../utils":38,"./base":17,"_process":82,"fs":42,"mkdirp":79,"path":42}],33:[function(require,module,exports){
(function (global){
'use strict';
@@ -4426,8 +4436,11 @@ Runnable.prototype.run = function (fn) {
}
if (this.allowUncaught) {
- callFn(this.fn);
- done();
+ if (this.isPending()) {
+ done();
+ } else {
+ callFn(this.fn);
+ }
return;
}
@@ -4488,7 +4501,7 @@ Runnable.prototype.run = function (fn) {
};
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":54,"lodash.create":60}],34:[function(require,module,exports){
+},{"./ms":15,"./pending":16,"./utils":38,"debug":2,"events":3,"json3":69,"lodash.create":75}],34:[function(require,module,exports){
(function (process,global){
'use strict';
@@ -4924,15 +4937,14 @@ Runner.prototype.runTest = function (fn) {
if (this.asyncOnly) {
test.asyncOnly = true;
}
-
+ test.on('error', function (err) {
+ self.fail(test, err);
+ });
if (this.allowUncaught) {
test.allowUncaught = true;
return test.run(fn);
}
try {
- test.on('error', function (err) {
- self.fail(test, err);
- });
test.run(fn);
} catch (err) {
fn(err);
@@ -5173,9 +5185,9 @@ Runner.prototype.runSuite = function (suite, fn) {
*/
Runner.prototype.uncaught = function (err) {
if (err) {
- debug('uncaught exception %s', err !== function () {
+ debug('uncaught exception %s', err === (function () {
return this;
- }.call(err) ? err : (err.message || err));
+ }.call(err)) ? (err.message || err) : err);
} else {
debug('uncaught undefined exception');
err = undefinedError();
@@ -5455,7 +5467,7 @@ function extraGlobals () {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./pending":16,"./runnable":33,"./utils":38,"_process":67,"debug":2,"events":3}],35:[function(require,module,exports){
+},{"./pending":16,"./runnable":33,"./utils":38,"_process":82,"debug":2,"events":3}],35:[function(require,module,exports){
'use strict';
/**
@@ -5913,7 +5925,7 @@ Test.prototype.clone = function () {
return test;
};
-},{"./runnable":33,"./utils":38,"lodash.create":60}],37:[function(require,module,exports){
+},{"./runnable":33,"./utils":38,"lodash.create":75}],37:[function(require,module,exports){
'use strict';
/**
@@ -6278,7 +6290,9 @@ exports.parseQuery = function (qs) {
var key = pair.slice(0, i);
var val = pair.slice(++i);
- obj[key] = decodeURIComponent(val);
+ // Due to how the URLSearchParams API treats spaces
+ obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
+
return obj;
}, {});
};
@@ -6372,7 +6386,7 @@ var type = exports.type = function type (value) {
return 'buffer';
}
return Object.prototype.toString.call(value)
- .replace(/^\[.+\s(.+?)\]$/, '$1')
+ .replace(/^\[.+\s(.+?)]$/, '$1')
.toLowerCase();
};
@@ -6697,7 +6711,9 @@ exports.stackTraceFilter = function () {
if (is.node) {
cwd = process.cwd() + slash;
} else {
- cwd = (typeof location === 'undefined' ? window.location : location).href.replace(/\/[^\/]*$/, '/');
+ cwd = (typeof location === 'undefined'
+ ? window.location
+ : location).href.replace(/\/[^/]*$/, '/');
slash = '/';
}
@@ -6759,7 +6775,7 @@ exports.isPromise = function isPromise (value) {
exports.noop = function () {};
}).call(this,require('_process'),require("buffer").Buffer)
-},{"./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){
+},{"./to-iso-string":37,"_process":82,"buffer":44,"debug":2,"fs":42,"glob":42,"json3":69,"path":42,"util":100}],39:[function(require,module,exports){
'use strict'
exports.byteLength = byteLength
@@ -6906,7 +6922,7 @@ BrowserStdout.prototype._write = function(chunks, encoding, cb) {
}
}).call(this,require('_process'))
-},{"_process":67,"stream":79,"util":84}],42:[function(require,module,exports){
+},{"_process":82,"stream":95,"util":100}],42:[function(require,module,exports){
arguments[4][40][0].apply(exports,arguments)
},{"dup":40}],43:[function(require,module,exports){
(function (global){
@@ -8813,7 +8829,7 @@ function isnan (val) {
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"base64-js":39,"ieee754":50,"isarray":53}],45:[function(require,module,exports){
+},{"base64-js":39,"ieee754":65,"isarray":68}],45:[function(require,module,exports){
(function (Buffer){
// Copyright Joyent, Inc. and other Node contributors.
//
@@ -8924,646 +8940,1276 @@ function objectToString(o) {
}
}).call(this,{"isBuffer":require("../../is-buffer/index.js")})
-},{"../../is-buffer/index.js":52}],46:[function(require,module,exports){
-/* See LICENSE file for terms of use */
+},{"../../is-buffer/index.js":67}],46:[function(require,module,exports){
+/*istanbul ignore start*/"use strict";
+
+exports.__esModule = true;
+exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP;
+// See: http://code.google.com/p/google-diff-match-patch/wiki/API
+function convertChangesToDMP(changes) {
+ var ret = [],
+ change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
+ operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
+ for (var i = 0; i < changes.length; i++) {
+ change = changes[i];
+ if (change.added) {
+ operation = 1;
+ } else if (change.removed) {
+ operation = -1;
+ } else {
+ operation = 0;
+ }
-/*
- * Text diff implementation.
- *
- * This library supports the following APIS:
- * JsDiff.diffChars: Character by character diff
- * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
- * JsDiff.diffLines: Line based diff
- *
- * JsDiff.diffCss: Diff targeted at CSS content
- *
- * These methods are based on the implementation proposed in
- * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
- * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
- */
-(function(global, undefined) {
- var objectPrototypeToString = Object.prototype.toString;
+ ret.push([operation, change.value]);
+ }
+ return ret;
+}
- /*istanbul ignore next*/
- function map(arr, mapper, that) {
- if (Array.prototype.map) {
- return Array.prototype.map.call(arr, mapper, that);
- }
- var other = new Array(arr.length);
+},{}],47:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- for (var i = 0, n = arr.length; i < n; i++) {
- other[i] = mapper.call(that, arr[i], i, arr);
+exports.__esModule = true;
+exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML;
+function convertChangesToXML(changes) {
+ var ret = [];
+ for (var i = 0; i < changes.length; i++) {
+ var change = changes[i];
+ if (change.added) {
+ ret.push('');
+ } else if (change.removed) {
+ ret.push('');
}
- return other;
- }
- function clonePath(path) {
- return { newPos: path.newPos, components: path.components.slice(0) };
- }
- function removeEmpty(array) {
- var ret = [];
- for (var i = 0; i < array.length; i++) {
- if (array[i]) {
- ret.push(array[i]);
- }
+
+ ret.push(escapeHTML(change.value));
+
+ if (change.added) {
+ ret.push('');
+ } else if (change.removed) {
+ ret.push('');
}
- return ret;
}
- function escapeHTML(s) {
- var n = s;
- n = n.replace(/&/g, '&');
- n = n.replace(//g, '>');
- n = n.replace(/"/g, '"');
+ return ret.join('');
+}
- return n;
- }
+function escapeHTML(s) {
+ var n = s;
+ n = n.replace(/&/g, '&');
+ n = n.replace(//g, '>');
+ n = n.replace(/"/g, '"');
- // This function handles the presence of circular references by bailing out when encountering an
- // object that is already on the "stack" of items being processed.
- function canonicalize(obj, stack, replacementStack) {
- stack = stack || [];
- replacementStack = replacementStack || [];
+ return n;
+}
- var i;
- for (i = 0; i < stack.length; i += 1) {
- if (stack[i] === obj) {
- return replacementStack[i];
- }
+},{}],48:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports.arrayDiff = undefined;
+exports. /*istanbul ignore end*/diffArrays = diffArrays;
+
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
+
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+/*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+arrayDiff.tokenize = arrayDiff.join = function (value) {
+ return value.slice();
+};
+
+function diffArrays(oldArr, newArr, callback) {
+ return arrayDiff.diff(oldArr, newArr, callback);
+}
+
+
+},{"./base":49}],49:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports['default'] = /*istanbul ignore end*/Diff;
+function Diff() {}
+
+Diff.prototype = { /*istanbul ignore start*/
+ /*istanbul ignore end*/diff: function diff(oldString, newString) {
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
+
+ var callback = options.callback;
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
}
+ this.options = options;
- var canonicalizedObj;
+ var self = this;
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
- stack.push(obj);
- canonicalizedObj = new Array(obj.length);
- replacementStack.push(canonicalizedObj);
- for (i = 0; i < obj.length; i += 1) {
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
- }
- stack.pop();
- replacementStack.pop();
- } else if (typeof obj === 'object' && obj !== null) {
- stack.push(obj);
- canonicalizedObj = {};
- replacementStack.push(canonicalizedObj);
- var sortedKeys = [],
- key;
- for (key in obj) {
- sortedKeys.push(key);
- }
- sortedKeys.sort();
- for (i = 0; i < sortedKeys.length; i += 1) {
- key = sortedKeys[i];
- canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
+ function done(value) {
+ if (callback) {
+ setTimeout(function () {
+ callback(undefined, value);
+ }, 0);
+ return true;
+ } else {
+ return value;
}
- stack.pop();
- replacementStack.pop();
- } else {
- canonicalizedObj = obj;
}
- return canonicalizedObj;
- }
- function buildValues(components, newString, oldString, useLongestToken) {
- var componentPos = 0,
- componentLen = components.length,
- newPos = 0,
- oldPos = 0;
+ // Allow subclasses to massage the input prior to running
+ oldString = this.castInput(oldString);
+ newString = this.castInput(newString);
+
+ oldString = this.removeEmpty(this.tokenize(oldString));
+ newString = this.removeEmpty(this.tokenize(newString));
+
+ var newLen = newString.length,
+ oldLen = oldString.length;
+ var editLength = 1;
+ var maxEditLength = newLen + oldLen;
+ var bestPath = [{ newPos: -1, components: [] }];
+
+ // Seed editLength = 0, i.e. the content starts with the same values
+ var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
+ if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
+ // Identity per the equality and tokenizer
+ return done([{ value: this.join(newString), count: newString.length }]);
+ }
+
+ // Main worker method. checks all permutations of a given edit length for acceptance.
+ function execEditLength() {
+ for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
+ var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
+ var addPath = bestPath[diagonalPath - 1],
+ removePath = bestPath[diagonalPath + 1],
+ _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
+ if (addPath) {
+ // No one else is going to attempt to use this value, clear it
+ bestPath[diagonalPath - 1] = undefined;
+ }
- for (; componentPos < componentLen; componentPos++) {
- var component = components[componentPos];
- if (!component.removed) {
- if (!component.added && useLongestToken) {
- var value = newString.slice(newPos, newPos + component.count);
- value = map(value, function(value, i) {
- var oldValue = oldString[oldPos + i];
- return oldValue.length > value.length ? oldValue : value;
- });
+ var canAdd = addPath && addPath.newPos + 1 < newLen,
+ canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
+ if (!canAdd && !canRemove) {
+ // If this path is a terminal then prune
+ bestPath[diagonalPath] = undefined;
+ continue;
+ }
- component.value = value.join('');
+ // Select the diagonal that we want to branch from. We select the prior
+ // path whose position in the new string is the farthest from the origin
+ // and does not pass the bounds of the diff graph
+ if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
+ basePath = clonePath(removePath);
+ self.pushComponent(basePath.components, undefined, true);
} else {
- component.value = newString.slice(newPos, newPos + component.count).join('');
+ basePath = addPath; // No need to clone, we've pulled it from the list
+ basePath.newPos++;
+ self.pushComponent(basePath.components, true, undefined);
}
- newPos += component.count;
- // Common case
- if (!component.added) {
- oldPos += component.count;
+ _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
+
+ // If we have hit the end of both strings, then we are done
+ if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
+ return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
+ } else {
+ // Otherwise track this path as a potential candidate and continue.
+ bestPath[diagonalPath] = basePath;
}
- } else {
- component.value = oldString.slice(oldPos, oldPos + component.count).join('');
- oldPos += component.count;
+ }
- // Reverse add and remove so removes are output first to match common convention
- // The diffing algorithm is tied to add then remove output and this is the simplest
- // route to get the desired output with minimal overhead.
- if (componentPos && components[componentPos - 1].added) {
- var tmp = components[componentPos - 1];
- components[componentPos - 1] = components[componentPos];
- components[componentPos] = tmp;
+ editLength++;
+ }
+
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
+ // sync and async mode which is never fun. Loops over execEditLength until a value
+ // is produced.
+ if (callback) {
+ (function exec() {
+ setTimeout(function () {
+ // This should not happen, but we want to be safe.
+ /* istanbul ignore next */
+ if (editLength > maxEditLength) {
+ return callback();
+ }
+
+ if (!execEditLength()) {
+ exec();
+ }
+ }, 0);
+ })();
+ } else {
+ while (editLength <= maxEditLength) {
+ var ret = execEditLength();
+ if (ret) {
+ return ret;
}
}
}
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) {
+ var last = components[components.length - 1];
+ if (last && last.added === added && last.removed === removed) {
+ // We need to clone here as the component clone operation is just
+ // as shallow array clone
+ components[components.length - 1] = { count: last.count + 1, added: added, removed: removed };
+ } else {
+ components.push({ count: 1, added: added, removed: removed });
+ }
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
+ var newLen = newString.length,
+ oldLen = oldString.length,
+ newPos = basePath.newPos,
+ oldPos = newPos - diagonalPath,
+ commonCount = 0;
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
+ newPos++;
+ oldPos++;
+ commonCount++;
+ }
- return components;
- }
+ if (commonCount) {
+ basePath.components.push({ count: commonCount });
+ }
- function Diff(ignoreWhitespace) {
- this.ignoreWhitespace = ignoreWhitespace;
+ basePath.newPos = newPos;
+ return oldPos;
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
+ return left === right;
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
+ var ret = [];
+ for (var i = 0; i < array.length; i++) {
+ if (array[i]) {
+ ret.push(array[i]);
+ }
+ }
+ return ret;
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) {
+ return value;
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) {
+ return value.split('');
+ },
+ /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) {
+ return chars.join('');
}
- Diff.prototype = {
- diff: function(oldString, newString, callback) {
- var self = this;
+};
- function done(value) {
- if (callback) {
- setTimeout(function() { callback(undefined, value); }, 0);
- return true;
- } else {
- return value;
- }
- }
+function buildValues(diff, components, newString, oldString, useLongestToken) {
+ var componentPos = 0,
+ componentLen = components.length,
+ newPos = 0,
+ oldPos = 0;
+
+ for (; componentPos < componentLen; componentPos++) {
+ var component = components[componentPos];
+ if (!component.removed) {
+ if (!component.added && useLongestToken) {
+ var value = newString.slice(newPos, newPos + component.count);
+ value = value.map(function (value, i) {
+ var oldValue = oldString[oldPos + i];
+ return oldValue.length > value.length ? oldValue : value;
+ });
- // Handle the identity case (this is due to unrolling editLength == 0
- if (newString === oldString) {
- return done([{ value: newString }]);
+ component.value = diff.join(value);
+ } else {
+ component.value = diff.join(newString.slice(newPos, newPos + component.count));
}
- if (!newString) {
- return done([{ value: oldString, removed: true }]);
+ newPos += component.count;
+
+ // Common case
+ if (!component.added) {
+ oldPos += component.count;
}
- if (!oldString) {
- return done([{ value: newString, added: true }]);
+ } else {
+ component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
+ oldPos += component.count;
+
+ // Reverse add and remove so removes are output first to match common convention
+ // The diffing algorithm is tied to add then remove output and this is the simplest
+ // route to get the desired output with minimal overhead.
+ if (componentPos && components[componentPos - 1].added) {
+ var tmp = components[componentPos - 1];
+ components[componentPos - 1] = components[componentPos];
+ components[componentPos] = tmp;
}
+ }
+ }
- newString = this.tokenize(newString);
- oldString = this.tokenize(oldString);
+ // Special case handle for when one terminal is ignored. For this case we merge the
+ // terminal into the prior string and drop the change.
+ var lastComponent = components[componentLen - 1];
+ if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
+ components[componentLen - 2].value += lastComponent.value;
+ components.pop();
+ }
- var newLen = newString.length, oldLen = oldString.length;
- var editLength = 1;
- var maxEditLength = newLen + oldLen;
- var bestPath = [{ newPos: -1, components: [] }];
+ return components;
+}
- // Seed editLength = 0, i.e. the content starts with the same values
- var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
- if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
- // Identity per the equality and tokenizer
- return done([{value: newString.join('')}]);
- }
+function clonePath(path) {
+ return { newPos: path.newPos, components: path.components.slice(0) };
+}
- // Main worker method. checks all permutations of a given edit length for acceptance.
- function execEditLength() {
- for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
- var basePath;
- var addPath = bestPath[diagonalPath - 1],
- removePath = bestPath[diagonalPath + 1],
- oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
- if (addPath) {
- // No one else is going to attempt to use this value, clear it
- bestPath[diagonalPath - 1] = undefined;
- }
- var canAdd = addPath && addPath.newPos + 1 < newLen,
- canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
- if (!canAdd && !canRemove) {
- // If this path is a terminal then prune
- bestPath[diagonalPath] = undefined;
- continue;
- }
+},{}],50:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- // Select the diagonal that we want to branch from. We select the prior
- // path whose position in the new string is the farthest from the origin
- // and does not pass the bounds of the diff graph
- if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
- basePath = clonePath(removePath);
- self.pushComponent(basePath.components, undefined, true);
- } else {
- basePath = addPath; // No need to clone, we've pulled it from the list
- basePath.newPos++;
- self.pushComponent(basePath.components, true, undefined);
- }
+exports.__esModule = true;
+exports.characterDiff = undefined;
+exports. /*istanbul ignore end*/diffChars = diffChars;
- oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
- // If we have hit the end of both strings, then we are done
- if (basePath.newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
- return done(buildValues(basePath.components, newString, oldString, self.useLongestToken));
- } else {
- // Otherwise track this path as a potential candidate and continue.
- bestPath[diagonalPath] = basePath;
- }
- }
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
- editLength++;
- }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- // Performs the length of edit iteration. Is a bit fugly as this has to support the
- // sync and async mode which is never fun. Loops over execEditLength until a value
- // is produced.
- if (callback) {
- (function exec() {
- setTimeout(function() {
- // This should not happen, but we want to be safe.
- /*istanbul ignore next */
- if (editLength > maxEditLength) {
- return callback();
- }
+/*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+function diffChars(oldStr, newStr, callback) {
+ return characterDiff.diff(oldStr, newStr, callback);
+}
- if (!execEditLength()) {
- exec();
- }
- }, 0);
- }());
- } else {
- while (editLength <= maxEditLength) {
- var ret = execEditLength();
- if (ret) {
- return ret;
- }
- }
- }
- },
- pushComponent: function(components, added, removed) {
- var last = components[components.length - 1];
- if (last && last.added === added && last.removed === removed) {
- // We need to clone here as the component clone operation is just
- // as shallow array clone
- components[components.length - 1] = {count: last.count + 1, added: added, removed: removed };
- } else {
- components.push({count: 1, added: added, removed: removed });
- }
- },
- extractCommon: function(basePath, newString, oldString, diagonalPath) {
- var newLen = newString.length,
- oldLen = oldString.length,
- newPos = basePath.newPos,
- oldPos = newPos - diagonalPath,
-
- commonCount = 0;
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
- newPos++;
- oldPos++;
- commonCount++;
- }
+},{"./base":49}],51:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- if (commonCount) {
- basePath.components.push({count: commonCount});
- }
+exports.__esModule = true;
+exports.cssDiff = undefined;
+exports. /*istanbul ignore end*/diffCss = diffCss;
- basePath.newPos = newPos;
- return oldPos;
- },
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
- equals: function(left, right) {
- var reWhitespace = /\S/;
- return left === right || (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right));
- },
- tokenize: function(value) {
- return value.split('');
- }
- };
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
- var CharDiff = new Diff();
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- var WordDiff = new Diff(true);
- var WordWithSpaceDiff = new Diff();
- WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\s+|\b)/));
- };
+/*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+cssDiff.tokenize = function (value) {
+ return value.split(/([{}:;,]|\s+)/);
+};
- var CssDiff = new Diff(true);
- CssDiff.tokenize = function(value) {
- return removeEmpty(value.split(/([{}:;,]|\s+)/));
- };
+function diffCss(oldStr, newStr, callback) {
+ return cssDiff.diff(oldStr, newStr, callback);
+}
- var LineDiff = new Diff();
- var TrimmedLineDiff = new Diff();
- TrimmedLineDiff.ignoreTrim = true;
+},{"./base":49}],52:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- LineDiff.tokenize = TrimmedLineDiff.tokenize = function(value) {
- var retLines = [],
- lines = value.split(/^/m);
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i],
- lastLine = lines[i - 1],
- lastLineLastChar = lastLine && lastLine[lastLine.length - 1];
+exports.__esModule = true;
+exports.jsonDiff = undefined;
- // Merge lines that may contain windows new lines
- if (line === '\n' && lastLineLastChar === '\r') {
- retLines[retLines.length - 1] = retLines[retLines.length - 1].slice(0, -1) + '\r\n';
- } else {
- if (this.ignoreTrim) {
- line = line.trim();
- // add a newline unless this is the last line.
- if (i < lines.length - 1) {
- line += '\n';
- }
- }
- retLines.push(line);
- }
- }
+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; };
- return retLines;
- };
+exports. /*istanbul ignore end*/diffJson = diffJson;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize;
- var PatchDiff = new Diff();
- PatchDiff.tokenize = function(value) {
- var ret = [],
- linesAndNewlines = value.split(/(\n|\r\n)/);
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
- // Ignore the final empty token that occurs if the string ends with a new line
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
- linesAndNewlines.pop();
- }
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
- // Merge the content and line separators into single tokens
- for (var i = 0; i < linesAndNewlines.length; i++) {
- var line = linesAndNewlines[i];
+/*istanbul ignore end*/
+var /*istanbul ignore start*/_line = require('./line') /*istanbul ignore end*/;
- if (i % 2) {
- ret[ret.length - 1] += line;
- } else {
- ret.push(line);
- }
+/*istanbul ignore start*/
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+/*istanbul ignore end*/
+
+var objectPrototypeToString = Object.prototype.toString;
+
+var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
+// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
+jsonDiff.useLongestToken = true;
+
+jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff. /*istanbul ignore end*/tokenize;
+jsonDiff.castInput = function (value) {
+ /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement;
+
+
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
+ if (typeof v === 'undefined') {
+ return undefinedReplacement;
}
- return ret;
- };
- var SentenceDiff = new Diff();
- SentenceDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\S.+?[.!?])(?=\s+|$)/));
- };
+ return v;
+ }, ' ');
+};
+jsonDiff.equals = function (left, right) {
+ return (/*istanbul ignore start*/_base2['default']. /*istanbul ignore end*/prototype.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
+ );
+};
- var JsonDiff = new Diff();
- // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
- JsonDiff.useLongestToken = true;
- JsonDiff.tokenize = LineDiff.tokenize;
- JsonDiff.equals = function(left, right) {
- return LineDiff.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'));
- };
+function diffJson(oldObj, newObj, options) {
+ return jsonDiff.diff(oldObj, newObj, options);
+}
+
+// This function handles the presence of circular references by bailing out when encountering an
+// object that is already on the "stack" of items being processed.
+function canonicalize(obj, stack, replacementStack) {
+ stack = stack || [];
+ replacementStack = replacementStack || [];
- var JsDiff = {
- Diff: Diff,
+ var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
- diffChars: function(oldStr, newStr, callback) { return CharDiff.diff(oldStr, newStr, callback); },
- diffWords: function(oldStr, newStr, callback) { return WordDiff.diff(oldStr, newStr, callback); },
- diffWordsWithSpace: function(oldStr, newStr, callback) { return WordWithSpaceDiff.diff(oldStr, newStr, callback); },
- diffLines: function(oldStr, newStr, callback) { return LineDiff.diff(oldStr, newStr, callback); },
- diffTrimmedLines: function(oldStr, newStr, callback) { return TrimmedLineDiff.diff(oldStr, newStr, callback); },
+ for (i = 0; i < stack.length; i += 1) {
+ if (stack[i] === obj) {
+ return replacementStack[i];
+ }
+ }
- diffSentences: function(oldStr, newStr, callback) { return SentenceDiff.diff(oldStr, newStr, callback); },
+ var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
- diffCss: function(oldStr, newStr, callback) { return CssDiff.diff(oldStr, newStr, callback); },
- diffJson: function(oldObj, newObj, callback) {
- return JsonDiff.diff(
- typeof oldObj === 'string' ? oldObj : JSON.stringify(canonicalize(oldObj), undefined, ' '),
- typeof newObj === 'string' ? newObj : JSON.stringify(canonicalize(newObj), undefined, ' '),
- callback
- );
- },
+ if ('[object Array]' === objectPrototypeToString.call(obj)) {
+ stack.push(obj);
+ canonicalizedObj = new Array(obj.length);
+ replacementStack.push(canonicalizedObj);
+ for (i = 0; i < obj.length; i += 1) {
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
+ }
+ stack.pop();
+ replacementStack.pop();
+ return canonicalizedObj;
+ }
- createTwoFilesPatch: function(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader) {
- var ret = [];
+ if (obj && obj.toJSON) {
+ obj = obj.toJSON();
+ }
- if (oldFileName == newFileName) {
- ret.push('Index: ' + oldFileName);
+ if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) {
+ stack.push(obj);
+ canonicalizedObj = {};
+ replacementStack.push(canonicalizedObj);
+ var sortedKeys = [],
+ key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
+ for (key in obj) {
+ /* istanbul ignore else */
+ if (obj.hasOwnProperty(key)) {
+ sortedKeys.push(key);
}
- ret.push('===================================================================');
- ret.push('--- ' + oldFileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader));
- ret.push('+++ ' + newFileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader));
+ }
+ sortedKeys.sort();
+ for (i = 0; i < sortedKeys.length; i += 1) {
+ key = sortedKeys[i];
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
+ }
+ stack.pop();
+ replacementStack.pop();
+ } else {
+ canonicalizedObj = obj;
+ }
+ return canonicalizedObj;
+}
- var diff = PatchDiff.diff(oldStr, newStr);
- diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier
- // Formats a given set of lines for printing as context lines in a patch
- function contextLines(lines) {
- return map(lines, function(entry) { return ' ' + entry; });
- }
+},{"./base":49,"./line":53}],53:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- // Outputs the no newline at end of file warning if needed
- function eofNL(curRange, i, current) {
- var last = diff[diff.length - 2],
- isLast = i === diff.length - 2,
- isLastOfType = i === diff.length - 3 && current.added !== last.added;
+exports.__esModule = true;
+exports.lineDiff = undefined;
+exports. /*istanbul ignore end*/diffLines = diffLines;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines;
- // Figure out if this is the last line for the given file and missing NL
- if (!(/\n$/.test(current.value)) && (isLast || isLastOfType)) {
- curRange.push('\\ No newline at end of file');
- }
- }
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
- var oldRangeStart = 0, newRangeStart = 0, curRange = [],
- oldLine = 1, newLine = 1;
- for (var i = 0; i < diff.length; i++) {
- var current = diff[i],
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
- current.lines = lines;
-
- if (current.added || current.removed) {
- // If we have previous context, start with that
- if (!oldRangeStart) {
- var prev = diff[i - 1];
- oldRangeStart = oldLine;
- newRangeStart = newLine;
-
- if (prev) {
- curRange = contextLines(prev.lines.slice(-4));
- oldRangeStart -= curRange.length;
- newRangeStart -= curRange.length;
- }
- }
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
- // Output our changes
- curRange.push.apply(curRange, map(lines, function(entry) {
- return (current.added ? '+' : '-') + entry;
- }));
- eofNL(curRange, i, current);
+/*istanbul ignore end*/
+var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
- // Track the updated file position
- if (current.added) {
- newLine += lines.length;
- } else {
- oldLine += lines.length;
- }
- } else {
- // Identical context lines. Track line changes
- if (oldRangeStart) {
- // Close out any changes that have been output (or join overlapping)
- if (lines.length <= 8 && i < diff.length - 2) {
- // Overlapping
- curRange.push.apply(curRange, contextLines(lines));
- } else {
- // end the range and output
- var contextSize = Math.min(lines.length, 4);
- ret.push(
- '@@ -' + oldRangeStart + ',' + (oldLine - oldRangeStart + contextSize)
- + ' +' + newRangeStart + ',' + (newLine - newRangeStart + contextSize)
- + ' @@');
- ret.push.apply(ret, curRange);
- ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
- if (lines.length <= 4) {
- eofNL(ret, i, current);
- }
+/*istanbul ignore start*/
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- oldRangeStart = 0;
- newRangeStart = 0;
- curRange = [];
- }
- }
- oldLine += lines.length;
- newLine += lines.length;
- }
+/*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+lineDiff.tokenize = function (value) {
+ var retLines = [],
+ linesAndNewlines = value.split(/(\n|\r\n)/);
+
+ // Ignore the final empty token that occurs if the string ends with a new line
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
+ linesAndNewlines.pop();
+ }
+
+ // Merge the content and line separators into single tokens
+ for (var i = 0; i < linesAndNewlines.length; i++) {
+ var line = linesAndNewlines[i];
+
+ if (i % 2 && !this.options.newlineIsToken) {
+ retLines[retLines.length - 1] += line;
+ } else {
+ if (this.options.ignoreWhitespace) {
+ line = line.trim();
}
+ retLines.push(line);
+ }
+ }
- return ret.join('\n') + '\n';
- },
+ return retLines;
+};
- createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
- return JsDiff.createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader);
- },
+function diffLines(oldStr, newStr, callback) {
+ return lineDiff.diff(oldStr, newStr, callback);
+}
+function diffTrimmedLines(oldStr, newStr, callback) {
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
+ return lineDiff.diff(oldStr, newStr, options);
+}
- applyPatch: function(oldStr, uniDiff) {
- var diffstr = uniDiff.split('\n'),
- hunks = [],
- i = 0,
- remEOFNL = false,
- addEOFNL = false;
- // Skip to the first change hunk
- while (i < diffstr.length && !(/^@@/.test(diffstr[i]))) {
- i++;
- }
+},{"../util/params":61,"./base":49}],54:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- // Parse the unified diff
- for (; i < diffstr.length; i++) {
- if (diffstr[i][0] === '@') {
- var chnukHeader = diffstr[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
- hunks.unshift({
- start: chnukHeader[3],
- oldlength: +chnukHeader[2],
- removed: [],
- newlength: chnukHeader[4],
- added: []
- });
- } else if (diffstr[i][0] === '+') {
- hunks[0].added.push(diffstr[i].substr(1));
- } else if (diffstr[i][0] === '-') {
- hunks[0].removed.push(diffstr[i].substr(1));
- } else if (diffstr[i][0] === ' ') {
- hunks[0].added.push(diffstr[i].substr(1));
- hunks[0].removed.push(diffstr[i].substr(1));
- } else if (diffstr[i][0] === '\\') {
- if (diffstr[i - 1][0] === '+') {
- remEOFNL = true;
- } else if (diffstr[i - 1][0] === '-') {
- addEOFNL = true;
- }
- }
- }
+exports.__esModule = true;
+exports.sentenceDiff = undefined;
+exports. /*istanbul ignore end*/diffSentences = diffSentences;
- // Apply the diff to the input
- var lines = oldStr.split('\n');
- for (i = hunks.length - 1; i >= 0; i--) {
- var hunk = hunks[i];
- // Sanity check the input string. Bail if we don't match.
- for (var j = 0; j < hunk.oldlength; j++) {
- if (lines[hunk.start - 1 + j] !== hunk.removed[j]) {
- return false;
- }
- }
- Array.prototype.splice.apply(lines, [hunk.start - 1, hunk.oldlength].concat(hunk.added));
- }
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
- // Handle EOFNL insertion/removal
- if (remEOFNL) {
- while (!lines[lines.length - 1]) {
- lines.pop();
- }
- } else if (addEOFNL) {
- lines.push('');
- }
- return lines.join('\n');
- },
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
- convertChangesToXML: function(changes) {
- var ret = [];
- for (var i = 0; i < changes.length; i++) {
- var change = changes[i];
- if (change.added) {
- ret.push('');
- } else if (change.removed) {
- ret.push('');
- }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- ret.push(escapeHTML(change.value));
+/*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+sentenceDiff.tokenize = function (value) {
+ return value.split(/(\S.+?[.!?])(?=\s+|$)/);
+};
- if (change.added) {
- ret.push('');
- } else if (change.removed) {
- ret.push('');
- }
- }
- return ret.join('');
- },
+function diffSentences(oldStr, newStr, callback) {
+ return sentenceDiff.diff(oldStr, newStr, callback);
+}
- // See: http://code.google.com/p/google-diff-match-patch/wiki/API
- convertChangesToDMP: function(changes) {
- var ret = [],
- change,
- operation;
- for (var i = 0; i < changes.length; i++) {
- change = changes[i];
- if (change.added) {
- operation = 1;
- } else if (change.removed) {
- operation = -1;
- } else {
- operation = 0;
- }
- ret.push([operation, change.value]);
- }
- return ret;
- },
+},{"./base":49}],55:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
- canonicalize: canonicalize
- };
+exports.__esModule = true;
+exports.wordDiff = undefined;
+exports. /*istanbul ignore end*/diffWords = diffWords;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace;
- /*istanbul ignore next */
- /*global module */
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = JsDiff;
- } else if (false) {
- /*global define */
- define([], function() { return JsDiff; });
- } else if (typeof global.JsDiff === 'undefined') {
- global.JsDiff = JsDiff;
- }
-}(this));
+var /*istanbul ignore start*/_base = require('./base') /*istanbul ignore end*/;
-},{}],47:[function(require,module,exports){
-'use strict';
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
-var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
+/*istanbul ignore end*/
+var /*istanbul ignore start*/_params = require('../util/params') /*istanbul ignore end*/;
-module.exports = function (str) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string');
- }
+/*istanbul ignore start*/
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- return str.replace(matchOperatorsRe, '\\$&');
-};
+/*istanbul ignore end*/
-},{}],48:[function(require,module,exports){
-// Copyright Joyent, Inc. and other Node contributors.
+// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
+// Ranges and exceptions:
+// Latin-1 Supplement, 0080–00FF
+// - U+00D7 × Multiplication sign
+// - U+00F7 ÷ Division sign
+// Latin Extended-A, 0100–017F
+// Latin Extended-B, 0180–024F
+// IPA Extensions, 0250–02AF
+// Spacing Modifier Letters, 02B0–02FF
+// - U+02C7 ˇ ˇ Caron
+// - U+02D8 ˘ ˘ Breve
+// - U+02D9 ˙ ˙ Dot Above
+// - U+02DA ˚ ˚ Ring Above
+// - U+02DB ˛ ˛ Ogonek
+// - U+02DC ˜ ˜ Small Tilde
+// - U+02DD ˝ ˝ Double Acute Accent
+// Latin Extended Additional, 1E00–1EFF
+var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
+
+var reWhitespace = /\S/;
+
+var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default']() /*istanbul ignore end*/;
+wordDiff.equals = function (left, right) {
+ return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
+};
+wordDiff.tokenize = function (value) {
+ var tokens = value.split(/(\s+|\b)/);
+
+ // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
+ for (var i = 0; i < tokens.length - 1; i++) {
+ // If we have an empty string in the next field and we have only word chars before and after, merge
+ if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
+ tokens[i] += tokens[i + 2];
+ tokens.splice(i + 1, 2);
+ i--;
+ }
+ }
+
+ return tokens;
+};
+
+function diffWords(oldStr, newStr, callback) {
+ var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true });
+ return wordDiff.diff(oldStr, newStr, options);
+}
+function diffWordsWithSpace(oldStr, newStr, callback) {
+ return wordDiff.diff(oldStr, newStr, callback);
+}
+
+
+},{"../util/params":61,"./base":49}],56:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+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;
+/*istanbul ignore end*/
+var /*istanbul ignore start*/_base = require('./diff/base') /*istanbul ignore end*/;
+
+/*istanbul ignore start*/
+var _base2 = _interopRequireDefault(_base);
+
+/*istanbul ignore end*/
+var /*istanbul ignore start*/_character = require('./diff/character') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_word = require('./diff/word') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_line = require('./diff/line') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_sentence = require('./diff/sentence') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_css = require('./diff/css') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_json = require('./diff/json') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_array = require('./diff/array') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_apply = require('./patch/apply') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_parse = require('./patch/parse') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_create = require('./patch/create') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_dmp = require('./convert/dmp') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_xml = require('./convert/xml') /*istanbul ignore end*/;
+
+/*istanbul ignore start*/
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+exports. /*istanbul ignore end*/Diff = _base2['default'];
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize; /* See LICENSE file for terms of use */
+
+/*
+ * Text diff implementation.
+ *
+ * This library supports the following APIS:
+ * JsDiff.diffChars: Character by character diff
+ * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
+ * JsDiff.diffLines: Line based diff
+ *
+ * JsDiff.diffCss: Diff targeted at CSS content
+ *
+ * These methods are based on the implementation proposed in
+ * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
+ * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
+ */
+
+
+},{"./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){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports. /*istanbul ignore end*/applyPatch = applyPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches;
+
+var /*istanbul ignore start*/_parse = require('./parse') /*istanbul ignore end*/;
+
+var /*istanbul ignore start*/_distanceIterator = require('../util/distance-iterator') /*istanbul ignore end*/;
+
+/*istanbul ignore start*/
+var _distanceIterator2 = _interopRequireDefault(_distanceIterator);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+/*istanbul ignore end*/function applyPatch(source, uniDiff) {
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
+
+ if (typeof uniDiff === 'string') {
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
+ }
+
+ if (Array.isArray(uniDiff)) {
+ if (uniDiff.length > 1) {
+ throw new Error('applyPatch only works with a single input.');
+ }
+
+ uniDiff = uniDiff[0];
+ }
+
+ // Apply the diff to the input
+ var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
+ delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
+ hunks = uniDiff.hunks,
+ compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{
+ return (/*istanbul ignore end*/line === patchContent
+ );
+ },
+ errorCount = 0,
+ fuzzFactor = options.fuzzFactor || 0,
+ minLine = 0,
+ offset = 0,
+ removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/,
+ addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
+
+ /**
+ * Checks if the hunk exactly fits on the provided location
+ */
+ function hunkFits(hunk, toPos) {
+ for (var j = 0; j < hunk.lines.length; j++) {
+ var line = hunk.lines[j],
+ operation = line[0],
+ content = line.substr(1);
+
+ if (operation === ' ' || operation === '-') {
+ // Context sanity check
+ if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
+ errorCount++;
+
+ if (errorCount > fuzzFactor) {
+ return false;
+ }
+ }
+ toPos++;
+ }
+ }
+
+ return true;
+ }
+
+ // Search best fit offsets for each hunk based on the previous ones
+ for (var i = 0; i < hunks.length; i++) {
+ var hunk = hunks[i],
+ maxLine = lines.length - hunk.oldLines,
+ localOffset = 0,
+ toPos = offset + hunk.oldStart - 1;
+
+ var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine);
+
+ for (; localOffset !== undefined; localOffset = iterator()) {
+ if (hunkFits(hunk, toPos + localOffset)) {
+ hunk.offset = offset += localOffset;
+ break;
+ }
+ }
+
+ if (localOffset === undefined) {
+ return false;
+ }
+
+ // Set lower text limit to end of the current hunk, so next ones don't try
+ // to fit over already patched text
+ minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
+ }
+
+ // Apply patch hunks
+ for (var _i = 0; _i < hunks.length; _i++) {
+ var _hunk = hunks[_i],
+ _toPos = _hunk.offset + _hunk.newStart - 1;
+ if (_hunk.newLines == 0) {
+ _toPos++;
+ }
+
+ for (var j = 0; j < _hunk.lines.length; j++) {
+ var line = _hunk.lines[j],
+ operation = line[0],
+ content = line.substr(1),
+ delimiter = _hunk.linedelimiters[j];
+
+ if (operation === ' ') {
+ _toPos++;
+ } else if (operation === '-') {
+ lines.splice(_toPos, 1);
+ delimiters.splice(_toPos, 1);
+ /* istanbul ignore else */
+ } else if (operation === '+') {
+ lines.splice(_toPos, 0, content);
+ delimiters.splice(_toPos, 0, delimiter);
+ _toPos++;
+ } else if (operation === '\\') {
+ var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
+ if (previousOperation === '+') {
+ removeEOFNL = true;
+ } else if (previousOperation === '-') {
+ addEOFNL = true;
+ }
+ }
+ }
+ }
+
+ // Handle EOFNL insertion/removal
+ if (removeEOFNL) {
+ while (!lines[lines.length - 1]) {
+ lines.pop();
+ delimiters.pop();
+ }
+ } else if (addEOFNL) {
+ lines.push('');
+ delimiters.push('\n');
+ }
+ for (var _k = 0; _k < lines.length - 1; _k++) {
+ lines[_k] = lines[_k] + delimiters[_k];
+ }
+ return lines.join('');
+}
+
+// Wrapper that supports multiple file patches via callbacks.
+function applyPatches(uniDiff, options) {
+ if (typeof uniDiff === 'string') {
+ uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff);
+ }
+
+ var currentIndex = 0;
+ function processIndex() {
+ var index = uniDiff[currentIndex++];
+ if (!index) {
+ return options.complete();
+ }
+
+ options.loadFile(index, function (err, data) {
+ if (err) {
+ return options.complete(err);
+ }
+
+ var updatedContent = applyPatch(data, index, options);
+ options.patched(index, updatedContent, function (err) {
+ if (err) {
+ return options.complete(err);
+ }
+
+ processIndex();
+ });
+ });
+ }
+ processIndex();
+}
+
+
+},{"../util/distance-iterator":60,"./parse":59}],58:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports. /*istanbul ignore end*/structuredPatch = structuredPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch;
+/*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch;
+
+var /*istanbul ignore start*/_line = require('../diff/line') /*istanbul ignore end*/;
+
+/*istanbul ignore start*/
+function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+
+/*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
+ if (!options) {
+ options = {};
+ }
+ if (typeof options.context === 'undefined') {
+ options.context = 4;
+ }
+
+ var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options);
+ diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
+
+ function contextLines(lines) {
+ return lines.map(function (entry) {
+ return ' ' + entry;
+ });
+ }
+
+ var hunks = [];
+ var oldRangeStart = 0,
+ newRangeStart = 0,
+ curRange = [],
+ oldLine = 1,
+ newLine = 1;
+ /*istanbul ignore start*/
+ var _loop = function _loop( /*istanbul ignore end*/i) {
+ var current = diff[i],
+ lines = current.lines || current.value.replace(/\n$/, '').split('\n');
+ current.lines = lines;
+
+ if (current.added || current.removed) {
+ /*istanbul ignore start*/
+ var _curRange;
+
+ /*istanbul ignore end*/
+ // If we have previous context, start with that
+ if (!oldRangeStart) {
+ var prev = diff[i - 1];
+ oldRangeStart = oldLine;
+ newRangeStart = newLine;
+
+ if (prev) {
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
+ oldRangeStart -= curRange.length;
+ newRangeStart -= curRange.length;
+ }
+ }
+
+ // Output our changes
+ /*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) {
+ return (current.added ? '+' : '-') + entry;
+ })));
+
+ // Track the updated file position
+ if (current.added) {
+ newLine += lines.length;
+ } else {
+ oldLine += lines.length;
+ }
+ } else {
+ // Identical context lines. Track line changes
+ if (oldRangeStart) {
+ // Close out any changes that have been output (or join overlapping)
+ if (lines.length <= options.context * 2 && i < diff.length - 2) {
+ /*istanbul ignore start*/
+ var _curRange2;
+
+ /*istanbul ignore end*/
+ // Overlapping
+ /*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)));
+ } else {
+ /*istanbul ignore start*/
+ var _curRange3;
+
+ /*istanbul ignore end*/
+ // end the range and output
+ var contextSize = Math.min(lines.length, options.context);
+ /*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))));
+
+ var hunk = {
+ oldStart: oldRangeStart,
+ oldLines: oldLine - oldRangeStart + contextSize,
+ newStart: newRangeStart,
+ newLines: newLine - newRangeStart + contextSize,
+ lines: curRange
+ };
+ if (i >= diff.length - 2 && lines.length <= options.context) {
+ // EOF is inside this hunk
+ var oldEOFNewline = /\n$/.test(oldStr);
+ var newEOFNewline = /\n$/.test(newStr);
+ if (lines.length == 0 && !oldEOFNewline) {
+ // special case: old has no eol and no trailing context; no-nl can end up before adds
+ curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file');
+ } else if (!oldEOFNewline || !newEOFNewline) {
+ curRange.push('\\ No newline at end of file');
+ }
+ }
+ hunks.push(hunk);
+
+ oldRangeStart = 0;
+ newRangeStart = 0;
+ curRange = [];
+ }
+ }
+ oldLine += lines.length;
+ newLine += lines.length;
+ }
+ };
+
+ for (var i = 0; i < diff.length; i++) {
+ /*istanbul ignore start*/
+ _loop( /*istanbul ignore end*/i);
+ }
+
+ return {
+ oldFileName: oldFileName, newFileName: newFileName,
+ oldHeader: oldHeader, newHeader: newHeader,
+ hunks: hunks
+ };
+}
+
+function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
+ var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
+
+ var ret = [];
+ if (oldFileName == newFileName) {
+ ret.push('Index: ' + oldFileName);
+ }
+ ret.push('===================================================================');
+ ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
+ ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
+
+ for (var i = 0; i < diff.hunks.length; i++) {
+ var hunk = diff.hunks[i];
+ ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
+ ret.push.apply(ret, hunk.lines);
+ }
+
+ return ret.join('\n') + '\n';
+}
+
+function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
+ return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
+}
+
+
+},{"../diff/line":53}],59:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports. /*istanbul ignore end*/parsePatch = parsePatch;
+function parsePatch(uniDiff) {
+ /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
+
+ var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
+ delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
+ list = [],
+ i = 0;
+
+ function parseIndex() {
+ var index = {};
+ list.push(index);
+
+ // Parse diff metadata
+ while (i < diffstr.length) {
+ var line = diffstr[i];
+
+ // File header found, end parsing diff metadata
+ if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
+ break;
+ }
+
+ // Diff index
+ var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
+ if (header) {
+ index.index = header[1];
+ }
+
+ i++;
+ }
+
+ // Parse file headers if they are defined. Unified diff requires them, but
+ // there's no technical issues to have an isolated hunk without file header
+ parseFileHeader(index);
+ parseFileHeader(index);
+
+ // Parse hunks
+ index.hunks = [];
+
+ while (i < diffstr.length) {
+ var _line = diffstr[i];
+
+ if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
+ break;
+ } else if (/^@@/.test(_line)) {
+ index.hunks.push(parseHunk());
+ } else if (_line && options.strict) {
+ // Ignore unexpected content unless in strict mode
+ throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
+ } else {
+ i++;
+ }
+ }
+ }
+
+ // Parses the --- and +++ headers, if none are found, no lines
+ // are consumed.
+ function parseFileHeader(index) {
+ var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
+ var fileHeader = headerPattern.exec(diffstr[i]);
+ if (fileHeader) {
+ var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
+ index[keyPrefix + 'FileName'] = fileHeader[2];
+ index[keyPrefix + 'Header'] = fileHeader[3];
+
+ i++;
+ }
+ }
+
+ // Parses a hunk
+ // This assumes that we are at the start of a hunk.
+ function parseHunk() {
+ var chunkHeaderIndex = i,
+ chunkHeaderLine = diffstr[i++],
+ chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
+
+ var hunk = {
+ oldStart: +chunkHeader[1],
+ oldLines: +chunkHeader[2] || 1,
+ newStart: +chunkHeader[3],
+ newLines: +chunkHeader[4] || 1,
+ lines: [],
+ linedelimiters: []
+ };
+
+ var addCount = 0,
+ removeCount = 0;
+ for (; i < diffstr.length; i++) {
+ // Lines starting with '---' could be mistaken for the "remove line" operation
+ // But they could be the header for the next file. Therefore prune such cases out.
+ if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
+ break;
+ }
+ var operation = diffstr[i][0];
+
+ if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
+ hunk.lines.push(diffstr[i]);
+ hunk.linedelimiters.push(delimiters[i] || '\n');
+
+ if (operation === '+') {
+ addCount++;
+ } else if (operation === '-') {
+ removeCount++;
+ } else if (operation === ' ') {
+ addCount++;
+ removeCount++;
+ }
+ } else {
+ break;
+ }
+ }
+
+ // Handle the empty block count case
+ if (!addCount && hunk.newLines === 1) {
+ hunk.newLines = 0;
+ }
+ if (!removeCount && hunk.oldLines === 1) {
+ hunk.oldLines = 0;
+ }
+
+ // Perform optional sanity checking
+ if (options.strict) {
+ if (addCount !== hunk.newLines) {
+ throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
+ }
+ if (removeCount !== hunk.oldLines) {
+ throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
+ }
+ }
+
+ return hunk;
+ }
+
+ while (i < diffstr.length) {
+ parseIndex();
+ }
+
+ return list;
+}
+
+
+},{}],60:[function(require,module,exports){
+/*istanbul ignore start*/"use strict";
+
+exports.__esModule = true;
+
+exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) {
+ var wantForward = true,
+ backwardExhausted = false,
+ forwardExhausted = false,
+ localOffset = 1;
+
+ return function iterator() {
+ if (wantForward && !forwardExhausted) {
+ if (backwardExhausted) {
+ localOffset++;
+ } else {
+ wantForward = false;
+ }
+
+ // Check if trying to fit beyond text length, and if not, check it fits
+ // after offset location (or desired location on first iteration)
+ if (start + localOffset <= maxLine) {
+ return localOffset;
+ }
+
+ forwardExhausted = true;
+ }
+
+ if (!backwardExhausted) {
+ if (!forwardExhausted) {
+ wantForward = true;
+ }
+
+ // Check if trying to fit before text beginning, and if not, check it fits
+ // before offset location
+ if (minLine <= start - localOffset) {
+ return -localOffset++;
+ }
+
+ backwardExhausted = true;
+ return iterator();
+ }
+
+ // We tried to fit hunk before text beginning and beyond text lenght, then
+ // hunk can't fit on the text. Return undefined
+ };
+};
+
+
+},{}],61:[function(require,module,exports){
+/*istanbul ignore start*/'use strict';
+
+exports.__esModule = true;
+exports. /*istanbul ignore end*/generateOptions = generateOptions;
+function generateOptions(options, defaults) {
+ if (typeof options === 'function') {
+ defaults.callback = options;
+ } else if (options) {
+ for (var name in options) {
+ /* istanbul ignore else */
+ if (options.hasOwnProperty(name)) {
+ defaults[name] = options[name];
+ }
+ }
+ }
+ return defaults;
+}
+
+
+},{}],62:[function(require,module,exports){
+'use strict';
+
+var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
+
+module.exports = function (str) {
+ if (typeof str !== 'string') {
+ throw new TypeError('Expected a string');
+ }
+
+ return str.replace(matchOperatorsRe, '\\$&');
+};
+
+},{}],63:[function(require,module,exports){
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
@@ -9862,7 +10508,7 @@ function isUndefined(arg) {
return arg === void 0;
}
-},{}],49:[function(require,module,exports){
+},{}],64:[function(require,module,exports){
(function (process){
// Growl - Copyright TJ Holowaychuk (MIT Licensed)
@@ -10156,7 +10802,7 @@ function growl(msg, options, fn) {
};
}).call(this,require('_process'))
-},{"_process":67,"child_process":42,"fs":42,"os":65,"path":42}],50:[function(require,module,exports){
+},{"_process":82,"child_process":42,"fs":42,"os":80,"path":42}],65:[function(require,module,exports){
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = nBytes * 8 - mLen - 1
@@ -10242,7 +10888,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
buffer[offset + i - d] |= s * 128
}
-},{}],51:[function(require,module,exports){
+},{}],66:[function(require,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
@@ -10267,7 +10913,7 @@ if (typeof Object.create === 'function') {
}
}
-},{}],52:[function(require,module,exports){
+},{}],67:[function(require,module,exports){
/*!
* Determine if an object is a Buffer
*
@@ -10290,14 +10936,14 @@ function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
}
-},{}],53:[function(require,module,exports){
+},{}],68:[function(require,module,exports){
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
-},{}],54:[function(require,module,exports){
+},{}],69:[function(require,module,exports){
(function (global){
/*! JSON v3.3.2 | http://bestiejs.github.io/json3 | Copyright 2012-2014, Kit Cambridge | http://kit.mit-license.org */
;(function () {
@@ -11203,7 +11849,7 @@ module.exports = Array.isArray || function (arr) {
}).call(this);
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],55:[function(require,module,exports){
+},{}],70:[function(require,module,exports){
/**
* lodash 3.2.0 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11232,7 +11878,7 @@ function baseAssign(object, source) {
module.exports = baseAssign;
-},{"lodash._basecopy":56,"lodash.keys":63}],56:[function(require,module,exports){
+},{"lodash._basecopy":71,"lodash.keys":78}],71:[function(require,module,exports){
/**
* lodash 3.0.1 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11266,7 +11912,7 @@ function baseCopy(source, props, object) {
module.exports = baseCopy;
-},{}],57:[function(require,module,exports){
+},{}],72:[function(require,module,exports){
/**
* lodash 3.0.3 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11325,7 +11971,7 @@ function isObject(value) {
module.exports = baseCreate;
-},{}],58:[function(require,module,exports){
+},{}],73:[function(require,module,exports){
/**
* lodash 3.9.1 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11464,7 +12110,7 @@ function isNative(value) {
module.exports = getNative;
-},{}],59:[function(require,module,exports){
+},{}],74:[function(require,module,exports){
/**
* lodash 3.0.9 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11598,7 +12244,7 @@ function isObject(value) {
module.exports = isIterateeCall;
-},{}],60:[function(require,module,exports){
+},{}],75:[function(require,module,exports){
/**
* lodash 3.1.1 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -11655,7 +12301,7 @@ function create(prototype, properties, guard) {
module.exports = create;
-},{"lodash._baseassign":55,"lodash._basecreate":57,"lodash._isiterateecall":59}],61:[function(require,module,exports){
+},{"lodash._baseassign":70,"lodash._basecreate":72,"lodash._isiterateecall":74}],76:[function(require,module,exports){
/**
* lodash (Custom Build)
* Build: `lodash modularize exports="npm" -o ./`
@@ -11886,7 +12532,7 @@ function isObjectLike(value) {
module.exports = isArguments;
-},{}],62:[function(require,module,exports){
+},{}],77:[function(require,module,exports){
/**
* lodash 3.0.4 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -12068,7 +12714,7 @@ function isNative(value) {
module.exports = isArray;
-},{}],63:[function(require,module,exports){
+},{}],78:[function(require,module,exports){
/**
* lodash 3.1.2 (Custom Build)
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -12306,7 +12952,7 @@ function keysIn(object) {
module.exports = keys;
-},{"lodash._getnative":58,"lodash.isarguments":61,"lodash.isarray":62}],64:[function(require,module,exports){
+},{"lodash._getnative":73,"lodash.isarguments":76,"lodash.isarray":77}],79:[function(require,module,exports){
(function (process){
var path = require('path');
var fs = require('fs');
@@ -12408,7 +13054,7 @@ mkdirP.sync = function sync (p, opts, made) {
};
}).call(this,require('_process'))
-},{"_process":67,"fs":42,"path":42}],65:[function(require,module,exports){
+},{"_process":82,"fs":42,"path":42}],80:[function(require,module,exports){
exports.endianness = function () { return 'LE' };
exports.hostname = function () {
@@ -12455,7 +13101,7 @@ exports.tmpdir = exports.tmpDir = function () {
exports.EOL = '\n';
-},{}],66:[function(require,module,exports){
+},{}],81:[function(require,module,exports){
(function (process){
'use strict';
@@ -12502,7 +13148,7 @@ function nextTick(fn, arg1, arg2, arg3) {
}
}).call(this,require('_process'))
-},{"_process":67}],67:[function(require,module,exports){
+},{"_process":82}],82:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
@@ -12673,6 +13319,10 @@ process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
+process.prependListener = noop;
+process.prependOnceListener = noop;
+
+process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
@@ -12684,10 +13334,10 @@ process.chdir = function (dir) {
};
process.umask = function() { return 0; };
-},{}],68:[function(require,module,exports){
-module.exports = require("./lib/_stream_duplex.js")
+},{}],83:[function(require,module,exports){
+module.exports = require('./lib/_stream_duplex.js');
-},{"./lib/_stream_duplex.js":69}],69:[function(require,module,exports){
+},{"./lib/_stream_duplex.js":84}],84:[function(require,module,exports){
// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
@@ -12763,7 +13413,7 @@ function forEach(xs, f) {
f(xs[i], i);
}
}
-},{"./_stream_readable":71,"./_stream_writable":73,"core-util-is":45,"inherits":51,"process-nextick-args":66}],70:[function(require,module,exports){
+},{"./_stream_readable":86,"./_stream_writable":88,"core-util-is":45,"inherits":66,"process-nextick-args":81}],85:[function(require,module,exports){
// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
@@ -12790,7 +13440,7 @@ function PassThrough(options) {
PassThrough.prototype._transform = function (chunk, encoding, cb) {
cb(null, chunk);
};
-},{"./_stream_transform":72,"core-util-is":45,"inherits":51}],71:[function(require,module,exports){
+},{"./_stream_transform":87,"core-util-is":45,"inherits":66}],86:[function(require,module,exports){
(function (process){
'use strict';
@@ -12804,6 +13454,10 @@ var processNextTick = require('process-nextick-args');
var isArray = require('isarray');
/**/
+/**/
+var Duplex;
+/**/
+
Readable.ReadableState = ReadableState;
/**/
@@ -12815,14 +13469,7 @@ var EElistenerCount = function (emitter, type) {
/**/
/**/
-var Stream;
-(function () {
- try {
- Stream = require('st' + 'ream');
- } catch (_) {} finally {
- if (!Stream) Stream = require('events').EventEmitter;
- }
-})();
+var Stream = require('./internal/streams/stream');
/**/
var Buffer = require('buffer').Buffer;
@@ -12850,7 +13497,11 @@ var StringDecoder;
util.inherits(Readable, Stream);
+var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
+
function prependListener(emitter, event, fn) {
+ // Sadly this is not cacheable as some libraries bundle their own
+ // event emitter implementation with them.
if (typeof emitter.prependListener === 'function') {
return emitter.prependListener(event, fn);
} else {
@@ -12862,7 +13513,6 @@ function prependListener(emitter, event, fn) {
}
}
-var Duplex;
function ReadableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
@@ -12881,7 +13531,7 @@ function ReadableState(options, stream) {
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
// cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
+ this.highWaterMark = ~~this.highWaterMark;
// A linked list is used to store data chunks instead of an array because the
// linked list can remove elements from the beginning faster than
@@ -12932,7 +13582,6 @@ function ReadableState(options, stream) {
}
}
-var Duplex;
function Readable(options) {
Duplex = Duplex || require('./_stream_duplex');
@@ -13255,7 +13904,7 @@ function maybeReadMore_(stream, state) {
// for virtual (non-string, non-buffer) streams, "length" is somewhat
// arbitrary, and perhaps not very meaningful.
Readable.prototype._read = function (n) {
- this.emit('error', new Error('not implemented'));
+ this.emit('error', new Error('_read() is not implemented'));
};
Readable.prototype.pipe = function (dest, pipeOpts) {
@@ -13433,16 +14082,16 @@ Readable.prototype.unpipe = function (dest) {
state.pipesCount = 0;
state.flowing = false;
- for (var _i = 0; _i < len; _i++) {
- dests[_i].emit('unpipe', this);
+ for (var i = 0; i < len; i++) {
+ dests[i].emit('unpipe', this);
}return this;
}
// try to find the right one.
- var i = indexOf(state.pipes, dest);
- if (i === -1) return this;
+ var index = indexOf(state.pipes, dest);
+ if (index === -1) return this;
- state.pipes.splice(i, 1);
+ state.pipes.splice(index, 1);
state.pipesCount -= 1;
if (state.pipesCount === 1) state.pipes = state.pipes[0];
@@ -13574,10 +14223,9 @@ Readable.prototype.wrap = function (stream) {
}
// proxy certain important events.
- var events = ['error', 'close', 'destroy', 'pause', 'resume'];
- forEach(events, function (ev) {
- stream.on(ev, self.emit.bind(self, ev));
- });
+ for (var n = 0; n < kProxyEvents.length; n++) {
+ stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
+ }
// when we try to consume some more bytes, simply unpause the
// underlying stream.
@@ -13730,7 +14378,7 @@ function indexOf(xs, x) {
return -1;
}
}).call(this,require('_process'))
-},{"./_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){
+},{"./_stream_duplex":84,"./internal/streams/BufferList":89,"./internal/streams/stream":90,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"events":63,"inherits":66,"isarray":68,"process-nextick-args":81,"string_decoder/":96,"util":40}],87:[function(require,module,exports){
// a transform stream is a readable/writable stream where you do
// something with the data. Sometimes it's called a "filter",
// but that's not a great name for it, since that implies a thing where
@@ -13827,7 +14475,6 @@ function Transform(options) {
this._transformState = new TransformState(this);
- // when the writable side finishes, then flush out anything remaining.
var stream = this;
// start out asking for a readable event once data is transformed.
@@ -13844,9 +14491,10 @@ function Transform(options) {
if (typeof options.flush === 'function') this._flush = options.flush;
}
+ // When the writable side finishes, then flush out anything remaining.
this.once('prefinish', function () {
- if (typeof this._flush === 'function') this._flush(function (er) {
- done(stream, er);
+ if (typeof this._flush === 'function') this._flush(function (er, data) {
+ done(stream, er, data);
});else done(stream);
});
}
@@ -13867,7 +14515,7 @@ Transform.prototype.push = function (chunk, encoding) {
// an error, then that'll put the hurt on the whole operation. If you
// never call cb(), then you'll never get another chunk.
Transform.prototype._transform = function (chunk, encoding, cb) {
- throw new Error('Not implemented');
+ throw new Error('_transform() is not implemented');
};
Transform.prototype._write = function (chunk, encoding, cb) {
@@ -13897,9 +14545,11 @@ Transform.prototype._read = function (n) {
}
};
-function done(stream, er) {
+function done(stream, er, data) {
if (er) return stream.emit('error', er);
+ if (data !== null && data !== undefined) stream.push(data);
+
// if there's nothing in the write buffer, then that means
// that nothing more will ever be provided
var ws = stream._writableState;
@@ -13911,7 +14561,7 @@ function done(stream, er) {
return stream.push(null);
}
-},{"./_stream_duplex":69,"core-util-is":45,"inherits":51}],73:[function(require,module,exports){
+},{"./_stream_duplex":84,"core-util-is":45,"inherits":66}],88:[function(require,module,exports){
(function (process){
// A bit simpler than readable streams.
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
@@ -13929,6 +14579,10 @@ var processNextTick = require('process-nextick-args');
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
/**/
+/**/
+var Duplex;
+/**/
+
Writable.WritableState = WritableState;
/**/
@@ -13943,14 +14597,7 @@ var internalUtil = {
/**/
/**/
-var Stream;
-(function () {
- try {
- Stream = require('st' + 'ream');
- } catch (_) {} finally {
- if (!Stream) Stream = require('events').EventEmitter;
- }
-})();
+var Stream = require('./internal/streams/stream');
/**/
var Buffer = require('buffer').Buffer;
@@ -13969,7 +14616,6 @@ function WriteReq(chunk, encoding, cb) {
this.next = null;
}
-var Duplex;
function WritableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
@@ -13989,8 +14635,9 @@ function WritableState(options, stream) {
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
// cast to ints.
- this.highWaterMark = ~ ~this.highWaterMark;
+ this.highWaterMark = ~~this.highWaterMark;
+ // drain event flag.
this.needDrain = false;
// at the start of calling end()
this.ending = false;
@@ -14065,7 +14712,7 @@ function WritableState(options, stream) {
this.corkedRequestsFree = new CorkedRequest(this);
}
-WritableState.prototype.getBuffer = function writableStateGetBuffer() {
+WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
var out = [];
while (current) {
@@ -14085,13 +14732,37 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
} catch (_) {}
})();
-var Duplex;
+// Test _writableState for inheritance to account for Duplex streams,
+// whose prototype chain only points to Readable.
+var realHasInstance;
+if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
+ realHasInstance = Function.prototype[Symbol.hasInstance];
+ Object.defineProperty(Writable, Symbol.hasInstance, {
+ value: function (object) {
+ if (realHasInstance.call(this, object)) return true;
+
+ return object && object._writableState instanceof WritableState;
+ }
+ });
+} else {
+ realHasInstance = function (object) {
+ return object instanceof this;
+ };
+}
+
function Writable(options) {
Duplex = Duplex || require('./_stream_duplex');
- // Writable ctor is applied to Duplexes, though they're not
- // instanceof Writable, they're instanceof Readable.
- if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
+ // Writable ctor is applied to Duplexes, too.
+ // `realHasInstance` is necessary because using plain `instanceof`
+ // would return false, as no `_writableState` property is attached.
+
+ // Trying to use the custom `instanceof` for Writable here will also break the
+ // Node.js LazyTransform implementation, which has a non-trivial getter for
+ // `_writableState` that would lead to infinite recursion.
+ if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
+ return new Writable(options);
+ }
this._writableState = new WritableState(options, this);
@@ -14119,20 +14790,16 @@ function writeAfterEnd(stream, cb) {
processNextTick(cb, er);
}
-// If we get something that is not a buffer, string, null, or undefined,
-// and we're not in objectMode, then that's an error.
-// Otherwise stream chunks are all considered to be of length=1, and the
-// watermarks determine how many objects to keep in the buffer, rather than
-// how many bytes or characters.
+// Checks that a user-supplied chunk is valid, especially for the particular
+// mode the stream is in. Currently this means that `null` is never accepted
+// and undefined/non-string values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) {
var valid = true;
var er = false;
- // Always throw error if a null is written
- // if we are not in object mode then throw
- // if it is not a buffer, string, or undefined.
+
if (chunk === null) {
er = new TypeError('May not write null values to stream');
- } else if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
+ } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
er = new TypeError('Invalid non-string/buffer chunk');
}
if (er) {
@@ -14146,19 +14813,20 @@ function validChunk(stream, state, chunk, cb) {
Writable.prototype.write = function (chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
+ var isBuf = Buffer.isBuffer(chunk);
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
+ if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
if (typeof cb !== 'function') cb = nop;
- if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) {
+ if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
state.pendingcb++;
- ret = writeOrBuffer(this, state, chunk, encoding, cb);
+ ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
}
return ret;
@@ -14198,10 +14866,11 @@ function decodeChunk(state, chunk, encoding) {
// if we're already writing something, then just put this
// in the queue, and wait our turn. Otherwise, call _write
// If we return false, then we need a drain event, so set that flag.
-function writeOrBuffer(stream, state, chunk, encoding, cb) {
- chunk = decodeChunk(state, chunk, encoding);
-
- if (Buffer.isBuffer(chunk)) encoding = 'buffer';
+function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
+ if (!isBuf) {
+ chunk = decodeChunk(state, chunk, encoding);
+ if (Buffer.isBuffer(chunk)) encoding = 'buffer';
+ }
var len = state.objectMode ? 1 : chunk.length;
state.length += len;
@@ -14270,8 +14939,8 @@ function onwrite(stream, er) {
asyncWrite(afterWrite, stream, state, finished, cb);
/**/
} else {
- afterWrite(stream, state, finished, cb);
- }
+ afterWrite(stream, state, finished, cb);
+ }
}
}
@@ -14351,7 +15020,7 @@ function clearBuffer(stream, state) {
}
Writable.prototype._write = function (chunk, encoding, cb) {
- cb(new Error('not implemented'));
+ cb(new Error('_write() is not implemented'));
};
Writable.prototype._writev = null;
@@ -14422,7 +15091,6 @@ function CorkedRequest(state) {
this.next = null;
this.entry = null;
-
this.finish = function (err) {
var entry = _this.entry;
_this.entry = null;
@@ -14440,7 +15108,7 @@ function CorkedRequest(state) {
};
}
}).call(this,require('_process'))
-},{"./_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){
+},{"./_stream_duplex":84,"./internal/streams/stream":90,"_process":82,"buffer":44,"buffer-shims":43,"core-util-is":45,"inherits":66,"process-nextick-args":81,"util-deprecate":97}],89:[function(require,module,exports){
'use strict';
var Buffer = require('buffer').Buffer;
@@ -14505,36 +15173,28 @@ BufferList.prototype.concat = function (n) {
}
return ret;
};
-},{"buffer":44,"buffer-shims":43}],75:[function(require,module,exports){
-module.exports = require("./lib/_stream_passthrough.js")
+},{"buffer":44,"buffer-shims":43}],90:[function(require,module,exports){
+module.exports = require('events').EventEmitter;
-},{"./lib/_stream_passthrough.js":70}],76:[function(require,module,exports){
-(function (process){
-var Stream = (function (){
- try {
- return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify
- } catch(_){}
-}());
+},{"events":63}],91:[function(require,module,exports){
+module.exports = require('./readable').PassThrough
+
+},{"./readable":92}],92:[function(require,module,exports){
exports = module.exports = require('./lib/_stream_readable.js');
-exports.Stream = Stream || exports;
+exports.Stream = exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
-if (!process.browser && process.env.READABLE_STREAM === 'disable' && Stream) {
- module.exports = Stream;
-}
+},{"./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}],93:[function(require,module,exports){
+module.exports = require('./readable').Transform
-}).call(this,require('_process'))
-},{"./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){
-module.exports = require("./lib/_stream_transform.js")
+},{"./readable":92}],94:[function(require,module,exports){
+module.exports = require('./lib/_stream_writable.js');
-},{"./lib/_stream_transform.js":72}],78:[function(require,module,exports){
-module.exports = require("./lib/_stream_writable.js")
-
-},{"./lib/_stream_writable.js":73}],79:[function(require,module,exports){
+},{"./lib/_stream_writable.js":88}],95:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -14663,230 +15323,281 @@ Stream.prototype.pipe = function(dest, options) {
return dest;
};
-},{"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){
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
+},{"events":63,"inherits":66,"readable-stream/duplex.js":83,"readable-stream/passthrough.js":91,"readable-stream/readable.js":92,"readable-stream/transform.js":93,"readable-stream/writable.js":94}],96:[function(require,module,exports){
+'use strict';
var Buffer = require('buffer').Buffer;
+var bufferShim = require('buffer-shims');
-var isBufferEncoding = Buffer.isEncoding
- || function(encoding) {
- switch (encoding && encoding.toLowerCase()) {
- case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
- default: return false;
- }
- }
-
+var isEncoding = Buffer.isEncoding || function (encoding) {
+ encoding = '' + encoding;
+ switch (encoding && encoding.toLowerCase()) {
+ case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
+ return true;
+ default:
+ return false;
+ }
+};
-function assertEncoding(encoding) {
- if (encoding && !isBufferEncoding(encoding)) {
- throw new Error('Unknown encoding: ' + encoding);
+function _normalizeEncoding(enc) {
+ if (!enc) return 'utf8';
+ var retried;
+ while (true) {
+ switch (enc) {
+ case 'utf8':
+ case 'utf-8':
+ return 'utf8';
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return 'utf16le';
+ case 'latin1':
+ case 'binary':
+ return 'latin1';
+ case 'base64':
+ case 'ascii':
+ case 'hex':
+ return enc;
+ default:
+ if (retried) return; // undefined
+ enc = ('' + enc).toLowerCase();
+ retried = true;
+ }
}
+};
+
+// Do not cache `Buffer.isEncoding` when checking encoding names as some
+// modules monkey-patch it to support additional encodings
+function normalizeEncoding(enc) {
+ var nenc = _normalizeEncoding(enc);
+ if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
+ return nenc || enc;
}
// StringDecoder provides an interface for efficiently splitting a series of
// buffers into a series of JS strings without breaking apart multi-byte
-// characters. CESU-8 is handled as part of the UTF-8 encoding.
-//
-// @TODO Handling all encodings inside a single object makes it very difficult
-// to reason about this code, so it should be split up in the future.
-// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
-// points as used by CESU-8.
-var StringDecoder = exports.StringDecoder = function(encoding) {
- this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
- assertEncoding(encoding);
+// characters.
+exports.StringDecoder = StringDecoder;
+function StringDecoder(encoding) {
+ this.encoding = normalizeEncoding(encoding);
+ var nb;
switch (this.encoding) {
- case 'utf8':
- // CESU-8 represents each of Surrogate Pair by 3-bytes
- this.surrogateSize = 3;
- break;
- case 'ucs2':
case 'utf16le':
- // UTF-16 represents each of Surrogate Pair by 2-bytes
- this.surrogateSize = 2;
- this.detectIncompleteChar = utf16DetectIncompleteChar;
+ this.text = utf16Text;
+ this.end = utf16End;
+ nb = 4;
+ break;
+ case 'utf8':
+ this.fillLast = utf8FillLast;
+ nb = 4;
break;
case 'base64':
- // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
- this.surrogateSize = 3;
- this.detectIncompleteChar = base64DetectIncompleteChar;
+ this.text = base64Text;
+ this.end = base64End;
+ nb = 3;
break;
default:
- this.write = passThroughWrite;
+ this.write = simpleWrite;
+ this.end = simpleEnd;
return;
}
+ this.lastNeed = 0;
+ this.lastTotal = 0;
+ this.lastChar = bufferShim.allocUnsafe(nb);
+}
- // Enough space to store all bytes of a single character. UTF-8 needs 4
- // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
- this.charBuffer = new Buffer(6);
- // Number of bytes received for the current incomplete multi-byte character.
- this.charReceived = 0;
- // Number of bytes expected for the current incomplete multi-byte character.
- this.charLength = 0;
+StringDecoder.prototype.write = function (buf) {
+ if (buf.length === 0) return '';
+ var r;
+ var i;
+ if (this.lastNeed) {
+ r = this.fillLast(buf);
+ if (r === undefined) return '';
+ i = this.lastNeed;
+ this.lastNeed = 0;
+ } else {
+ i = 0;
+ }
+ if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
+ return r || '';
};
+StringDecoder.prototype.end = utf8End;
-// write decodes the given buffer and returns it as JS string that is
-// guaranteed to not contain any partial multi-byte characters. Any partial
-// character found at the end of the buffer is buffered up, and will be
-// returned when calling write again with the remaining bytes.
-//
-// Note: Converting a Buffer containing an orphan surrogate to a String
-// currently works, but converting a String to a Buffer (via `new Buffer`, or
-// Buffer#write) will replace incomplete surrogates with the unicode
-// replacement character. See https://codereview.chromium.org/121173009/ .
-StringDecoder.prototype.write = function(buffer) {
- var charStr = '';
- // if our last write ended with an incomplete multibyte character
- while (this.charLength) {
- // determine how many remaining bytes this buffer has to offer for this char
- var available = (buffer.length >= this.charLength - this.charReceived) ?
- this.charLength - this.charReceived :
- buffer.length;
-
- // add the new bytes to the char buffer
- buffer.copy(this.charBuffer, this.charReceived, 0, available);
- this.charReceived += available;
-
- if (this.charReceived < this.charLength) {
- // still not enough chars in this buffer? wait for more ...
- return '';
- }
-
- // remove bytes belonging to the current character from the buffer
- buffer = buffer.slice(available, buffer.length);
-
- // get the character that was split
- charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
-
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- var charCode = charStr.charCodeAt(charStr.length - 1);
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- this.charLength += this.surrogateSize;
- charStr = '';
- continue;
- }
- this.charReceived = this.charLength = 0;
+// Returns only complete characters in a Buffer
+StringDecoder.prototype.text = utf8Text;
- // if there are no more bytes in this buffer, just emit our char
- if (buffer.length === 0) {
- return charStr;
- }
- break;
+// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
+StringDecoder.prototype.fillLast = function (buf) {
+ if (this.lastNeed <= buf.length) {
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
+ this.lastNeed -= buf.length;
+};
- // determine and set charLength / charReceived
- this.detectIncompleteChar(buffer);
+// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
+// continuation byte.
+function utf8CheckByte(byte) {
+ if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
+ return -1;
+}
- var end = buffer.length;
- if (this.charLength) {
- // buffer the incomplete character bytes we got
- buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
- end -= this.charReceived;
+// Checks at most 3 bytes at the end of a Buffer in order to detect an
+// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
+// needed to complete the UTF-8 character (if applicable) are returned.
+function utf8CheckIncomplete(self, buf, i) {
+ var j = buf.length - 1;
+ if (j < i) return 0;
+ var nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) self.lastNeed = nb - 1;
+ return nb;
}
-
- charStr += buffer.toString(this.encoding, 0, end);
-
- var end = charStr.length - 1;
- var charCode = charStr.charCodeAt(end);
- // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
- if (charCode >= 0xD800 && charCode <= 0xDBFF) {
- var size = this.surrogateSize;
- this.charLength += size;
- this.charReceived += size;
- this.charBuffer.copy(this.charBuffer, size, 0, size);
- buffer.copy(this.charBuffer, 0, 0, size);
- return charStr.substring(0, end);
+ if (--j < i) return 0;
+ nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) self.lastNeed = nb - 2;
+ return nb;
}
-
- // or just emit the charStr
- return charStr;
-};
-
-// detectIncompleteChar determines if there is an incomplete UTF-8 character at
-// the end of the given buffer. If so, it sets this.charLength to the byte
-// length that character, and sets this.charReceived to the number of bytes
-// that are available for this character.
-StringDecoder.prototype.detectIncompleteChar = function(buffer) {
- // determine how many bytes we have to check at the end of this buffer
- var i = (buffer.length >= 3) ? 3 : buffer.length;
-
- // Figure out if one of the last i bytes of our buffer announces an
- // incomplete char.
- for (; i > 0; i--) {
- var c = buffer[buffer.length - i];
-
- // See http://en.wikipedia.org/wiki/UTF-8#Description
-
- // 110XXXXX
- if (i == 1 && c >> 5 == 0x06) {
- this.charLength = 2;
- break;
+ if (--j < i) return 0;
+ nb = utf8CheckByte(buf[j]);
+ if (nb >= 0) {
+ if (nb > 0) {
+ if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
+ return nb;
+ }
+ return 0;
+}
- // 1110XXXX
- if (i <= 2 && c >> 4 == 0x0E) {
- this.charLength = 3;
- break;
+// Validates as many continuation bytes for a multi-byte UTF-8 character as
+// needed or are available. If we see a non-continuation byte where we expect
+// one, we "replace" the validated continuation bytes we've seen so far with
+// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
+// behavior. The continuation byte check is included three times in the case
+// where all of the continuation bytes for a character exist in the same buffer.
+// It is also done this way as a slight performance increase instead of using a
+// loop.
+function utf8CheckExtraBytes(self, buf, p) {
+ if ((buf[0] & 0xC0) !== 0x80) {
+ self.lastNeed = 0;
+ return '\ufffd'.repeat(p);
+ }
+ if (self.lastNeed > 1 && buf.length > 1) {
+ if ((buf[1] & 0xC0) !== 0x80) {
+ self.lastNeed = 1;
+ return '\ufffd'.repeat(p + 1);
+ }
+ if (self.lastNeed > 2 && buf.length > 2) {
+ if ((buf[2] & 0xC0) !== 0x80) {
+ self.lastNeed = 2;
+ return '\ufffd'.repeat(p + 2);
+ }
}
+ }
+}
- // 11110XXX
- if (i <= 3 && c >> 3 == 0x1E) {
- this.charLength = 4;
- break;
+// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
+function utf8FillLast(buf) {
+ var p = this.lastTotal - this.lastNeed;
+ var r = utf8CheckExtraBytes(this, buf, p);
+ if (r !== undefined) return r;
+ if (this.lastNeed <= buf.length) {
+ buf.copy(this.lastChar, p, 0, this.lastNeed);
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
+ }
+ buf.copy(this.lastChar, p, 0, buf.length);
+ this.lastNeed -= buf.length;
+}
+
+// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
+// partial character, the character's bytes are buffered until the required
+// number of bytes are available.
+function utf8Text(buf, i) {
+ var total = utf8CheckIncomplete(this, buf, i);
+ if (!this.lastNeed) return buf.toString('utf8', i);
+ this.lastTotal = total;
+ var end = buf.length - (total - this.lastNeed);
+ buf.copy(this.lastChar, 0, end);
+ return buf.toString('utf8', i, end);
+}
+
+// For UTF-8, a replacement character for each buffered byte of a (partial)
+// character needs to be added to the output.
+function utf8End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
+ return r;
+}
+
+// UTF-16LE typically needs two bytes per character, but even if we have an even
+// number of bytes available, we need to check if we end on a leading/high
+// surrogate. In that case, we need to wait for the next two bytes in order to
+// decode the last character properly.
+function utf16Text(buf, i) {
+ if ((buf.length - i) % 2 === 0) {
+ var r = buf.toString('utf16le', i);
+ if (r) {
+ var c = r.charCodeAt(r.length - 1);
+ if (c >= 0xD800 && c <= 0xDBFF) {
+ this.lastNeed = 2;
+ this.lastTotal = 4;
+ this.lastChar[0] = buf[buf.length - 2];
+ this.lastChar[1] = buf[buf.length - 1];
+ return r.slice(0, -1);
+ }
}
+ return r;
}
- this.charReceived = i;
-};
-
-StringDecoder.prototype.end = function(buffer) {
- var res = '';
- if (buffer && buffer.length)
- res = this.write(buffer);
+ this.lastNeed = 1;
+ this.lastTotal = 2;
+ this.lastChar[0] = buf[buf.length - 1];
+ return buf.toString('utf16le', i, buf.length - 1);
+}
- if (this.charReceived) {
- var cr = this.charReceived;
- var buf = this.charBuffer;
- var enc = this.encoding;
- res += buf.slice(0, cr).toString(enc);
+// For UTF-16LE we do not explicitly append special replacement characters if we
+// end on a partial character, we simply let v8 handle that.
+function utf16End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) {
+ var end = this.lastTotal - this.lastNeed;
+ return r + this.lastChar.toString('utf16le', 0, end);
}
+ return r;
+}
- return res;
-};
-
-function passThroughWrite(buffer) {
- return buffer.toString(this.encoding);
+function base64Text(buf, i) {
+ var n = (buf.length - i) % 3;
+ if (n === 0) return buf.toString('base64', i);
+ this.lastNeed = 3 - n;
+ this.lastTotal = 3;
+ if (n === 1) {
+ this.lastChar[0] = buf[buf.length - 1];
+ } else {
+ this.lastChar[0] = buf[buf.length - 2];
+ this.lastChar[1] = buf[buf.length - 1];
+ }
+ return buf.toString('base64', i, buf.length - n);
}
-function utf16DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 2;
- this.charLength = this.charReceived ? 2 : 0;
+function base64End(buf) {
+ var r = buf && buf.length ? this.write(buf) : '';
+ if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
+ return r;
}
-function base64DetectIncompleteChar(buffer) {
- this.charReceived = buffer.length % 3;
- this.charLength = this.charReceived ? 3 : 0;
+// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
+function simpleWrite(buf) {
+ return buf.toString(this.encoding);
}
-},{"buffer":44}],81:[function(require,module,exports){
+function simpleEnd(buf) {
+ return buf && buf.length ? this.write(buf) : '';
+}
+},{"buffer":44,"buffer-shims":43}],97:[function(require,module,exports){
(function (global){
/**
@@ -14957,16 +15668,16 @@ function config (name) {
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{}],82:[function(require,module,exports){
-arguments[4][51][0].apply(exports,arguments)
-},{"dup":51}],83:[function(require,module,exports){
+},{}],98:[function(require,module,exports){
+arguments[4][66][0].apply(exports,arguments)
+},{"dup":66}],99:[function(require,module,exports){
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
-},{}],84:[function(require,module,exports){
+},{}],100:[function(require,module,exports){
(function (process,global){
// Copyright Joyent, Inc. and other Node contributors.
//
@@ -15556,4 +16267,4 @@ function hasOwnProperty(obj, prop) {
}
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./support/isBuffer":83,"_process":67,"inherits":82}]},{},[1]);
+},{"./support/isBuffer":99,"_process":82,"inherits":98}]},{},[1]);
diff --git a/package.json b/package.json
index c0586eb591..a65cf2b733 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mocha",
- "version": "3.3.0",
+ "version": "3.4.0",
"description": "simple, flexible, fun test framework",
"keywords": [
"mocha",