Skip to content

Commit 19c8854

Browse files
committed
add diff link.
1 parent f574655 commit 19c8854

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ calcDiffData (oldString, newString)
1212

1313
## Algorithm
1414

15+
http://wiki.c2.com/?DiffAlgorithm
1516

17+
https://github.com/mtjs/mt
1618

19+
https://neil.fraser.name/software/diff_match_patch/myers.pdf
1720

21+
https://code.google.com/p/google-diff-match-patch/
1822

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function calcDiffData (localFileContent, fileContent) {
3434
matchedCount = 1;
3535
}
3636

37-
if (i === (size - 1)) {
37+
if (i === size - 1) {
3838
arrayData += `${matchedCount}]`;
3939
diffDataArray.push(JSON.parse(arrayData));
4040
arrayData = '';
@@ -74,22 +74,22 @@ function roll (content, localMd5Map, chunkSize) {
7474
const matchedNo = findMatchedNo(chunkMd5, localMd5Map, lastMatchNo);
7575

7676
if (endIndex > len - 1) {
77-
if (outBuffer.length > 0 && outBuffer !== '') {
77+
if (outBuffer.length > 0) {
7878
diffDataArray.push({
7979
match: false,
8080
data: outBuffer
8181
});
8282
outBuffer = '';
8383
}
84-
if (buffer.length > 0 && buffer !== '') {
84+
if (buffer.length > 0) {
8585
diffDataArray.push({
8686
match: false,
8787
data: buffer
8888
});
8989
}
9090
currentIndex = currentIndex + chunkSize;
9191
} else if (matchedNo >= 0) {
92-
if (outBuffer.length > 0 && outBuffer !== '') {
92+
if (outBuffer.length > 0) {
9393
diffDataArray.push({
9494
match: false,
9595
data: outBuffer

0 commit comments

Comments
 (0)