From dbf31798d5bc930c3cd860c24ba20cf19060a6d3 Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Fri, 25 Mar 2016 15:01:17 +0100 Subject: [PATCH] json-ot triggering PARANOIA errors in ChainPad --- www/common/json-ot.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/www/common/json-ot.js b/www/common/json-ot.js index 238ccc18a..37172b95c 100644 --- a/www/common/json-ot.js +++ b/www/common/json-ot.js @@ -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