Skip to content

Instantly share code, notes, and snippets.

@artursapek
Last active December 16, 2015 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artursapek/5473761 to your computer and use it in GitHub Desktop.
Save artursapek/5473761 to your computer and use it in GitHub Desktop.
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