1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 18:23:44 +03:00

Construct Patches with Terms directly.

This commit is contained in:
Rob Rix 2015-10-23 18:26:24 -04:00
parent 16876343a4
commit f00b9cca5b

View File

@ -65,25 +65,12 @@
}
function Patch(patch) {
if (patch.delete != null) { this.patch = new Delete(patch.delete); }
if (patch.insert != null) { this.patch = new Insert(patch.insert); }
if (patch.replace != null) { this.patch = new Replace(patch.replace.before, patch.replace.after); }
return this;
}
function Delete(before) {
this.before = new Term(before);
return this;
}
function Insert(after) {
this.after = new Term(after);
return this;
}
function Replace(before, after) {
this.before = new Term(before);
this.after = new Term(after);
if (patch.delete != null) { this.before = new Term(patch.delete); }
if (patch.insert != null) { this.after = new Term(patch.insert); }
if (patch.replace != null) {
this.before = new Term(patch.replace.before);
this.after = new Term(patch.replace.after);
}
return this;
}