From 41e1abc84e597d162ad24ffbc13f431dd11f6970 Mon Sep 17 00:00:00 2001 From: nlac Date: Wed, 31 Jan 2018 20:26:08 +0100 Subject: [PATCH] - added .gitignore not to track any temp/generated files (included package-lock.json) - removed packaging itself as an external node module - fixed async warning dropping by fs - fixed issue #3 (diff calculated wrong) - modified expected test results where the calculated patch is equivalent (now only 1 fails) - added comments to almost every change - the code formatting is a mess, but i've left it as it is to compare more easy - proper tabulating required --- .gitignore | 5 ++ JSON-Diff.js | 29 ++++++++---- dataset/Stackoverflow/Stackoverflow.csv | 61 ------------------------- dataset/Twitter/Twitter.csv | 15 ------ dataset/Xignite/Xignite.csv | 61 ------------------------- dataset/generate_patch.js | 9 ++-- dataset/package.json | 1 - lib/hashObject.js | 4 +- lib/patchArea.js | 8 +++- lib/unchangedArea.js | 41 +++++++---------- package-lock.json | 13 ------ package.json | 9 +++- tests/1/fjp_new.json | 5 -- tests/1/fjp_patch.json | 7 --- tests/1/jdr_new.json | 5 -- tests/1/jdr_patch.json | 7 --- tests/1/jiff_patch.json | 7 --- tests/10/fjp_new.json | 10 ---- tests/10/fjp_patch.json | 6 --- tests/10/jdr_new.json | 10 ---- tests/10/jdr_patch.json | 6 --- tests/10/jiff_patch.json | 6 --- tests/11/fjp_new.json | 10 ---- tests/11/fjp_patch.json | 16 ------- tests/11/jdr_new.json | 10 ---- tests/11/jdr_patch.json | 6 --- tests/11/jiff_patch.json | 6 --- tests/12/expected.json | 14 +++--- tests/12/fjp_new.json | 14 ------ tests/12/fjp_patch.json | 12 ----- tests/12/jdr_new.json | 14 ------ tests/12/jdr_patch.json | 12 ----- tests/12/jiff_patch.json | 14 ------ tests/13/expected.json | 14 +++--- tests/13/fjp_new.json | 14 ------ tests/13/fjp_patch.json | 12 ----- tests/13/jdr_new.json | 14 ------ tests/13/jdr_patch.json | 12 ----- tests/13/jiff_patch.json | 14 ------ tests/14/expected.json | 14 +++--- tests/14/fjp_new.json | 14 ------ tests/14/fjp_patch.json | 12 ----- tests/14/jdr_new.json | 14 ------ tests/14/jdr_patch.json | 12 ----- tests/14/jiff_patch.json | 14 ------ tests/15/fjp_new.json | 18 -------- tests/15/fjp_patch.json | 10 ---- tests/15/jdr_new.json | 18 -------- tests/15/jdr_patch.json | 7 --- tests/15/jiff_patch.json | 10 ---- tests/16/fjp_new.json | 14 ------ tests/16/fjp_patch.json | 22 --------- tests/16/jdr_new.json | 14 ------ tests/16/jdr_patch.json | 7 --- tests/16/jiff_patch.json | 14 ------ tests/17/fjp_new.json | 14 ------ tests/17/fjp_patch.json | 32 ------------- tests/17/jdr_new.json | 14 ------ tests/17/jdr_patch.json | 12 ----- tests/17/jiff_patch.json | 14 ------ tests/18/fjp_new.json | 14 ------ tests/18/fjp_patch.json | 22 --------- tests/18/jdr_new.json | 14 ------ tests/18/jdr_patch.json | 7 --- tests/18/jiff_patch.json | 14 ------ tests/19/expected.json | 8 ++-- tests/19/fjp_new.json | 14 ------ tests/19/fjp_patch.json | 22 --------- tests/19/jdr_new.json | 14 ------ tests/19/jdr_patch.json | 12 ----- tests/19/jiff_patch.json | 26 ----------- tests/2/fjp_new.json | 3 -- tests/2/fjp_patch.json | 6 --- tests/2/jdr_new.json | 3 -- tests/2/jdr_patch.json | 6 --- tests/2/jiff_patch.json | 6 --- tests/20/fjp_new.json | 14 ------ tests/20/fjp_patch.json | 32 ------------- tests/20/jdr_new.json | 14 ------ tests/20/jdr_patch.json | 7 --- tests/20/jiff_patch.json | 14 ------ tests/21/expected.json | 8 ++-- tests/21/fjp_new.json | 17 ------- tests/21/fjp_patch.json | 17 ------- tests/21/jdr_new.json | 17 ------- tests/21/jdr_patch.json | 17 ------- tests/21/jiff_patch.json | 41 ----------------- tests/3/fjp_new.json | 5 -- tests/3/fjp_patch.json | 7 --- tests/3/jdr_new.json | 5 -- tests/3/jdr_patch.json | 7 --- tests/3/jiff_patch.json | 7 --- tests/4/fjp_new.json | 20 -------- tests/4/fjp_patch.json | 14 ------ tests/4/jdr_new.json | 20 -------- tests/4/jdr_patch.json | 7 --- tests/4/jiff_patch.json | 14 ------ tests/5/fjp_new.json | 5 -- tests/5/fjp_patch.json | 11 ----- tests/5/jdr_new.json | 5 -- tests/5/jdr_patch.json | 7 --- tests/5/jiff_patch.json | 11 ----- tests/6/fjp_new.json | 18 -------- tests/6/fjp_patch.json | 40 ---------------- tests/6/jdr_new.json | 18 -------- tests/6/jdr_patch.json | 10 ---- tests/6/jiff_patch.json | 10 ---- tests/7/fjp_new.json | 18 -------- tests/7/fjp_patch.json | 10 ---- tests/7/jdr_new.json | 18 -------- tests/7/jdr_patch.json | 10 ---- tests/7/jiff_patch.json | 10 ---- tests/8/fjp_new.json | 18 -------- tests/8/fjp_patch.json | 30 ------------ tests/8/jdr_new.json | 18 -------- tests/8/jdr_patch.json | 10 ---- tests/8/jiff_patch.json | 10 ---- tests/9/fjp_new.json | 10 ---- tests/9/fjp_patch.json | 26 ----------- tests/9/jdr_new.json | 10 ---- tests/9/jdr_patch.json | 6 --- tests/9/jiff_patch.json | 6 --- tests/diff.js | 15 +++--- 123 files changed, 104 insertions(+), 1584 deletions(-) create mode 100644 .gitignore delete mode 100644 dataset/Stackoverflow/Stackoverflow.csv delete mode 100644 dataset/Twitter/Twitter.csv delete mode 100644 dataset/Xignite/Xignite.csv delete mode 100644 package-lock.json delete mode 100644 tests/1/fjp_new.json delete mode 100644 tests/1/fjp_patch.json delete mode 100644 tests/1/jdr_new.json delete mode 100644 tests/1/jdr_patch.json delete mode 100644 tests/1/jiff_patch.json delete mode 100644 tests/10/fjp_new.json delete mode 100644 tests/10/fjp_patch.json delete mode 100644 tests/10/jdr_new.json delete mode 100644 tests/10/jdr_patch.json delete mode 100644 tests/10/jiff_patch.json delete mode 100644 tests/11/fjp_new.json delete mode 100644 tests/11/fjp_patch.json delete mode 100644 tests/11/jdr_new.json delete mode 100644 tests/11/jdr_patch.json delete mode 100644 tests/11/jiff_patch.json delete mode 100644 tests/12/fjp_new.json delete mode 100644 tests/12/fjp_patch.json delete mode 100644 tests/12/jdr_new.json delete mode 100644 tests/12/jdr_patch.json delete mode 100644 tests/12/jiff_patch.json delete mode 100644 tests/13/fjp_new.json delete mode 100644 tests/13/fjp_patch.json delete mode 100644 tests/13/jdr_new.json delete mode 100644 tests/13/jdr_patch.json delete mode 100644 tests/13/jiff_patch.json delete mode 100644 tests/14/fjp_new.json delete mode 100644 tests/14/fjp_patch.json delete mode 100644 tests/14/jdr_new.json delete mode 100644 tests/14/jdr_patch.json delete mode 100644 tests/14/jiff_patch.json delete mode 100644 tests/15/fjp_new.json delete mode 100644 tests/15/fjp_patch.json delete mode 100644 tests/15/jdr_new.json delete mode 100644 tests/15/jdr_patch.json delete mode 100644 tests/15/jiff_patch.json delete mode 100644 tests/16/fjp_new.json delete mode 100644 tests/16/fjp_patch.json delete mode 100644 tests/16/jdr_new.json delete mode 100644 tests/16/jdr_patch.json delete mode 100644 tests/16/jiff_patch.json delete mode 100644 tests/17/fjp_new.json delete mode 100644 tests/17/fjp_patch.json delete mode 100644 tests/17/jdr_new.json delete mode 100644 tests/17/jdr_patch.json delete mode 100644 tests/17/jiff_patch.json delete mode 100644 tests/18/fjp_new.json delete mode 100644 tests/18/fjp_patch.json delete mode 100644 tests/18/jdr_new.json delete mode 100644 tests/18/jdr_patch.json delete mode 100644 tests/18/jiff_patch.json delete mode 100644 tests/19/fjp_new.json delete mode 100644 tests/19/fjp_patch.json delete mode 100644 tests/19/jdr_new.json delete mode 100644 tests/19/jdr_patch.json delete mode 100644 tests/19/jiff_patch.json delete mode 100644 tests/2/fjp_new.json delete mode 100644 tests/2/fjp_patch.json delete mode 100644 tests/2/jdr_new.json delete mode 100644 tests/2/jdr_patch.json delete mode 100644 tests/2/jiff_patch.json delete mode 100644 tests/20/fjp_new.json delete mode 100644 tests/20/fjp_patch.json delete mode 100644 tests/20/jdr_new.json delete mode 100644 tests/20/jdr_patch.json delete mode 100644 tests/20/jiff_patch.json delete mode 100644 tests/21/fjp_new.json delete mode 100644 tests/21/fjp_patch.json delete mode 100644 tests/21/jdr_new.json delete mode 100644 tests/21/jdr_patch.json delete mode 100644 tests/21/jiff_patch.json delete mode 100644 tests/3/fjp_new.json delete mode 100644 tests/3/fjp_patch.json delete mode 100644 tests/3/jdr_new.json delete mode 100644 tests/3/jdr_patch.json delete mode 100644 tests/3/jiff_patch.json delete mode 100644 tests/4/fjp_new.json delete mode 100644 tests/4/fjp_patch.json delete mode 100644 tests/4/jdr_new.json delete mode 100644 tests/4/jdr_patch.json delete mode 100644 tests/4/jiff_patch.json delete mode 100644 tests/5/fjp_new.json delete mode 100644 tests/5/fjp_patch.json delete mode 100644 tests/5/jdr_new.json delete mode 100644 tests/5/jdr_patch.json delete mode 100644 tests/5/jiff_patch.json delete mode 100644 tests/6/fjp_new.json delete mode 100644 tests/6/fjp_patch.json delete mode 100644 tests/6/jdr_new.json delete mode 100644 tests/6/jdr_patch.json delete mode 100644 tests/6/jiff_patch.json delete mode 100644 tests/7/fjp_new.json delete mode 100644 tests/7/fjp_patch.json delete mode 100644 tests/7/jdr_new.json delete mode 100644 tests/7/jdr_patch.json delete mode 100644 tests/7/jiff_patch.json delete mode 100644 tests/8/fjp_new.json delete mode 100644 tests/8/fjp_patch.json delete mode 100644 tests/8/jdr_new.json delete mode 100644 tests/8/jdr_patch.json delete mode 100644 tests/8/jiff_patch.json delete mode 100644 tests/9/fjp_new.json delete mode 100644 tests/9/fjp_patch.json delete mode 100644 tests/9/jdr_new.json delete mode 100644 tests/9/jdr_patch.json delete mode 100644 tests/9/jiff_patch.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f2fd80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*_new.json +*_patch.json +*.csv +node_modules/ +package-lock.json diff --git a/JSON-Diff.js b/JSON-Diff.js index 51c321f..27bf5a3 100644 --- a/JSON-Diff.js +++ b/JSON-Diff.js @@ -83,13 +83,13 @@ function generateArrayDiff(oldJson, newJson, unchanged, patches, path) { // Use LCS var tmpPatches = []; - var tmpPatchHashes = []; if (oldJson.length === 0) { patches.push({ op: "add", path: path, value: newJson}); } else { // Use sortBack - tmpPatches = transformArray(oldJson, newJson, unchanged, tmpPatches, tmpPatchHashes, path); + // deleted unused parameters from the call + tmpPatches = transformArray(oldJson, newJson, unchanged, path); for (var l = 0; l < tmpPatches.length; l++) { patches.push(tmpPatches[l]); } @@ -146,7 +146,9 @@ function generateObjectDiff(oldJson, newJson, unchanged, patches, path) { if (!oldJson.hasOwnProperty(newKey)) { //Try to find the value in the unchanged area // change JSON.stringify() - var pointer = unchangedArea.findValueInUnchanged(JSON.stringify(newVal), unchanged); + + // pass the value here, apply JSON.stringify in the method + var pointer = unchangedArea.findValueInUnchanged(newVal, unchanged); if (pointer) { //COPY patches.push({ op: "copy", path: path + "/" + patchPointString(newKey), from: pointer}); @@ -294,7 +296,8 @@ function findCopyInArray(element, m, array, arrUnchanged) { return copyIndex; } -function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, jsondiff) { +// deleted unused parameters +function transformArray(oldJson, newJson, unchanged, path) { //When is the Array, stop to find leaf node // (hash, value, index) var x = hashObject.mapArray(hashObject.hash, oldJson, HASH_ID); @@ -315,6 +318,7 @@ function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, while (i < x_sorted.length) { while( j < y_sorted.length) { + if(x_sorted[i] !== void 0) { if (x_sorted[i].hash > y_sorted[j].hash) { @@ -323,7 +327,11 @@ function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, } else if (x_sorted[i].hash === y_sorted[j].hash) { // Unchanged push - unchanged.push( path + '/' + y_sorted[j].index + "=" + JSON.stringify(x_sorted[i].hash)); + //no point to insert if already there + var el = path + '/' + y_sorted[j].index + "=" + JSON.stringify(x_sorted[i].value); + if (unchanged.indexOf(el)<0) + unchanged.push(el); + arrPatch.push({op: "move", value: y_sorted[j].value, valueOld: x_sorted[i].value, from: x_sorted[i].index , index: y_sorted[j].index, hash: y_sorted[j].hash }); i++; j++; @@ -338,14 +346,15 @@ function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, j++; } - } + } //j if (i < x_sorted.length) { // Remove the rest elements of the x_sorted - arrPatch.push({op: "remove", index: x_sorted[i].index, value: x_sorted[i].value }); + // for being consistent, added hash as well like for other operators + arrPatch.push({op: "remove", index: x_sorted[i].index, value: x_sorted[i].value, hash: x_sorted[i].hash }); i++; } - } + } //i //Get the patch to make all the elements are the same, but index is random arrPatch = arrPatch.sort(compare); @@ -462,6 +471,8 @@ function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, } +/* + // no reason to do anything with arrPatch local variable at this point arrPatch = arrPatch.map(function(obj) { obj.path = path + '/' + obj.index; delete obj.hash; @@ -473,7 +484,7 @@ function transformArray(oldJson, newJson, unchanged, patches, patchHashes, path, return obj; }); +*/ return arrtmp; - } diff --git a/dataset/Stackoverflow/Stackoverflow.csv b/dataset/Stackoverflow/Stackoverflow.csv deleted file mode 100644 index 0beaf63..0000000 --- a/dataset/Stackoverflow/Stackoverflow.csv +++ /dev/null @@ -1,61 +0,0 @@ -A0_DT,A0_PS,A1_DT,A1_PS,A2_DT,A2_PS,A3_DT,A3_PS,A4_DT,A4_PS,A5_DT,A5_PS -0,11820,0.1691,23964,0.3632,2377,0.2151,1981,3.8049,1981,0.0192,11854 -0,11916,0.133,24013,0.2937,3390,0.1671,3034,3.0239,3034,0.0051,11950 -0,11930,0.14400000000000002,23869,0.28309999999999996,3862,0.1427,3506,3.6732,3506,0.0060999999999999995,11964 -0,11914,0.10880000000000001,23725,0.304,2874,0.1392,2522,3.4916,2522,0.0129,11948 -0,11970,0.1161,24025,0.2905,2370,0.1277,2370,2.6882,2370,0.004699999999999999,12004 -0,11935,0.11699999999999999,24026,0.32189999999999996,1915,0.1361,1915,2.5368,1915,0.0038,11969 -0,12117,0.1148,24177,0.3225,1611,0.1325,1611,2.325,1611,0.0037,12151 -0,12133,0.11560000000000001,24518,0.3025,2452,0.1252,2452,2.5827999999999998,2452,0.0034999999999999996,12167 -0,12133,0.0958,56,0.3063,56,0.3135,56,0.1075,56,0.12369999999999999,56 -0,12077,0.122,24283,0.3665,1921,0.168,1921,2.539,1921,0.0045000000000000005,12111 -0,12067,0.11410000000000001,24326,0.3132,1942,0.131,1942,2.4623,1942,0.0064,12101 -0,12046,0.115,24284,0.2827,3340,0.1231,3340,2.9957,3340,0.0045000000000000005,12080 -0,12145,0.1288,24256,0.29710000000000003,2418,0.12869999999999998,2418,2.8105,2418,0.0040999999999999995,12179 -0,11968,0.1617,23925,0.3225,3853,0.1437,3853,3.2031,3853,0.0032,12002 -0,12023,0.1268,24141,0.3342,1490,0.1441,1490,2.4324,1490,0.0044,12057 -0,11998,0.1118,24366,0.28350000000000003,2864,0.12050000000000001,2864,2.717,2864,0.006999999999999999,12032 -0,12096,0.135,24665,0.3116,2011,0.2006,1568,2.5474,2011,0.0033,12130 -0,12117,0.1084,21716,0.324,530,0.1485,530,1.7593,530,0.0029,12151 -0,12092,0.13019999999999998,24300,0.32030000000000003,1427,0.1379,1115,3.1094999999999997,1115,0.0044,12126 -0,12149,0.1118,24399,0.3166,1058,0.134,1058,2.228,1058,0.0194,12183 -0,12098,0.1259,24364,0.3265,982,0.1376,604,2.0977,604,0.0045000000000000005,12132 -0,12172,0.11289999999999999,24892,0.30820000000000003,2931,0.1247,2931,2.6323000000000003,2931,0.0069,12206 -0,12053,0.1142,24992,0.2872,2342,0.1245,2342,2.4951,2342,0.004699999999999999,12087 -0,12010,0.12179999999999999,24886,0.30670000000000003,979,0.13019999999999998,979,2.106,979,0.006,12044 -0,12176,0.1233,24820,0.2944,3006,0.12560000000000002,2629,2.8945,2629,0.0029,12210 -0,12054,0.126,24630,0.2969,1397,0.1286,1397,2.2803999999999998,1397,0.003,12088 -0,12050,0.156,24544,0.2865,2503,0.13,2126,3.3092,2126,0.0046,12084 -0,12128,0.12689999999999999,24645,0.33509999999999995,2509,0.1313,2509,2.5842,2509,0.0044,12162 -0,12187,0.1783,24757,0.302,2001,0.1319,1651,3.3672000000000004,1651,0.0045000000000000005,12221 -0,12196,0.12300000000000001,24501,0.3084,1523,0.12789999999999999,1523,2.2499000000000002,1523,0.0044,12230 -0,12317,0.114,24344,0.2809,3450,0.12380000000000001,3071,2.7522,3071,0.0046,12351 -0,12321,0.1124,23976,0.2896,3853,0.1243,3537,2.9254000000000002,3537,0.0027,12355 -0,12466,0.1288,24588,0.2796,3451,0.1282,3135,3.0612,3135,0.0044,12500 -0,12418,0.1317,24612,0.2812,2893,0.1233,2893,2.6387,2893,0.0045000000000000005,12452 -0,12442,0.12269999999999999,25005,0.30670000000000003,1530,0.12890000000000001,1530,2.2156000000000002,1530,0.0028000000000000004,12476 -0,12302,0.12119999999999999,24969,0.32909999999999995,1395,0.1349,1395,2.2591,1395,0.0028000000000000004,12336 -0,11993,0.11359999999999999,24387,0.2853,3691,0.1152,3691,2.8857999999999997,3691,0.0044,12027 -0,11954,0.1253,24246,0.3123,2441,0.1259,2441,2.5106,2441,0.0029,11988 -0,11990,0.12300000000000001,24468,0.3232,2054,0.1282,2054,2.3741,2054,0.0045000000000000005,12024 -0,11960,0.11699999999999999,24691,0.2959,1941,0.12369999999999999,1941,2.4198,1941,0.0048,11994 -0,12028,0.1334,24691,0.2768,3423,0.1183,3423,2.7794,3423,0.0044,12062 -0,12085,0.1336,24676,0.2933,4263,0.12710000000000002,3563,3.0801999999999996,3563,0.0044,12119 -0,12204,0.1266,24883,0.2805,2959,0.1258,2959,2.7406,2959,0.0045000000000000005,12238 -0,12167,0.1166,24626,0.2868,2480,0.122,2480,2.6201999999999996,2480,0.003,12201 -0,12133,0.1253,24417,0.278,2890,0.1195,2890,2.7560000000000002,2890,0.0027,12167 -0,12113,0.126,24415,0.2818,2893,0.12050000000000001,2893,2.7704000000000004,2893,0.0045000000000000005,12147 -0,12195,0.12890000000000001,24381,0.273,3408,0.1173,3408,2.8643,3408,0.0029,12229 -0,12147,0.1144,24494,0.2975,1938,0.1245,1938,2.452,1938,0.0028000000000000004,12181 -0,12096,0.11230000000000001,24312,0.3095,1440,0.1378,1096,3.2571,1096,0.0045000000000000005,12130 -0,12096,0.0697,56,0.29350000000000004,56,0.2957,56,0.1056,56,0.121,56 -0,12116,0.1283,24722,0.2984,1986,0.1308,1986,2.4045,1986,0.0045000000000000005,12150 -0,12088,0.1276,24134,0.2928,2400,0.1241,2400,2.5269999999999997,2400,0.004699999999999999,12122 -0,12114,0.11460000000000001,24304,0.3002,1538,0.127,1538,2.2783,1538,0.0043,12148 -0,12094,0.1204,24102,0.3077,1913,0.1259,1913,2.426,1913,0.0044,12128 -0,12154,0.1168,24508,0.2772,3948,0.1162,3948,2.9217,3948,0.0045000000000000005,12188 -0,12141,0.1159,24423,0.30579999999999996,966,0.19,1268,2.117,1268,0.0043,12175 -0,11982,0.127,24354,0.28059999999999996,3178,0.1452,2847,2.8256,2847,0.0028000000000000004,12016 -0,12106,0.1166,24775,0.2751,3936,0.11320000000000001,3936,2.9485,3936,0.0029,12140 -0,12070,0.11630000000000001,24812,0.30519999999999997,1502,0.12710000000000002,1502,2.2891,1502,0.0044,12104 -0,12085,0.1186,24859,0.289,3455,0.15039999999999998,3455,3.5433,3455,0.0049,12119 diff --git a/dataset/Twitter/Twitter.csv b/dataset/Twitter/Twitter.csv deleted file mode 100644 index 53f8cbd..0000000 --- a/dataset/Twitter/Twitter.csv +++ /dev/null @@ -1,15 +0,0 @@ -A0_DT,A0_PS,A1_DT,A1_PS,A2_DT,A2_PS,A3_DT,A3_PS,A4_DT,A4_PS,A5_DT,A5_PS -0,87098,0.8015000000000001,982,1.8673,55337,1.7973,982,5.4517999999999995,982,0.0622,87135 -0,87098,0.7707999999999999,593,2.4757,25936,1.4011000000000002,593,3.9794,593,0.12240000000000001,87135 -0,88085,1.1415,129737,1.2038,74983,2.0138,5305,6.8877,16066,0.0015,88122 -0,88085,0.7676999999999999,969,1.9102000000000001,49584,1.7929,969,5.2975,969,0.0819,88122 -0,88085,0.8087000000000001,1037,1.8837000000000002,54653,1.99,1037,5.5784,1037,0.0336,88122 -0,88087,0.7766,937,2.026,48538,1.7582,937,4.4162,937,0.0325,88124 -0,88087,0.7515000000000001,827,1.9188,48749,1.7628,827,4.0206,827,0.0404,88124 -0,88087,0.7483,475,2.5373,27154,1.3987,475,3.0975,475,0.0397,88124 -0,88087,0.7403,1237,1.485,65735,2.0313999999999997,1237,5.511,1237,0.0319,88124 -0,88087,0.7315,799,2.1524,38607,1.5697,799,3.9901999999999997,799,0.0334,88124 -0,89718,1.1347,131097,1.7730000000000001,56433,1.8263999999999998,6583,5.1835,10936,0.0028000000000000004,89755 -0,89718,0.8458,1012,1.7971000000000001,54660,1.9176,1012,4.8387,1012,0.0828,89755 -0,88711,1.1715,127014,1.5902,61689,1.8385,7557,4.8453,7557,0.0015,88748 -0,91156,1.1326,131721,1.8719,53073,1.7115,6347,5.385800000000001,25179,0.0016,91193 diff --git a/dataset/Xignite/Xignite.csv b/dataset/Xignite/Xignite.csv deleted file mode 100644 index 6d2d2f4..0000000 --- a/dataset/Xignite/Xignite.csv +++ /dev/null @@ -1,61 +0,0 @@ -A0_DT,A0_PS,A1_DT,A1_PS,A2_DT,A2_PS,A3_DT,A3_PS,A4_DT,A4_PS,A5_DT,A5_PS -0,15507,0.1444,7142,0.5017,9415,0.6192,7142,10.4406,7142,0.0109,15544 -0,15439,0.1137,8279,0.4106,10573,0.5595,8279,9.9296,8279,0.0019,15476 -0,15425,0.1188,7583,0.3921,10151,0.527,7583,9.8664,7583,0.002,15462 -0,15506,0.0977,6281,0.4033,8992,0.5105,6281,9.9283,6281,0.0019,15543 -0,15434,0.10289999999999999,6972,0.3918,10160,0.5124,6972,9.874500000000001,6972,0.002,15471 -0,15250,0.1124,6937,0.4029,8739,0.5046,6937,9.8877,6937,0.0072,15287 -0,15426,0.1833,8229,0.4536,17287,0.5858,8229,10.881300000000001,8229,0.0017000000000000001,15463 -0,15508,0.1108,5710,0.4217,8181,0.5129,5710,10.0053,5710,0.0017000000000000001,15545 -0,15518,0.09880000000000001,6447,0.4121,9016,0.5102,6447,9.906699999999999,6447,0.0023,15555 -0,15520,0.0933,5567,0.4035,9031,0.5085999999999999,5567,9.9673,5567,0.0017000000000000001,15557 -0,15516,0.10039999999999999,6757,0.4056,9833,0.5069,6757,9.9619,6757,0.003,15553 -0,15508,0.0951,6443,0.39880000000000004,9427,0.5253,6443,10.2456,6443,0.0019,15545 -0,15511,0.1082,6358,0.4039,9408,0.5246999999999999,6358,10.237400000000001,6358,0.0016,15548 -0,15515,0.0943,6051,0.4039,9004,0.5052,6051,9.9088,6051,0.0016,15552 -0,15506,0.0955,6970,0.2723,17367,0.4954,6970,11.2974,6970,0.0015,15543 -0,15518,0.0987,6092,0.4254,8598,0.5036,6092,9.8208,6092,0.0018,15555 -0,15512,0.0933,5886,0.40259999999999996,9000,0.524,5886,9.8616,5886,0.0025,15549 -0,15348,0.0926,5520,0.3951,9257,0.5013000000000001,5520,9.8614,5520,0.0016,15385 -0,15433,0.0959,6563,0.41259999999999997,8513,0.5063,6563,9.926499999999999,6563,0.0016,15470 -0,15420,0.09449999999999999,5584,0.43520000000000003,8500,0.5052,5584,9.8311,5584,0.0016,15457 -0,15507,0.0962,7094,0.3969,9812,0.5259,7094,9.8719,7094,0.0015,15544 -0,15514,0.1638,8625,0.2755,17375,0.5042,8625,10.7007,8625,0.0015,15551 -0,15507,0.0943,6138,0.3995,8997,0.5047,6138,9.8149,6138,0.0016,15544 -0,15511,0.1121,5610,0.4226,8606,0.5072,5610,9.7726,5610,0.0016,15548 -0,15430,0.0946,6349,0.39880000000000004,8935,0.5009,6349,10.0137,6349,0.0016,15467 -0,15501,0.10189999999999999,8043,0.40369999999999995,9833,0.5278,8043,10.0299,8043,0.0016,15538 -0,15434,0.0953,6590,0.39549999999999996,9345,0.5047,6590,9.8804,6590,0.0016,15471 -0,15426,0.09539999999999998,6548,0.4242,8929,0.5125,6548,9.8701,6548,0.0016,15463 -0,15513,0.0959,6863,0.40240000000000004,9016,0.5059,6863,9.8171,6863,0.0016,15550 -0,15430,0.1066,8428,0.2709,17291,0.4928,8428,10.6281,8428,0.0016,15467 -0,15434,0.0953,6475,0.4078,8532,0.5333,6475,9.8065,6475,0.0016,15471 -0,15515,0.1001,6413,0.4235,9019,0.5214,6413,9.7672,6413,0.0016,15552 -0,15427,0.0998,6783,0.401,9759,0.5191,6783,10.0284,6783,0.0017000000000000001,15464 -0,15431,0.0944,5667,0.4264,8511,0.5101,5667,10.2745,5667,0.0017000000000000001,15468 -0,15505,0.0949,5367,0.4036,9416,0.5112,5367,9.8664,5367,0.0018,15542 -0,15500,0.09570000000000001,5763,0.408,8587,0.5069,5763,9.712200000000001,5763,0.0017000000000000001,15537 -0,15499,0.09820000000000001,8038,0.2697,17360,0.4976,8038,10.610899999999999,8038,0.0017000000000000001,15536 -0,15503,0.0941,5894,0.41,8598,0.5092,5894,9.7647,5894,0.0017000000000000001,15540 -0,15510,0.0966,6062,0.39299999999999996,9842,0.5053,6062,9.8762,6062,0.0017000000000000001,15547 -0,15502,0.095,6501,0.40340000000000004,8990,0.501,6501,9.8406,6501,0.0017000000000000001,15539 -0,15424,0.09820000000000001,8008,0.3812,10148,0.5086999999999999,8008,9.8253,8008,0.0017000000000000001,15461 -0,15433,0.1375,8089,0.39039999999999997,10159,0.5142,8089,9.8454,8089,0.0017000000000000001,15470 -0,15510,0.09960000000000001,7092,0.4172,9004,0.5172,7092,9.79,7092,0.0017000000000000001,15547 -0,15507,0.0983,7293,0.39149999999999996,9820,0.5025999999999999,7293,9.7985,7293,0.0017000000000000001,15544 -0,15442,0.0993,7946,0.2664,17303,0.5033,7946,10.6748,7946,0.0017000000000000001,15479 -0,15439,0.10060000000000001,4825,0.4204,6825,0.5015999999999999,4825,7.9125,4825,0.0017000000000000001,15476 -0,15507,0.09849999999999999,7172,0.4094,9413,0.5134000000000001,7172,9.9554,7172,0.0077,15544 -0,15418,0.0984,7163,0.3958,9324,0.502,7163,9.7766,7163,0.0014000000000000002,15455 -0,15418,0.10460000000000001,6451,0.3986,8904,0.5058,6451,9.8397,6451,0.0014000000000000002,15455 -0,15508,0.09269999999999999,5488,0.4077,8596,0.5009,5488,9.772,5488,0.0014000000000000002,15545 -0,15513,0.0971,6145,0.4012,9001,0.5042,6145,9.8469,6145,0.0014000000000000002,15550 -0,15503,0.09519999999999999,6718,0.4,9001,0.5007,6718,9.7971,6718,0.0014000000000000002,15540 -0,15429,0.09820000000000001,8346,0.268,17290,0.4949,8346,10.656500000000001,8346,0.0014000000000000002,15466 -0,15515,0.0986,8324,0.3801,10662,0.5042,8324,10.085,8324,0.0014000000000000002,15552 -0,15510,0.0978,4788,0.45380000000000004,6501,0.5197999999999999,4788,9.6191,4788,0.0014000000000000002,15547 -0,15511,0.1018,7567,0.405,9826,0.5193,7567,9.895800000000001,7567,0.0013,15548 -0,15513,0.096,6143,0.4114,8998,0.5191,6143,9.845,6143,0.0014000000000000002,15550 -0,15432,0.09380000000000001,5052,0.4153,8929,0.5183,5052,9.799900000000001,5052,0.0012,15469 -0,15506,0.09380000000000001,5352,0.43200000000000005,6870,0.5067,5352,7.8373,5352,0.0012,15543 -0,15518,0.1124,8430,0.2645,17379,0.4953,8430,10.589400000000001,8430,0.0014000000000000002,15555 diff --git a/dataset/generate_patch.js b/dataset/generate_patch.js index 19e022c..f2944ab 100644 --- a/dataset/generate_patch.js +++ b/dataset/generate_patch.js @@ -1,7 +1,7 @@ var jsonpatch = require('fast-json-patch'), jiff = require('jiff'), rfc6902 = require('rfc6902'), -jdr = require('json-diff-rfc6902'), +jdr = require('../json-diff-rfc6902'), json8 = require('json8-patch'), fs = require('fs'), now = require("performance-now"); @@ -18,7 +18,8 @@ for (var i = 0; i < data.length; i++) { var root = "./" + data[i] + "/"; // Write title var title = data[i]+',A0_DT,A0_PS,A1_DT,A1_PS,A2_DT,A2_PS,A3_DT,A3_PS,A4_DT,A4_PS,A5_DT,A5_PS' + '\n'; - fs.writeFile(root + data[i] +'.csv', title, {flag: 'a'} ); + //use synched to avoid fs warning + fs.writeFileSync(root + data[i] +'.csv', title, {flag: 'a'} ); for (var j = 1; j <= versionNum; j++) { @@ -87,8 +88,8 @@ function generatePatch(root, data, f_old, f_new, version, algorithm) { result = result + '\n'; } - - fs.writeFile(root + data +'.csv', result, {flag: 'a'}); + //use synched to avoid fs warning + fs.writeFileSync(root + data +'.csv', result, {flag: 'a'}); } diff --git a/dataset/package.json b/dataset/package.json index 74c60ed..ef438e4 100644 --- a/dataset/package.json +++ b/dataset/package.json @@ -11,7 +11,6 @@ "dependencies": { "fast-json-patch": "^0.5.7", "jiff": "^0.7.3", - "json-diff-rfc6902": "^1.3.3", "json8-patch": "^0.4.0", "performance-now": "^0.2.0", "rfc6902": "^1.2.1" diff --git a/lib/hashObject.js b/lib/hashObject.js index 869b0d6..4955e02 100644 --- a/lib/hashObject.js +++ b/lib/hashObject.js @@ -12,9 +12,11 @@ function hash(obj, HASH_ID) { if (obj[HASH_ID] !== void 0 ) { return typeof obj[HASH_ID] === "string"? hashToNum(obj[HASH_ID]): obj[HASH_ID]; } else { + // no speculation about magical properties - just use the hashToNum(JSON.stringify(obj)) + return hashToNum(JSON.stringify(obj)); // || hashToNum(JSON.stringify(obj)) // || (obj.title === undefined)? obj.title: hashToNum(JSON.stringify(obj.title)) - return obj.id || obj._id || obj.answer_id || (obj.title === undefined? obj.title: hashToNum(JSON.stringify(obj.title))) || hashToNum(JSON.stringify(obj)); + //return obj.id || obj._id || obj.answer_id || (obj.title === undefined? obj.title: hashToNum(JSON.stringify(obj.title))) || hashToNum(JSON.stringify(obj)); } } diff --git a/lib/patchArea.js b/lib/patchArea.js index c04a37a..72ef169 100644 --- a/lib/patchArea.js +++ b/lib/patchArea.js @@ -1,3 +1,5 @@ +var deepEqual = require('./deepEquals.js'); + exports.findValueInPatchHashes = findValueInPatchHashes; exports.findValueInPatch = findValueInPatch; exports.handlePatch = handlePatch; @@ -23,8 +25,10 @@ function findValueInPatch(newValue, patches) { for (var i = 0; i < patches.length; i++) { patchValue = patches[i].value; - - if (newValue === patchValue) { + + // the two values are not neccessarily primitives + if (deepEqual._equals(newValue, patchValue)) { + //if (newValue === patchValue) { return i; } } diff --git a/lib/unchangedArea.js b/lib/unchangedArea.js index bcf1733..e0195fc 100644 --- a/lib/unchangedArea.js +++ b/lib/unchangedArea.js @@ -5,21 +5,24 @@ var applyPatches = require('./applyPatches'); exports.generateUnchanged = generateUnchanged; exports.findValueInUnchanged = findValueInUnchanged; - function generateUnchanged(oldJson, newJson, unchanged, path) { + + // Not equal + // Check the type - faster if this one goes first + if (typeof oldJson !== typeof newJson) { return; } + // Check if two json is the same // Equal if (deepEqual._equals(oldJson, newJson)) { // if (equal(oldJson, newJson)) { // console.log({path: path, value: copy.clone(newJson)}); - unchanged.push( path + "=" + JSON.stringify(newJson)); + // add the same value only once + var el = path + "=" + JSON.stringify(newJson); + if (unchanged.indexOf(el) < 0) + unchanged.push(el); return; } - // Not equal - // Check the type - if (typeof oldJson !== typeof newJson) { return; } - // Type is the same if (Array.isArray(oldJson) && Array.isArray(newJson)) { // Array @@ -34,22 +37,11 @@ function generateUnchanged(oldJson, newJson, unchanged, path) { } } -function arrayCompare(oldArr, newArr, unchanged, path) { - // Check if two array element (string) is the same - // Equal - if (oldArr === newArr) { - // if (equal(oldJson, newJson)) { - // console.log({path: path, value: copy.clone(newJson)}); - unchanged.push( path + "=" + newArr); - return; - } - -} - //********************Need to be changed ******************** function generateUnchangedArray(oldJson, newJson, unchanged, path) { - // Do nothing now - // Generate when diff + for(var i = 0, n = Math.min(oldJson.length, newJson.length); i < n; i++) { + generateUnchanged(oldJson[i], newJson[i], unchanged, path + "/" + i); + } } function generateUnchangedObject(oldJson, newJson, unchanged, path) { @@ -65,11 +57,12 @@ function generateUnchangedObject(oldJson, newJson, unchanged, path) { } function findValueInUnchanged(newValue, unchanged) { + // some optimization + var toStr = JSON.stringify(newValue), parts; for (var i = 0; i < unchanged.length; i++) { - var value = unchanged[i].split("=")[1]; - - if (newValue.toString() === value) { - return unchanged[i].split("=")[0]; + parts = unchanged[i].split("="); + if (toStr === parts[1]) { + return parts[0]; } } } diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 973c464..0000000 --- a/package-lock.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "json-diff-rfc6902", - "version": "1.3.3", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "string-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz", - "integrity": "sha1-6Kr8CsGFW0Zmkp7X3RJ1311sgRs=" - } - } -} diff --git a/package.json b/package.json index 1a62612..19045ff 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,14 @@ "dependencies": { "string-hash": "^1.1.0" }, - "devDependencies": {}, + "devDependencies": { + "mocha": "latest", + "fast-json-patch": "^0.5.7", + "jiff": "^0.7.3", + "json8-patch": "^0.4.0", + "performance-now": "^0.2.0", + "rfc6902": "^1.2.1" + }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/tests/1/fjp_new.json b/tests/1/fjp_new.json deleted file mode 100644 index 5527ab8..0000000 --- a/tests/1/fjp_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": 1, - "b": 2, - "c": 3 -} \ No newline at end of file diff --git a/tests/1/fjp_patch.json b/tests/1/fjp_patch.json deleted file mode 100644 index 97807ae..0000000 --- a/tests/1/fjp_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "add", - "path": "/c", - "value": 3 - } -] \ No newline at end of file diff --git a/tests/1/jdr_new.json b/tests/1/jdr_new.json deleted file mode 100644 index 5527ab8..0000000 --- a/tests/1/jdr_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": 1, - "b": 2, - "c": 3 -} \ No newline at end of file diff --git a/tests/1/jdr_patch.json b/tests/1/jdr_patch.json deleted file mode 100644 index 97807ae..0000000 --- a/tests/1/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "add", - "path": "/c", - "value": 3 - } -] \ No newline at end of file diff --git a/tests/1/jiff_patch.json b/tests/1/jiff_patch.json deleted file mode 100644 index 97807ae..0000000 --- a/tests/1/jiff_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "add", - "path": "/c", - "value": 3 - } -] \ No newline at end of file diff --git a/tests/10/fjp_new.json b/tests/10/fjp_new.json deleted file mode 100644 index 8e2cd67..0000000 --- a/tests/10/fjp_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - } -] \ No newline at end of file diff --git a/tests/10/fjp_patch.json b/tests/10/fjp_patch.json deleted file mode 100644 index 9c0c4e9..0000000 --- a/tests/10/fjp_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/2" - } -] \ No newline at end of file diff --git a/tests/10/jdr_new.json b/tests/10/jdr_new.json deleted file mode 100644 index 8e2cd67..0000000 --- a/tests/10/jdr_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - } -] \ No newline at end of file diff --git a/tests/10/jdr_patch.json b/tests/10/jdr_patch.json deleted file mode 100644 index 9c0c4e9..0000000 --- a/tests/10/jdr_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/2" - } -] \ No newline at end of file diff --git a/tests/10/jiff_patch.json b/tests/10/jiff_patch.json deleted file mode 100644 index 9c0c4e9..0000000 --- a/tests/10/jiff_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/2" - } -] \ No newline at end of file diff --git a/tests/11/fjp_new.json b/tests/11/fjp_new.json deleted file mode 100644 index f6d1da1..0000000 --- a/tests/11/fjp_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/11/fjp_patch.json b/tests/11/fjp_patch.json deleted file mode 100644 index d824ee7..0000000 --- a/tests/11/fjp_patch.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "op": "remove", - "path": "/2" - }, - { - "op": "replace", - "path": "/1/f2", - "value": 5 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 4 - } -] \ No newline at end of file diff --git a/tests/11/jdr_new.json b/tests/11/jdr_new.json deleted file mode 100644 index f6d1da1..0000000 --- a/tests/11/jdr_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/11/jdr_patch.json b/tests/11/jdr_patch.json deleted file mode 100644 index aa627cd..0000000 --- a/tests/11/jdr_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/11/jiff_patch.json b/tests/11/jiff_patch.json deleted file mode 100644 index aa627cd..0000000 --- a/tests/11/jiff_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/12/expected.json b/tests/12/expected.json index e96bcf3..e95d49b 100644 --- a/tests/12/expected.json +++ b/tests/12/expected.json @@ -1,10 +1,12 @@ [ { - "op": "replace", - "path": "/0", - "value": { - "f1": 6, - "f2": 7 - } + "op": "replace", + "path": "/0/f2", + "value": 7 + }, + { + "op": "replace", + "path": "/0/f1", + "value": 6 } ] \ No newline at end of file diff --git a/tests/12/fjp_new.json b/tests/12/fjp_new.json deleted file mode 100644 index 5c86735..0000000 --- a/tests/12/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 6, - "f2": 7 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/12/fjp_patch.json b/tests/12/fjp_patch.json deleted file mode 100644 index e95d49b..0000000 --- a/tests/12/fjp_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/0/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/0/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/12/jdr_new.json b/tests/12/jdr_new.json deleted file mode 100644 index 5c86735..0000000 --- a/tests/12/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 6, - "f2": 7 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/12/jdr_patch.json b/tests/12/jdr_patch.json deleted file mode 100644 index e95d49b..0000000 --- a/tests/12/jdr_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/0/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/0/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/12/jiff_patch.json b/tests/12/jiff_patch.json deleted file mode 100644 index 7eeaf1b..0000000 --- a/tests/12/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": 6, - "f2": 7 - } - }, - { - "op": "remove", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/13/expected.json b/tests/13/expected.json index f7e3eec..9d317a7 100644 --- a/tests/13/expected.json +++ b/tests/13/expected.json @@ -1,10 +1,12 @@ [ { - "op": "replace", - "path": "/2", - "value": { - "f1": 6, - "f2": 7 - } + "op": "replace", + "path": "/2/f2", + "value": 7 + }, + { + "op": "replace", + "path": "/2/f1", + "value": 6 } ] \ No newline at end of file diff --git a/tests/13/fjp_new.json b/tests/13/fjp_new.json deleted file mode 100644 index 275a70a..0000000 --- a/tests/13/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 6, - "f2": 7 - } -] \ No newline at end of file diff --git a/tests/13/fjp_patch.json b/tests/13/fjp_patch.json deleted file mode 100644 index 9d317a7..0000000 --- a/tests/13/fjp_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/2/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/13/jdr_new.json b/tests/13/jdr_new.json deleted file mode 100644 index 275a70a..0000000 --- a/tests/13/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 6, - "f2": 7 - } -] \ No newline at end of file diff --git a/tests/13/jdr_patch.json b/tests/13/jdr_patch.json deleted file mode 100644 index 9d317a7..0000000 --- a/tests/13/jdr_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/2/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/13/jiff_patch.json b/tests/13/jiff_patch.json deleted file mode 100644 index c5435da..0000000 --- a/tests/13/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/2", - "value": { - "f1": 6, - "f2": 7 - } - }, - { - "op": "remove", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/14/expected.json b/tests/14/expected.json index f3bebf0..0c8a2e8 100644 --- a/tests/14/expected.json +++ b/tests/14/expected.json @@ -1,10 +1,12 @@ [ { - "op": "replace", - "path": "/1", - "value": { - "f1": 6, - "f2": 7 - } + "op": "replace", + "path": "/1/f2", + "value": 7 + }, + { + "op": "replace", + "path": "/1/f1", + "value": 6 } ] \ No newline at end of file diff --git a/tests/14/fjp_new.json b/tests/14/fjp_new.json deleted file mode 100644 index a1fa6c0..0000000 --- a/tests/14/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 6, - "f2": 7 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/14/fjp_patch.json b/tests/14/fjp_patch.json deleted file mode 100644 index 0c8a2e8..0000000 --- a/tests/14/fjp_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/1/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/14/jdr_new.json b/tests/14/jdr_new.json deleted file mode 100644 index a1fa6c0..0000000 --- a/tests/14/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 6, - "f2": 7 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/14/jdr_patch.json b/tests/14/jdr_patch.json deleted file mode 100644 index 0c8a2e8..0000000 --- a/tests/14/jdr_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "replace", - "path": "/1/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 6 - } -] \ No newline at end of file diff --git a/tests/14/jiff_patch.json b/tests/14/jiff_patch.json deleted file mode 100644 index fe27e01..0000000 --- a/tests/14/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/1", - "value": { - "f1": 6, - "f2": 7 - } - }, - { - "op": "remove", - "path": "/2" - } -] \ No newline at end of file diff --git a/tests/15/fjp_new.json b/tests/15/fjp_new.json deleted file mode 100644 index 3a9fb86..0000000 --- a/tests/15/fjp_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - }, - { - "f1": 0, - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/15/fjp_patch.json b/tests/15/fjp_patch.json deleted file mode 100644 index ccf2ce6..0000000 --- a/tests/15/fjp_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/3", - "value": { - "f1": 0, - "f2": 1 - } - } -] \ No newline at end of file diff --git a/tests/15/jdr_new.json b/tests/15/jdr_new.json deleted file mode 100644 index 3a9fb86..0000000 --- a/tests/15/jdr_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - }, - { - "f1": 0, - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/15/jdr_patch.json b/tests/15/jdr_patch.json deleted file mode 100644 index 1bd82d6..0000000 --- a/tests/15/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "copy", - "from": "/0", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/15/jiff_patch.json b/tests/15/jiff_patch.json deleted file mode 100644 index ccf2ce6..0000000 --- a/tests/15/jiff_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/3", - "value": { - "f1": 0, - "f2": 1 - } - } -] \ No newline at end of file diff --git a/tests/16/fjp_new.json b/tests/16/fjp_new.json deleted file mode 100644 index def19b9..0000000 --- a/tests/16/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "a", - "f2": 0 - }, - { - "f1": "c", - "f2": 2 - }, - { - "f1": "b", - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/16/fjp_patch.json b/tests/16/fjp_patch.json deleted file mode 100644 index 7278897..0000000 --- a/tests/16/fjp_patch.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 1 - }, - { - "op": "replace", - "path": "/2/f1", - "value": "b" - }, - { - "op": "replace", - "path": "/1/f2", - "value": 2 - }, - { - "op": "replace", - "path": "/1/f1", - "value": "c" - } -] \ No newline at end of file diff --git a/tests/16/jdr_new.json b/tests/16/jdr_new.json deleted file mode 100644 index def19b9..0000000 --- a/tests/16/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "a", - "f2": 0 - }, - { - "f1": "c", - "f2": 2 - }, - { - "f1": "b", - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/16/jdr_patch.json b/tests/16/jdr_patch.json deleted file mode 100644 index 6b95d1e..0000000 --- a/tests/16/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "move", - "from": "/2", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/16/jiff_patch.json b/tests/16/jiff_patch.json deleted file mode 100644 index 17e6d53..0000000 --- a/tests/16/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/1", - "value": { - "f1": "c", - "f2": 2 - } - }, - { - "op": "remove", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/17/fjp_new.json b/tests/17/fjp_new.json deleted file mode 100644 index 6ba3bae..0000000 --- a/tests/17/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "b", - "f2": 1 - }, - { - "f1": "c", - "f2": 2 - }, - { - "f1": "a", - "f2": 0 - } -] \ No newline at end of file diff --git a/tests/17/fjp_patch.json b/tests/17/fjp_patch.json deleted file mode 100644 index 806d601..0000000 --- a/tests/17/fjp_patch.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 0 - }, - { - "op": "replace", - "path": "/2/f1", - "value": "a" - }, - { - "op": "replace", - "path": "/1/f2", - "value": 2 - }, - { - "op": "replace", - "path": "/1/f1", - "value": "c" - }, - { - "op": "replace", - "path": "/0/f2", - "value": 1 - }, - { - "op": "replace", - "path": "/0/f1", - "value": "b" - } -] \ No newline at end of file diff --git a/tests/17/jdr_new.json b/tests/17/jdr_new.json deleted file mode 100644 index 6ba3bae..0000000 --- a/tests/17/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "b", - "f2": 1 - }, - { - "f1": "c", - "f2": 2 - }, - { - "f1": "a", - "f2": 0 - } -] \ No newline at end of file diff --git a/tests/17/jdr_patch.json b/tests/17/jdr_patch.json deleted file mode 100644 index 9b10edb..0000000 --- a/tests/17/jdr_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "move", - "from": "/1", - "path": "/0" - }, - { - "op": "move", - "from": "/2", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/17/jiff_patch.json b/tests/17/jiff_patch.json deleted file mode 100644 index bbe40e2..0000000 --- a/tests/17/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "remove", - "path": "/0" - }, - { - "op": "add", - "path": "/2", - "value": { - "f1": "a", - "f2": 0 - } - } -] \ No newline at end of file diff --git a/tests/18/fjp_new.json b/tests/18/fjp_new.json deleted file mode 100644 index 60f85d5..0000000 --- a/tests/18/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "b", - "f2": 1 - }, - { - "f1": "a", - "f2": 0 - }, - { - "f1": "c", - "f2": 2 - } -] \ No newline at end of file diff --git a/tests/18/fjp_patch.json b/tests/18/fjp_patch.json deleted file mode 100644 index 49ede60..0000000 --- a/tests/18/fjp_patch.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "op": "replace", - "path": "/1/f2", - "value": 0 - }, - { - "op": "replace", - "path": "/1/f1", - "value": "a" - }, - { - "op": "replace", - "path": "/0/f2", - "value": 1 - }, - { - "op": "replace", - "path": "/0/f1", - "value": "b" - } -] \ No newline at end of file diff --git a/tests/18/jdr_new.json b/tests/18/jdr_new.json deleted file mode 100644 index 60f85d5..0000000 --- a/tests/18/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "b", - "f2": 1 - }, - { - "f1": "a", - "f2": 0 - }, - { - "f1": "c", - "f2": 2 - } -] \ No newline at end of file diff --git a/tests/18/jdr_patch.json b/tests/18/jdr_patch.json deleted file mode 100644 index b5bd5d7..0000000 --- a/tests/18/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "move", - "from": "/1", - "path": "/0" - } -] \ No newline at end of file diff --git a/tests/18/jiff_patch.json b/tests/18/jiff_patch.json deleted file mode 100644 index efdebb1..0000000 --- a/tests/18/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": "b", - "f2": 1 - } - }, - { - "op": "remove", - "path": "/2" - } -] \ No newline at end of file diff --git a/tests/19/expected.json b/tests/19/expected.json index eda80a9..468aed8 100644 --- a/tests/19/expected.json +++ b/tests/19/expected.json @@ -1,12 +1,12 @@ [ { "op": "move", - "from": "/0", - "path": "/2" + "from": "/2", + "path": "/0" }, { "op": "move", - "from": "/0", + "from": "/2", "path": "/1" } -] +] \ No newline at end of file diff --git a/tests/19/fjp_new.json b/tests/19/fjp_new.json deleted file mode 100644 index 6343481..0000000 --- a/tests/19/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "c", - "f2": 2 - }, - { - "f1": "b", - "f2": 1 - }, - { - "f1": "a", - "f2": 0 - } -] \ No newline at end of file diff --git a/tests/19/fjp_patch.json b/tests/19/fjp_patch.json deleted file mode 100644 index 3c3a787..0000000 --- a/tests/19/fjp_patch.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 0 - }, - { - "op": "replace", - "path": "/2/f1", - "value": "a" - }, - { - "op": "replace", - "path": "/0/f2", - "value": 2 - }, - { - "op": "replace", - "path": "/0/f1", - "value": "c" - } -] \ No newline at end of file diff --git a/tests/19/jdr_new.json b/tests/19/jdr_new.json deleted file mode 100644 index 6343481..0000000 --- a/tests/19/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "c", - "f2": 2 - }, - { - "f1": "b", - "f2": 1 - }, - { - "f1": "a", - "f2": 0 - } -] \ No newline at end of file diff --git a/tests/19/jdr_patch.json b/tests/19/jdr_patch.json deleted file mode 100644 index 468aed8..0000000 --- a/tests/19/jdr_patch.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "op": "move", - "from": "/2", - "path": "/0" - }, - { - "op": "move", - "from": "/2", - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/19/jiff_patch.json b/tests/19/jiff_patch.json deleted file mode 100644 index 9af7c10..0000000 --- a/tests/19/jiff_patch.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": "c", - "f2": 2 - } - }, - { - "op": "add", - "path": "/1", - "value": { - "f1": "b", - "f2": 1 - } - }, - { - "op": "remove", - "path": "/3" - }, - { - "op": "remove", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/2/fjp_new.json b/tests/2/fjp_new.json deleted file mode 100644 index 1ddc27a..0000000 --- a/tests/2/fjp_new.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": "1" -} \ No newline at end of file diff --git a/tests/2/fjp_patch.json b/tests/2/fjp_patch.json deleted file mode 100644 index 5cbb542..0000000 --- a/tests/2/fjp_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/b" - } -] \ No newline at end of file diff --git a/tests/2/jdr_new.json b/tests/2/jdr_new.json deleted file mode 100644 index 1ddc27a..0000000 --- a/tests/2/jdr_new.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "a": "1" -} \ No newline at end of file diff --git a/tests/2/jdr_patch.json b/tests/2/jdr_patch.json deleted file mode 100644 index 5cbb542..0000000 --- a/tests/2/jdr_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/b" - } -] \ No newline at end of file diff --git a/tests/2/jiff_patch.json b/tests/2/jiff_patch.json deleted file mode 100644 index 5cbb542..0000000 --- a/tests/2/jiff_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/b" - } -] \ No newline at end of file diff --git a/tests/20/fjp_new.json b/tests/20/fjp_new.json deleted file mode 100644 index 886eb3c..0000000 --- a/tests/20/fjp_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "c", - "f2": 2 - }, - { - "f1": "a", - "f2": 0 - }, - { - "f1": "b", - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/20/fjp_patch.json b/tests/20/fjp_patch.json deleted file mode 100644 index a36c117..0000000 --- a/tests/20/fjp_patch.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 1 - }, - { - "op": "replace", - "path": "/2/f1", - "value": "b" - }, - { - "op": "replace", - "path": "/1/f2", - "value": 0 - }, - { - "op": "replace", - "path": "/1/f1", - "value": "a" - }, - { - "op": "replace", - "path": "/0/f2", - "value": 2 - }, - { - "op": "replace", - "path": "/0/f1", - "value": "c" - } -] \ No newline at end of file diff --git a/tests/20/jdr_new.json b/tests/20/jdr_new.json deleted file mode 100644 index 886eb3c..0000000 --- a/tests/20/jdr_new.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "f1": "c", - "f2": 2 - }, - { - "f1": "a", - "f2": 0 - }, - { - "f1": "b", - "f2": 1 - } -] \ No newline at end of file diff --git a/tests/20/jdr_patch.json b/tests/20/jdr_patch.json deleted file mode 100644 index 495ff09..0000000 --- a/tests/20/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "move", - "from": "/2", - "path": "/0" - } -] \ No newline at end of file diff --git a/tests/20/jiff_patch.json b/tests/20/jiff_patch.json deleted file mode 100644 index 0ed75dc..0000000 --- a/tests/20/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": "c", - "f2": 2 - } - }, - { - "op": "remove", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/21/expected.json b/tests/21/expected.json index 7a20cfb..d845840 100644 --- a/tests/21/expected.json +++ b/tests/21/expected.json @@ -1,8 +1,8 @@ [ { "op": "add", - "path": "/2/f3", - "value": 9 + "path": "/0/f3", + "value": 7 }, { "op": "add", @@ -11,7 +11,7 @@ }, { "op": "add", - "path": "/0/f3", - "value": 7 + "path": "/2/f3", + "value": 9 } ] \ No newline at end of file diff --git a/tests/21/fjp_new.json b/tests/21/fjp_new.json deleted file mode 100644 index 6d7597c..0000000 --- a/tests/21/fjp_new.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "f1": 0, - "f2": 1, - "f3": 7 - }, - { - "f1": 2, - "f2": 3, - "f3": 8 - }, - { - "f1": 4, - "f2": 5, - "f3": 9 - } -] \ No newline at end of file diff --git a/tests/21/fjp_patch.json b/tests/21/fjp_patch.json deleted file mode 100644 index 7a20cfb..0000000 --- a/tests/21/fjp_patch.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "op": "add", - "path": "/2/f3", - "value": 9 - }, - { - "op": "add", - "path": "/1/f3", - "value": 8 - }, - { - "op": "add", - "path": "/0/f3", - "value": 7 - } -] \ No newline at end of file diff --git a/tests/21/jdr_new.json b/tests/21/jdr_new.json deleted file mode 100644 index 6d7597c..0000000 --- a/tests/21/jdr_new.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "f1": 0, - "f2": 1, - "f3": 7 - }, - { - "f1": 2, - "f2": 3, - "f3": 8 - }, - { - "f1": 4, - "f2": 5, - "f3": 9 - } -] \ No newline at end of file diff --git a/tests/21/jdr_patch.json b/tests/21/jdr_patch.json deleted file mode 100644 index d845840..0000000 --- a/tests/21/jdr_patch.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "op": "add", - "path": "/0/f3", - "value": 7 - }, - { - "op": "add", - "path": "/1/f3", - "value": 8 - }, - { - "op": "add", - "path": "/2/f3", - "value": 9 - } -] \ No newline at end of file diff --git a/tests/21/jiff_patch.json b/tests/21/jiff_patch.json deleted file mode 100644 index a9d3786..0000000 --- a/tests/21/jiff_patch.json +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": 0, - "f2": 1, - "f3": 7 - } - }, - { - "op": "add", - "path": "/1", - "value": { - "f1": 2, - "f2": 3, - "f3": 8 - } - }, - { - "op": "add", - "path": "/2", - "value": { - "f1": 4, - "f2": 5, - "f3": 9 - } - }, - { - "op": "remove", - "path": "/3" - }, - { - "op": "remove", - "path": "/3" - }, - { - "op": "remove", - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/3/fjp_new.json b/tests/3/fjp_new.json deleted file mode 100644 index ce54cf2..0000000 --- a/tests/3/fjp_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": "1", - "b": "2", - "c": "4" -} \ No newline at end of file diff --git a/tests/3/fjp_patch.json b/tests/3/fjp_patch.json deleted file mode 100644 index 2db4f87..0000000 --- a/tests/3/fjp_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "replace", - "path": "/c", - "value": "4" - } -] \ No newline at end of file diff --git a/tests/3/jdr_new.json b/tests/3/jdr_new.json deleted file mode 100644 index ce54cf2..0000000 --- a/tests/3/jdr_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": "1", - "b": "2", - "c": "4" -} \ No newline at end of file diff --git a/tests/3/jdr_patch.json b/tests/3/jdr_patch.json deleted file mode 100644 index 2db4f87..0000000 --- a/tests/3/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "replace", - "path": "/c", - "value": "4" - } -] \ No newline at end of file diff --git a/tests/3/jiff_patch.json b/tests/3/jiff_patch.json deleted file mode 100644 index 2db4f87..0000000 --- a/tests/3/jiff_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "replace", - "path": "/c", - "value": "4" - } -] \ No newline at end of file diff --git a/tests/4/fjp_new.json b/tests/4/fjp_new.json deleted file mode 100644 index 3574956..0000000 --- a/tests/4/fjp_new.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "a": "1", - "b": "2", - "c": [ - 1, - 2, - 3, - 4, - 5, - 6 - ], - "d": [ - 1, - 2, - 3, - 4, - 5, - 6 - ] -} \ No newline at end of file diff --git a/tests/4/fjp_patch.json b/tests/4/fjp_patch.json deleted file mode 100644 index c84c6ef..0000000 --- a/tests/4/fjp_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/d", - "value": [ - 1, - 2, - 3, - 4, - 5, - 6 - ] - } -] \ No newline at end of file diff --git a/tests/4/jdr_new.json b/tests/4/jdr_new.json deleted file mode 100644 index 3574956..0000000 --- a/tests/4/jdr_new.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "a": "1", - "b": "2", - "c": [ - 1, - 2, - 3, - 4, - 5, - 6 - ], - "d": [ - 1, - 2, - 3, - 4, - 5, - 6 - ] -} \ No newline at end of file diff --git a/tests/4/jdr_patch.json b/tests/4/jdr_patch.json deleted file mode 100644 index d1e1430..0000000 --- a/tests/4/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "copy", - "path": "/d", - "from": "/c" - } -] \ No newline at end of file diff --git a/tests/4/jiff_patch.json b/tests/4/jiff_patch.json deleted file mode 100644 index c84c6ef..0000000 --- a/tests/4/jiff_patch.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "op": "add", - "path": "/d", - "value": [ - 1, - 2, - 3, - 4, - 5, - 6 - ] - } -] \ No newline at end of file diff --git a/tests/5/fjp_new.json b/tests/5/fjp_new.json deleted file mode 100644 index bbdf9d5..0000000 --- a/tests/5/fjp_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": "1", - "b": "2", - "d": "333" -} \ No newline at end of file diff --git a/tests/5/fjp_patch.json b/tests/5/fjp_patch.json deleted file mode 100644 index 3c7af19..0000000 --- a/tests/5/fjp_patch.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "op": "remove", - "path": "/c" - }, - { - "op": "add", - "path": "/d", - "value": "333" - } -] \ No newline at end of file diff --git a/tests/5/jdr_new.json b/tests/5/jdr_new.json deleted file mode 100644 index bbdf9d5..0000000 --- a/tests/5/jdr_new.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "a": "1", - "b": "2", - "d": "333" -} \ No newline at end of file diff --git a/tests/5/jdr_patch.json b/tests/5/jdr_patch.json deleted file mode 100644 index 86a9a2c..0000000 --- a/tests/5/jdr_patch.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "op": "move", - "from": "/c", - "path": "/d" - } -] \ No newline at end of file diff --git a/tests/5/jiff_patch.json b/tests/5/jiff_patch.json deleted file mode 100644 index 429c41d..0000000 --- a/tests/5/jiff_patch.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "op": "add", - "path": "/d", - "value": "333" - }, - { - "op": "remove", - "path": "/c" - } -] \ No newline at end of file diff --git a/tests/6/fjp_new.json b/tests/6/fjp_new.json deleted file mode 100644 index 70a268d..0000000 --- a/tests/6/fjp_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 6, - "f2": 7 - }, - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/6/fjp_patch.json b/tests/6/fjp_patch.json deleted file mode 100644 index 1ff75c9..0000000 --- a/tests/6/fjp_patch.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 3 - }, - { - "op": "replace", - "path": "/2/f1", - "value": 2 - }, - { - "op": "replace", - "path": "/1/f2", - "value": 1 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 0 - }, - { - "op": "replace", - "path": "/0/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/0/f1", - "value": 6 - }, - { - "op": "add", - "path": "/3", - "value": { - "f1": 4, - "f2": 5 - } - } -] \ No newline at end of file diff --git a/tests/6/jdr_new.json b/tests/6/jdr_new.json deleted file mode 100644 index 70a268d..0000000 --- a/tests/6/jdr_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 6, - "f2": 7 - }, - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/6/jdr_patch.json b/tests/6/jdr_patch.json deleted file mode 100644 index 2742e18..0000000 --- a/tests/6/jdr_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "value": { - "f1": 6, - "f2": 7 - }, - "path": "/0" - } -] \ No newline at end of file diff --git a/tests/6/jiff_patch.json b/tests/6/jiff_patch.json deleted file mode 100644 index 1cd48c9..0000000 --- a/tests/6/jiff_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/0", - "value": { - "f1": 6, - "f2": 7 - } - } -] \ No newline at end of file diff --git a/tests/7/fjp_new.json b/tests/7/fjp_new.json deleted file mode 100644 index 3a52b19..0000000 --- a/tests/7/fjp_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - }, - { - "f1": 6, - "f2": 7 - } -] \ No newline at end of file diff --git a/tests/7/fjp_patch.json b/tests/7/fjp_patch.json deleted file mode 100644 index 30d4cbd..0000000 --- a/tests/7/fjp_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/3", - "value": { - "f1": 6, - "f2": 7 - } - } -] \ No newline at end of file diff --git a/tests/7/jdr_new.json b/tests/7/jdr_new.json deleted file mode 100644 index 3a52b19..0000000 --- a/tests/7/jdr_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - }, - { - "f1": 6, - "f2": 7 - } -] \ No newline at end of file diff --git a/tests/7/jdr_patch.json b/tests/7/jdr_patch.json deleted file mode 100644 index 77bddbb..0000000 --- a/tests/7/jdr_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "value": { - "f1": 6, - "f2": 7 - }, - "path": "/3" - } -] \ No newline at end of file diff --git a/tests/7/jiff_patch.json b/tests/7/jiff_patch.json deleted file mode 100644 index 30d4cbd..0000000 --- a/tests/7/jiff_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/3", - "value": { - "f1": 6, - "f2": 7 - } - } -] \ No newline at end of file diff --git a/tests/8/fjp_new.json b/tests/8/fjp_new.json deleted file mode 100644 index c1d0097..0000000 --- a/tests/8/fjp_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 6, - "f2": 7 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/8/fjp_patch.json b/tests/8/fjp_patch.json deleted file mode 100644 index c483d7d..0000000 --- a/tests/8/fjp_patch.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "op": "replace", - "path": "/2/f2", - "value": 3 - }, - { - "op": "replace", - "path": "/2/f1", - "value": 2 - }, - { - "op": "replace", - "path": "/1/f2", - "value": 7 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 6 - }, - { - "op": "add", - "path": "/3", - "value": { - "f1": 4, - "f2": 5 - } - } -] \ No newline at end of file diff --git a/tests/8/jdr_new.json b/tests/8/jdr_new.json deleted file mode 100644 index c1d0097..0000000 --- a/tests/8/jdr_new.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "f1": 0, - "f2": 1 - }, - { - "f1": 6, - "f2": 7 - }, - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/8/jdr_patch.json b/tests/8/jdr_patch.json deleted file mode 100644 index b89b57c..0000000 --- a/tests/8/jdr_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "value": { - "f1": 6, - "f2": 7 - }, - "path": "/1" - } -] \ No newline at end of file diff --git a/tests/8/jiff_patch.json b/tests/8/jiff_patch.json deleted file mode 100644 index b246348..0000000 --- a/tests/8/jiff_patch.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "op": "add", - "path": "/1", - "value": { - "f1": 6, - "f2": 7 - } - } -] \ No newline at end of file diff --git a/tests/9/fjp_new.json b/tests/9/fjp_new.json deleted file mode 100644 index 7f257ad..0000000 --- a/tests/9/fjp_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/9/fjp_patch.json b/tests/9/fjp_patch.json deleted file mode 100644 index 580d6fc..0000000 --- a/tests/9/fjp_patch.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "op": "remove", - "path": "/2" - }, - { - "op": "replace", - "path": "/1/f2", - "value": 5 - }, - { - "op": "replace", - "path": "/1/f1", - "value": 4 - }, - { - "op": "replace", - "path": "/0/f2", - "value": 3 - }, - { - "op": "replace", - "path": "/0/f1", - "value": 2 - } -] \ No newline at end of file diff --git a/tests/9/jdr_new.json b/tests/9/jdr_new.json deleted file mode 100644 index 7f257ad..0000000 --- a/tests/9/jdr_new.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "f1": 2, - "f2": 3 - }, - { - "f1": 4, - "f2": 5 - } -] \ No newline at end of file diff --git a/tests/9/jdr_patch.json b/tests/9/jdr_patch.json deleted file mode 100644 index 7aef9b1..0000000 --- a/tests/9/jdr_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/0" - } -] \ No newline at end of file diff --git a/tests/9/jiff_patch.json b/tests/9/jiff_patch.json deleted file mode 100644 index 7aef9b1..0000000 --- a/tests/9/jiff_patch.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "op": "remove", - "path": "/0" - } -] \ No newline at end of file diff --git a/tests/diff.js b/tests/diff.js index 22f9377..394babb 100644 --- a/tests/diff.js +++ b/tests/diff.js @@ -41,13 +41,14 @@ for (var i = 1; i <= n_pathlogic; i++) { jdr.apply(app_old, jdr_patch); - fs.writeFile(root + "jdr_patch.json", JSON.stringify(jdr_patch, null, 2)); - fs.writeFile(root + "fjp_patch.json", JSON.stringify(fjp_patch, null, 2)); - fs.writeFile(root + "jiff_patch.json", JSON.stringify(jiff_patch, null, 2)); - fs.writeFile(root + "rfc6902_patch.json", JSON.stringify(rfc6902_patch, null, 2)); - fs.writeFile(root + "json8_patch.json", JSON.stringify(json8_patch, null, 2)); - fs.writeFile(root + "fjp_new.json", JSON.stringify(f_old, null, 2)); - fs.writeFile(root + "jdr_new.json", JSON.stringify(app_old, null, 2)); + //use synched to avoid fs warning + fs.writeFileSync(root + "jdr_patch.json", JSON.stringify(jdr_patch, null, 2)); + fs.writeFileSync(root + "fjp_patch.json", JSON.stringify(fjp_patch, null, 2)); + fs.writeFileSync(root + "jiff_patch.json", JSON.stringify(jiff_patch, null, 2)); + fs.writeFileSync(root + "rfc6902_patch.json", JSON.stringify(rfc6902_patch, null, 2)); + fs.writeFileSync(root + "json8_patch.json", JSON.stringify(json8_patch, null, 2)); + fs.writeFileSync(root + "fjp_new.json", JSON.stringify(f_old, null, 2)); + fs.writeFileSync(root + "jdr_new.json", JSON.stringify(app_old, null, 2)); // fs.writeFile(root + "new_ori.json", JSON.stringify(f_new, null, 2)); // fs.writeFile(root + "old_ori.json", JSON.stringify(old_ori, null, 2));