aboutsummaryrefslogtreecommitdiff
path: root/node_modules/diff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
commit5f466137ad6ac596600e3ff53c9b786815398445 (patch)
treef914c221874f0b16bf3def7ac01d59d1a99a3b0b /node_modules/diff
parentc9f5ac8e763eda19aa0564179300cfff76785435 (diff)
downloadwallet-core-5f466137ad6ac596600e3ff53c9b786815398445.tar.xz
node_modules, clean up package.json
Diffstat (limited to 'node_modules/diff')
-rw-r--r--node_modules/diff/README.md131
-rw-r--r--node_modules/diff/diff.js619
-rw-r--r--node_modules/diff/package.json63
3 files changed, 123 insertions, 690 deletions
diff --git a/node_modules/diff/README.md b/node_modules/diff/README.md
index b867e19a7..03b5845d8 100644
--- a/node_modules/diff/README.md
+++ b/node_modules/diff/README.md
@@ -1,6 +1,7 @@
# jsdiff
-[![Build Status](https://secure.travis-ci.org/kpdecker/jsdiff.png)](http://travis-ci.org/kpdecker/jsdiff)
+[![Build Status](https://secure.travis-ci.org/kpdecker/jsdiff.svg)](http://travis-ci.org/kpdecker/jsdiff)
+[![Sauce Test Status](https://saucelabs.com/buildstatus/jsdiff)](https://saucelabs.com/u/jsdiff)
A javascript text differencing implementation.
@@ -15,41 +16,46 @@ or
bower install jsdiff
-or
-
- git clone git://github.com/kpdecker/jsdiff.git
## API
-* `JsDiff.diffChars(oldStr, newStr[, callback])` - diffs two blocks of text, comparing character by character.
+* `JsDiff.diffChars(oldStr, newStr[, options])` - diffs two blocks of text, comparing character by character.
+
+ Returns a list of change objects (See below).
+
+* `JsDiff.diffWords(oldStr, newStr[, options])` - diffs two blocks of text, comparing word by word, ignoring whitespace.
Returns a list of change objects (See below).
-* `JsDiff.diffWords(oldStr, newStr[, callback])` - diffs two blocks of text, comparing word by word, ignoring whitespace.
+* `JsDiff.diffWordsWithSpace(oldStr, newStr[, options])` - diffs two blocks of text, comparing word by word, treating whitespace as significant.
Returns a list of change objects (See below).
-* `JsDiff.diffWordsWithSpace(oldStr, newStr[, callback])` - diffs two blocks of text, comparing word by word, treating whitespace as significant.
+* `JsDiff.diffLines(oldStr, newStr[, options])` - diffs two blocks of text, comparing line by line.
+
+ Options
+ * `ignoreWhitespace`: `true` to ignore leading and trailing whitespace. This is the same as `diffTrimmedLines`
+ * `newlineIsToken`: `true` to treat newline characters as separate tokens. This allows for changes to the newline structure to occur independently of the line content and to be treated as such. In general this is the more human friendly form of `diffLines` and `diffLines` is better suited for patches and other computer friendly output.
Returns a list of change objects (See below).
-* `JsDiff.diffLines(oldStr, newStr[, callback])` - diffs two blocks of text, comparing line by line.
+* `JsDiff.diffTrimmedLines(oldStr, newStr[, options])` - diffs two blocks of text, comparing line by line, ignoring leading and trailing whitespace.
Returns a list of change objects (See below).
-* `JsDiff.diffTrimmedLines(oldStr, newStr[, callback])` - diffs two blocks of text, comparing line by line, ignoring leading and trailing whitespace.
+* `JsDiff.diffSentences(oldStr, newStr[, options])` - diffs two blocks of text, comparing sentence by sentence.
Returns a list of change objects (See below).
-* `JsDiff.diffSentences(oldStr, newStr[, callback])` - diffs two blocks of text, comparing sentence by sentence.
+* `JsDiff.diffCss(oldStr, newStr[, options])` - diffs two blocks of text, comparing CSS tokens.
Returns a list of change objects (See below).
-* `JsDiff.diffCss(oldStr, newStr[, callback])` - diffs two blocks of text, comparing CSS tokens.
+* `JsDiff.diffJson(oldObj, newObj[, options])` - diffs two JSON objects, comparing the fields defined on each. The order of fields, etc does not matter in this comparison.
Returns a list of change objects (See below).
-* `JsDiff.diffJson(oldObj, newObj[, callback])` - diffs two JSON objects, comparing the fields defined on each. The order of fields, etc does not matter in this comparison.
+* `JsDiff.diffArrays(oldArr, newArr[, options])` - diffs two arrays, comparing each item for strict equality (===).
Returns a list of change objects (See below).
@@ -61,23 +67,59 @@ or
* `oldStr` : Original string value
* `newStr` : New string value
* `oldHeader` : Additional information to include in the old file header
- * `newHeader` : Additional information to include in thew new file header
+ * `newHeader` : Additional information to include in the new file header
+ * `options` : An object with options. Currently, only `context` is supported and describes how many lines of context should be included.
* `JsDiff.createPatch(fileName, oldStr, newStr, oldHeader, newHeader)` - creates a unified diff patch.
Just like JsDiff.createTwoFilesPatch, but with oldFileName being equal to newFileName.
-* `JsDiff.applyPatch(oldStr, diffStr)` - applies a unified diff patch.
- Return a string containing new version of provided data.
+* `JsDiff.structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options)` - returns an object with an array of hunk objects.
+
+ This method is similar to createTwoFilesPatch, but returns a data structure
+ suitable for further processing. Parameters are the same as createTwoFilesPatch. The data structure returned may look like this:
+
+ ```js
+ {
+ oldFileName: 'oldfile', newFileName: 'newfile',
+ oldHeader: 'header1', newHeader: 'header2',
+ hunks: [{
+ oldStart: 1, oldLines: 3, newStart: 1, newLines: 3,
+ lines: [' line2', ' line3', '-line4', '+line5', '\\ No newline at end of file'],
+ }]
+ }
+ ```
+
+* `JsDiff.applyPatch(source, patch[, options])` - applies a unified diff patch.
+
+ Return a string containing new version of provided data. `patch` may be a string diff or the output from the `parsePatch` or `structuredPatch` methods.
+
+ The optional `options` object may have the following keys:
+
+ - `fuzzFactor`: Number of lines that are allowed to differ before rejecting a patch. Defaults to 0.
+ - `compareLine(lineNumber, line, operation, patchContent)`: Callback used to compare to given lines to determine if they should be considered equal when patching. Defaults to strict equality but may be overriden to provide fuzzier comparison. Should return false if the lines should be rejected.
+
+* `JsDiff.applyPatches(patch, options)` - applies one or more patches.
+
+ This method will iterate over the contents of the patch and apply to data provided through callbacks. The general flow for each patch index is:
+
+ - `options.loadFile(index, callback)` is called. The caller should then load the contents of the file and then pass that to the `callback(err, data)` callback. Passing an `err` will terminate further patch execution.
+ - `options.patched(index, content, callback)` is called once the patch has been applied. `content` will be the return value from `applyPatch`. When it's ready, the caller should call `callback(err)` callback. Passing an `err` will terminate further patch execution.
+
+ Once all patches have been applied or an error occurs, the `options.complete(err)` callback is made.
+
+* `JsDiff.parsePatch(diffStr)` - Parses a patch into structured data
+
+ Return a JSON object representation of the a patch, suitable for use with the `applyPatch` method. This parses to the same structure returned by `JsDiff.structuredPatch`.
* `convertChangesToXML(changes)` - converts a list of changes to a serialized XML format
-All methods above which accept the optional callback method will run in sync mode when that parameter is omitted and in async mode when supplied. This allows for larger diffs without blocking the event loop.
+All methods above which accept the optional `callback` method will run in sync mode when that parameter is omitted and in async mode when supplied. This allows for larger diffs without blocking the event loop. This may be passed either directly as the final parameter or as the `callback` field in the `options` object.
### Change Objects
-Many of the methods above return change objects. These objects are consist of the following fields:
+Many of the methods above return change objects. These objects consist of the following fields:
* `value`: Text content
* `added`: True if the value was inserted into the new string
@@ -118,22 +160,28 @@ Basic example in a web page
<pre id="display"></pre>
<script src="diff.js"></script>
<script>
-var one = 'beep boop';
-var other = 'beep boob blah';
+var one = 'beep boop',
+ other = 'beep boob blah',
+ color = '',
+ span = null;
-var diff = JsDiff.diffChars(one, other);
+var diff = JsDiff.diffChars(one, other),
+ display = document.getElementById('display'),
+ fragment = document.createDocumentFragment();
diff.forEach(function(part){
// green for additions, red for deletions
// grey for common parts
- var color = part.added ? 'green' :
+ color = part.added ? 'green' :
part.removed ? 'red' : 'grey';
- var span = document.createElement('span');
+ span = document.createElement('span');
span.style.color = color;
span.appendChild(document
.createTextNode(part.value));
- display.appendChild(span);
+ fragment.appendChild(span);
});
+
+display.appendChild(fragment);
</script>
```
@@ -143,39 +191,12 @@ Open the above .html file in a browser and you should see
**[Full online demo](http://kpdecker.github.com/jsdiff)**
-## License
+## Compatibility
-Software License Agreement (BSD License)
+[![Sauce Test Status](https://saucelabs.com/browser-matrix/jsdiff.svg)](https://saucelabs.com/u/jsdiff)
-Copyright (c) 2009-2011, Kevin Decker kpdecker@gmail.com
-
-All rights reserved.
-
-Redistribution and use of this software in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above
- copyright notice, this list of conditions and the
- following disclaimer.
-
-* Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the
- following disclaimer in the documentation and/or other
- materials provided with the distribution.
-
-* Neither the name of Kevin Decker nor the names of its
- contributors may be used to endorse or promote products
- derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+jsdiff supports all ES3 environments with some known issues on IE8 and below. Under these browsers some diff algorithms such as word diff and others may fail due to lack of support for capturing groups in the `split` operation.
+## License
-[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kpdecker/jsdiff/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
+See [LICENSE](https://github.com/kpdecker/jsdiff/blob/master/LICENSE).
diff --git a/node_modules/diff/diff.js b/node_modules/diff/diff.js
deleted file mode 100644
index 421854a12..000000000
--- a/node_modules/diff/diff.js
+++ /dev/null
@@ -1,619 +0,0 @@
-/* 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
- */
-(function(global, undefined) {
- var objectPrototypeToString = Object.prototype.toString;
-
- /*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);
-
- for (var i = 0, n = arr.length; i < n; i++) {
- other[i] = mapper.call(that, arr[i], i, arr);
- }
- 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]);
- }
- }
- return ret;
- }
- function escapeHTML(s) {
- var n = s;
- n = n.replace(/&/g, '&amp;');
- n = n.replace(/</g, '&lt;');
- n = n.replace(/>/g, '&gt;');
- n = n.replace(/"/g, '&quot;');
-
- return n;
- }
-
- // 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 i;
-
- for (i = 0; i < stack.length; i += 1) {
- if (stack[i] === obj) {
- return replacementStack[i];
- }
- }
-
- var canonicalizedObj;
-
- 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);
- }
- 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;
-
- 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;
- });
-
- component.value = value.join('');
- } else {
- component.value = newString.slice(newPos, newPos + component.count).join('');
- }
- newPos += component.count;
-
- // Common case
- if (!component.added) {
- oldPos += component.count;
- }
- } 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;
- }
- }
- }
-
- return components;
- }
-
- function Diff(ignoreWhitespace) {
- this.ignoreWhitespace = ignoreWhitespace;
- }
- 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;
- }
- }
-
- // Handle the identity case (this is due to unrolling editLength == 0
- if (newString === oldString) {
- return done([{ value: newString }]);
- }
- if (!newString) {
- return done([{ value: oldString, removed: true }]);
- }
- if (!oldString) {
- return done([{ value: newString, added: true }]);
- }
-
- newString = this.tokenize(newString);
- oldString = this.tokenize(oldString);
-
- 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: newString.join('')}]);
- }
-
- // 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;
- }
-
- // 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);
- }
-
- 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(basePath.components, newString, oldString, self.useLongestToken));
- } else {
- // Otherwise track this path as a potential candidate and continue.
- bestPath[diagonalPath] = basePath;
- }
- }
-
- 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;
- }
- }
- }
- },
-
- 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++;
- }
-
- if (commonCount) {
- basePath.components.push({count: commonCount});
- }
-
- basePath.newPos = newPos;
- return oldPos;
- },
-
- equals: function(left, right) {
- var reWhitespace = /\S/;
- return left === right || (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right));
- },
- tokenize: function(value) {
- return value.split('');
- }
- };
-
- var CharDiff = new Diff();
-
- var WordDiff = new Diff(true);
- var WordWithSpaceDiff = new Diff();
- WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\s+|\b)/));
- };
-
- var CssDiff = new Diff(true);
- CssDiff.tokenize = function(value) {
- return removeEmpty(value.split(/([{}:;,]|\s+)/));
- };
-
- var LineDiff = new Diff();
-
- var TrimmedLineDiff = new Diff();
- TrimmedLineDiff.ignoreTrim = true;
-
- 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];
-
- // 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);
- }
- }
-
- return retLines;
- };
-
- var PatchDiff = new Diff();
- PatchDiff.tokenize = function(value) {
- var ret = [],
- 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) {
- ret[ret.length - 1] += line;
- } else {
- ret.push(line);
- }
- }
- return ret;
- };
-
- var SentenceDiff = new Diff();
- SentenceDiff.tokenize = function(value) {
- return removeEmpty(value.split(/(\S.+?[.!?])(?=\s+|$)/));
- };
-
- 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'));
- };
-
- var JsDiff = {
- Diff: Diff,
-
- 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); },
-
- diffSentences: function(oldStr, newStr, callback) { return SentenceDiff.diff(oldStr, newStr, callback); },
-
- 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
- );
- },
-
- createTwoFilesPatch: function(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader) {
- var ret = [];
-
- if (oldFileName == newFileName) {
- ret.push('Index: ' + oldFileName);
- }
- ret.push('===================================================================');
- ret.push('--- ' + oldFileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader));
- ret.push('+++ ' + newFileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader));
-
- 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; });
- }
-
- // 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;
-
- // 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 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;
- }
- }
-
- // Output our changes
- curRange.push.apply(curRange, map(lines, function(entry) {
- return (current.added ? '+' : '-') + entry;
- }));
- eofNL(curRange, i, current);
-
- // 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);
- }
-
- oldRangeStart = 0;
- newRangeStart = 0;
- curRange = [];
- }
- }
- oldLine += lines.length;
- newLine += lines.length;
- }
- }
-
- return ret.join('\n') + '\n';
- },
-
- createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
- return JsDiff.createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader);
- },
-
- 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++;
- }
-
- // 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;
- }
- }
- }
-
- // 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));
- }
-
- // Handle EOFNL insertion/removal
- if (remEOFNL) {
- while (!lines[lines.length - 1]) {
- lines.pop();
- }
- } else if (addEOFNL) {
- lines.push('');
- }
- return lines.join('\n');
- },
-
- convertChangesToXML: function(changes) {
- var ret = [];
- for (var i = 0; i < changes.length; i++) {
- var change = changes[i];
- if (change.added) {
- ret.push('<ins>');
- } else if (change.removed) {
- ret.push('<del>');
- }
-
- ret.push(escapeHTML(change.value));
-
- if (change.added) {
- ret.push('</ins>');
- } else if (change.removed) {
- ret.push('</del>');
- }
- }
- return ret.join('');
- },
-
- // 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;
- },
-
- canonicalize: canonicalize
- };
-
- /*istanbul ignore next */
- /*global module */
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = JsDiff;
- } else if (typeof define === 'function' && define.amd) {
- /*global define */
- define([], function() { return JsDiff; });
- } else if (typeof global.JsDiff === 'undefined') {
- global.JsDiff = JsDiff;
- }
-}(this));
diff --git a/node_modules/diff/package.json b/node_modules/diff/package.json
index 2bd81f896..99a4fea46 100644
--- a/node_modules/diff/package.json
+++ b/node_modules/diff/package.json
@@ -1,6 +1,6 @@
{
"name": "diff",
- "version": "1.4.0",
+ "version": "3.2.0",
"description": "A javascript text diff implementation.",
"keywords": [
"diff",
@@ -13,12 +13,7 @@
"email": "kpdecker@gmail.com",
"url": "http://github.com/kpdecker/jsdiff/issues"
},
- "licenses": [
- {
- "type": "BSD",
- "url": "http://github.com/kpdecker/jsdiff/blob/master/LICENSE"
- }
- ],
+ "license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "git://github.com/kpdecker/jsdiff.git"
@@ -26,19 +21,55 @@
"engines": {
"node": ">=0.3.1"
},
- "main": "./diff",
+ "main": "./lib",
"scripts": {
- "test": "istanbul cover node_modules/.bin/_mocha test/*.js && istanbul check-coverage --statements 100 --functions 100 --branches 100 --lines 100 coverage/coverage.json"
+ "test": "grunt"
},
"dependencies": {},
"devDependencies": {
- "colors": "^1.1.0",
- "istanbul": "^0.3.2",
- "mocha": "^2.2.4",
- "should": "^6.0.1"
+ "async": "^1.4.2",
+ "babel-core": "^6.0.0",
+ "babel-loader": "^6.0.0",
+ "babel-preset-es2015-mod": "^6.3.13",
+ "babel-preset-es3": "^1.0.1",
+ "chai": "^3.3.0",
+ "colors": "^1.1.2",
+ "eslint": "^1.6.0",
+ "grunt": "^0.4.5",
+ "grunt-babel": "^6.0.0",
+ "grunt-clean": "^0.4.0",
+ "grunt-cli": "^0.1.13",
+ "grunt-contrib-clean": "^1.0.0",
+ "grunt-contrib-copy": "^1.0.0",
+ "grunt-contrib-uglify": "^1.0.0",
+ "grunt-contrib-watch": "^1.0.0",
+ "grunt-eslint": "^17.3.1",
+ "grunt-karma": "^0.12.1",
+ "grunt-mocha-istanbul": "^3.0.1",
+ "grunt-mocha-test": "^0.12.7",
+ "grunt-webpack": "^1.0.11",
+ "istanbul": "github:kpdecker/istanbul",
+ "karma": "^0.13.11",
+ "karma-mocha": "^0.2.0",
+ "karma-mocha-reporter": "^2.0.0",
+ "karma-phantomjs-launcher": "^1.0.0",
+ "karma-sauce-launcher": "^0.3.0",
+ "karma-sourcemap-loader": "^0.3.6",
+ "karma-webpack": "^1.7.0",
+ "mocha": "^2.3.3",
+ "phantomjs-prebuilt": "^2.1.5",
+ "semver": "^5.0.3",
+ "webpack": "^1.12.2",
+ "webpack-dev-server": "^1.12.0"
},
"optionalDependencies": {},
- "files": [
- "diff.js"
- ]
+ "babel": {
+ "sourceMaps": "inline",
+ "presets": [
+ "es3",
+ "es2015-mod"
+ ],
+ "auxiliaryCommentBefore": "istanbul ignore start",
+ "auxiliaryCommentAfter": "istanbul ignore end"
+ }
}