react-diff-view
Advanced tools
Comparing version 1.4.0-beta.4 to 1.4.0-beta.5
{ | ||
"name": "react-diff-view", | ||
"version": "1.4.0-beta.4", | ||
"version": "1.4.0-beta.5", | ||
"description": "A git diff component to consume the git unified diff output.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -281,2 +281,39 @@ import leven from 'leven'; | ||
export const getCollapsedLinesCountBetween = (previousHunk, nextHunk) => { | ||
if (!previousHunk) { | ||
return nextHunk.oldStart - 1; | ||
} | ||
if (!nextHunk) { | ||
throw new Error('Unable to compute lines count after the last hunk'); | ||
} | ||
const previousEnd = previousHunk.oldStart + previousHunk.oldLines; | ||
const nextStart = nextHunk.oldStart; | ||
return nextStart - previousEnd; | ||
}; | ||
export const expandCollapsedBlockBy = (hunks, rawCodeOrLines, predicate) => { | ||
const expandingBlocks = hunks.reduce( | ||
(expandingBlocks, currentHunk, index, hunks) => { | ||
const nextHunk = hunks[index + 1]; | ||
if (!nextHunk) { | ||
return expandingBlocks; | ||
} | ||
const oldStart = currentHunk.oldStart + currentHunk.oldLines; | ||
const newStart = currentHunk.newStart + currentHunk.newLines; | ||
const lines = getCollapsedLinesCountBetween(currentHunk, nextHunk); | ||
const shouldExpand = predicate(lines, oldStart, newStart); | ||
return shouldExpand ? [...expandingBlocks, [oldStart, oldStart + lines]] : expandingBlocks; | ||
}, | ||
[] | ||
); | ||
return expandingBlocks.reduce((hunks, [start, end]) => expandFromRawCode(hunks, rawCodeOrLines, start, end), hunks); | ||
}; | ||
export const getChangeKey = ({isNormal, isInsert, lineNumber, oldLineNumber}) => { | ||
@@ -283,0 +320,0 @@ if (isNormal) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
591308
1546