Last active
December 16, 2015 17:50
-
-
Save artursapek/5473761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for own ind, char of as | |
# Iterate over the characters in a-split | |
if matching | |
# So far we have only found matching chars... | |
if bs[ind] == char | |
# If they're still matching then great | |
continue | |
else | |
# Uh-oh! We've found the first mistmatch! | |
matching = false | |
index = parseInt(ind, 10) | |
if not matching | |
# If at this point it is no longer matching | |
# build up the diff | |
# Let's see if we can find somewhere in the future where | |
# they will start to match up again until the end of the blobs | |
resta = as.slice(ind) | |
restb = bs.slice(ind) | |
if resta and restb | |
for i in [0..resta.length] | |
att = @diffHelper(resta, restb, i) | |
if att | |
# We found it! | |
rold = rold.concat(resta.slice(0, i)) | |
return { index: index, old: rold.join(""), new: rnew.join("") } | |
for i in [0..restb.length] | |
att = @diffHelper(restb, resta, i) | |
if att | |
# We found it! | |
rnew = rnew.concat(restb.slice(0, i)) | |
return { index: index, old: rold.join(""), new: rnew.join("") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment