Attempt an operational transformation and if the result is not valid JSON then fail

This commit is contained in:
Caleb James DeLisle
2016-02-11 12:34:06 +01:00
parent e16299b5c4
commit 37db31b09e
2 changed files with 6 additions and 0 deletions

View File

@@ -114,6 +114,11 @@ define([
transformBy: transformBy
});
var resultOp = ChainPad.Operation.transform0(text, toTransform, transformBy);
var text2 = ChainPad.Operation.apply(transformBy, text);
var text3 = ChainPad.Operation.apply(resultOp, text2);
try { JSON.parse(text3); return resultOp; } catch (e) { console.log(e); }
// returning **null** breaks out of the loop
// which transforms conflicting operations
// in theory this should prevent us from producing bad JSON