Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript: allow easy way to remove diff/match/patch sections #47

Open
GoogleCodeExporter opened this issue Mar 13, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

In browser-side JavaScript, file size matters a lot. It would be nice if there 
was a well-documented easy way to get rid of the code that wasn't needed for 
Match and Patch if all you care about is the Diff features, for instance.

Original issue reported on code.google.com by philfreo on 4 May 2011 at 10:01

@GoogleCodeExporter
Copy link
Author

I can document the process I used a moment ago when I updated my "improved 
github diffs" user script 
(https://github.com/johan/github-improved/blob/master/better-diffs.user.js - or 
direct install link 
https://github.com/johan/github-improved/raw/master/better-diffs.user.js) a 
moment ago, which uses Neil's amazing diff backend without the match and patch 
parts:

 * replace all instances of "diff_match_patch" with "Diff" in javascript/diff_match_patch_uncompressed.js
 * remove all the code from //  MATCH FUNCTIONS to the end of the file
 * wrap the file between a "var Diff = (function(){" and "return new Diff; })()" (without the quotes)
 * prepend a little header comment annotating what revision it's based on, and linking to the source here

That's all. (Step 3 is only necessary if you want to keep identifier leakage to 
just the Diff object, it's really only the three DIFF_DELETE, DIFF_INSERT and 
DIFF_EQUAL constants.)

That said, it would be neat if the three portions were split up into a diff.js, 
a match.js and a patch.js (maybe a main.js too?) with a Makefile that 
recombines them back together into the current form;

Original comment by oyas...@gmail.com on 9 Jun 2011 at 12:55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant