diff options
author | npm CLI robot <npm-cli+bot@github.com> | 2022-09-02 05:48:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-02 12:48:00 +0000 |
commit | e0d2bfd4840934154772f6fc769b5e39a5d226be (patch) | |
tree | 011d626f748255a6715ea3a69407fcb79749c873 /deps/npm/node_modules/diff/lib/index.mjs | |
parent | f7896d4671cbce6deaa7bb9a520b37c87e46aebe (diff) | |
download | node-new-e0d2bfd4840934154772f6fc769b5e39a5d226be.tar.gz |
deps: upgrade npm to 8.19.1
PR-URL: https://github.com/nodejs/node/pull/44486
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/diff/lib/index.mjs')
-rw-r--r-- | deps/npm/node_modules/diff/lib/index.mjs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/deps/npm/node_modules/diff/lib/index.mjs b/deps/npm/node_modules/diff/lib/index.mjs index ca0e5917c4..c2a00135a4 100644 --- a/deps/npm/node_modules/diff/lib/index.mjs +++ b/deps/npm/node_modules/diff/lib/index.mjs @@ -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: [] |