json-ot triggering PARANOIA errors in ChainPad

This commit is contained in:
Caleb James DeLisle
2016-03-25 15:01:17 +01:00
parent 03932d0169
commit dbf31798d5

View File

@@ -5,19 +5,23 @@ define([
var JsonOT = {};
var validate = JsonOT.validate = function (text, toTransform, 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.error(e);
console.log({
resultOp: resultOp,
text2: text2,
text3: text3
});
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.error(e);
console.log({
resultOp: resultOp,
text2: text2,
text3: text3
});
}
} catch (x) {
console.error(x);
}
// returning **null** breaks out of the loop