mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(diff) add
This commit is contained in:
parent
d5be099df5
commit
21b3756b6e
7 changed files with 2309 additions and 5 deletions
21
lib/diff.js
Normal file
21
lib/diff.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
(function (obj) {
|
||||
obj.DiffProto = function(diffMatchPatch) {
|
||||
var dmp = new diffMatchPatch();
|
||||
|
||||
this.createPatch = function(oldText, newText) {
|
||||
var diff = dmp.diff_main(oldText, newText),
|
||||
patchList = dmp.patch_make(oldText, newText, diff),
|
||||
patch = dmp.patch_toText(patchList);
|
||||
|
||||
return patch;
|
||||
};
|
||||
|
||||
this.applyPatch = function(oldText, patch) {
|
||||
var patches = dmp.patch_fromText(patch),
|
||||
results = dmp.patch_apply(patches, oldText);
|
||||
|
||||
return results;
|
||||
};
|
||||
};
|
||||
})(this);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue