1
1
mirror of https://github.com/github/semantic.git synced 2024-11-25 11:04:00 +03:00

Add a function to construct diffs from JSON.

This commit is contained in:
Rob Rix 2015-10-23 18:54:24 -04:00
parent 692ae3be29
commit 20057acaff

View File

@ -155,6 +155,13 @@
if (this.leaf != null) { return new Syntax(this, transform); }
}
function diffFromJSON(json) {
if (json.pure != null) { return new Diff({ pure: new Patch(json.pure) }); }
if (json.roll != null) {
return new Diff({ ranges: json.roll.extract, roll: new Syntax(json.roll.unwrap, function(x) { return diffFromJSON(x); }) });
}
}
function Diff(json) {
if (json.pure != null) {
this.pure = new Patch(json.pure);