diff options
author | Luke Karrys <luke@lukekarrys.com> | 2022-08-25 23:18:23 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-08-26 01:02:40 +0300 |
commit | f4205e57d6c4ee5f2ff7d21ffc116ffc420d191e (patch) | |
tree | 8757fa16e4211ab67379b78e1eb2f3aabf5dba7c /node_modules/diff/lib/index.es6.js | |
parent | 8f7abbe4c3ceba451eb422c6328d623e7c8eeed5 (diff) |
deps: diff@5.1.0
Diffstat (limited to 'node_modules/diff/lib/index.es6.js')
-rw-r--r-- | node_modules/diff/lib/index.es6.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/node_modules/diff/lib/index.es6.js b/node_modules/diff/lib/index.es6.js index ca0e5917c..c2a00135a 100644 --- a/node_modules/diff/lib/index.es6.js +++ b/node_modules/diff/lib/index.es6.js @@ -32,6 +32,11 @@ Diff.prototype = { oldLen = oldString.length; var editLength = 1; var maxEditLength = newLen + oldLen; + + if (options.maxEditLength) { + maxEditLength = Math.min(maxEditLength, options.maxEditLength); + } + var bestPath = [{ newPos: -1, components: [] @@ -96,15 +101,13 @@ Diff.prototype = { 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. + // is produced, or until the edit length exceeds options.maxEditLength (if given), + // in which case it will return undefined. if (callback) { (function exec() { setTimeout(function () { - // This should not happen, but we want to be safe. - - /* istanbul ignore next */ if (editLength > maxEditLength) { return callback(); } @@ -922,6 +925,11 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne } var diff = diffLines(oldStr, newStr, options); + + if (!diff) { + return; + } + diff.push({ value: '', lines: [] |