mol_db 0.0.100 → 0.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.test.js +106 -217
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +106 -217
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1258,23 +1258,16 @@ var $;
|
|
|
1258
1258
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
1259
1259
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
1260
1260
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
1261
|
-
},
|
|
1262
|
-
'Number'() {
|
|
1263
1261
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
1264
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
1265
1262
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
1266
1263
|
},
|
|
1267
|
-
'
|
|
1264
|
+
'POJO'() {
|
|
1268
1265
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
1269
|
-
},
|
|
1270
|
-
'different POJOs'() {
|
|
1271
1266
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1272
|
-
},
|
|
1273
|
-
'different POJOs with same keys but different values'() {
|
|
1274
1267
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1275
|
-
},
|
|
1276
|
-
'different POJOs with different keys but same values'() {
|
|
1277
1268
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
1269
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1270
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1278
1271
|
},
|
|
1279
1272
|
'Array'() {
|
|
1280
1273
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -1282,17 +1275,12 @@ var $;
|
|
|
1282
1275
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
1283
1276
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1284
1277
|
},
|
|
1285
|
-
'
|
|
1286
|
-
|
|
1287
|
-
},
|
|
1288
|
-
'different classes with same values'() {
|
|
1289
|
-
class Obj {
|
|
1290
|
-
foo = 1;
|
|
1278
|
+
'Non POJO are different'() {
|
|
1279
|
+
class Thing extends Object {
|
|
1291
1280
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
1281
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
1282
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
1283
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1296
1284
|
},
|
|
1297
1285
|
'same POJOs with cyclic reference'() {
|
|
1298
1286
|
const a = { foo: {} };
|
|
@@ -1301,41 +1289,6 @@ var $;
|
|
|
1301
1289
|
b['self'] = b;
|
|
1302
1290
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
1303
1291
|
},
|
|
1304
|
-
'empty Element'() {
|
|
1305
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
1306
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
1307
|
-
},
|
|
1308
|
-
'Element with attributes'() {
|
|
1309
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
1310
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
1311
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
1312
|
-
},
|
|
1313
|
-
'Element with styles'() {
|
|
1314
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
1315
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
1316
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
1317
|
-
},
|
|
1318
|
-
'Element with content'() {
|
|
1319
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1320
|
-
"foo",
|
|
1321
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1322
|
-
"foo",
|
|
1323
|
-
$.$mol_jsx("br", null))));
|
|
1324
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1325
|
-
"foo",
|
|
1326
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1327
|
-
"bar",
|
|
1328
|
-
$.$mol_jsx("br", null))));
|
|
1329
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
1330
|
-
"foo",
|
|
1331
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
1332
|
-
"foo",
|
|
1333
|
-
$.$mol_jsx("hr", null))));
|
|
1334
|
-
},
|
|
1335
|
-
'Element with handlers'() {
|
|
1336
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
1337
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
1338
|
-
},
|
|
1339
1292
|
'Date'() {
|
|
1340
1293
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1341
1294
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -1347,8 +1300,9 @@ var $;
|
|
|
1347
1300
|
},
|
|
1348
1301
|
'Map'() {
|
|
1349
1302
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
1350
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
1303
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1351
1304
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1305
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1352
1306
|
},
|
|
1353
1307
|
'Set'() {
|
|
1354
1308
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -1367,97 +1321,118 @@ var $;
|
|
|
1367
1321
|
"use strict";
|
|
1368
1322
|
var $;
|
|
1369
1323
|
(function ($) {
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
function $mol_compare_deep(a, b) {
|
|
1374
|
-
if (Object.is(a, b))
|
|
1324
|
+
let cache = new WeakMap();
|
|
1325
|
+
function $mol_compare_deep(left, right) {
|
|
1326
|
+
if (Object.is(left, right))
|
|
1375
1327
|
return true;
|
|
1376
|
-
|
|
1377
|
-
const b_type = typeof b;
|
|
1378
|
-
if (a_type !== b_type)
|
|
1328
|
+
if (left === null)
|
|
1379
1329
|
return false;
|
|
1380
|
-
if (
|
|
1381
|
-
return a['toString']() === b['toString']();
|
|
1382
|
-
if (a_type !== 'object')
|
|
1330
|
+
if (right === null)
|
|
1383
1331
|
return false;
|
|
1384
|
-
if (
|
|
1332
|
+
if (typeof left !== 'object')
|
|
1385
1333
|
return false;
|
|
1386
|
-
if (
|
|
1334
|
+
if (typeof right !== 'object')
|
|
1387
1335
|
return false;
|
|
1388
|
-
|
|
1336
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
1337
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
1338
|
+
if (left_proto !== right_proto)
|
|
1389
1339
|
return false;
|
|
1390
|
-
if (
|
|
1391
|
-
return
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
if (
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1340
|
+
if (left instanceof Boolean)
|
|
1341
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1342
|
+
if (left instanceof Number)
|
|
1343
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1344
|
+
if (left instanceof String)
|
|
1345
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1346
|
+
if (left instanceof Date)
|
|
1347
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
1348
|
+
if (left instanceof RegExp)
|
|
1349
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
1350
|
+
let left_cache = cache.get(left);
|
|
1351
|
+
if (left_cache) {
|
|
1352
|
+
const right_cache = left_cache.get(right);
|
|
1353
|
+
if (typeof right_cache === 'boolean')
|
|
1354
|
+
return right_cache;
|
|
1403
1355
|
}
|
|
1404
1356
|
else {
|
|
1405
|
-
|
|
1406
|
-
cache.set(
|
|
1357
|
+
left_cache = new WeakMap([[right, true]]);
|
|
1358
|
+
cache.set(left, left_cache);
|
|
1407
1359
|
}
|
|
1408
|
-
a_stack.push(a);
|
|
1409
|
-
b_stack.push(b);
|
|
1410
1360
|
let result;
|
|
1411
1361
|
try {
|
|
1412
|
-
if (
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
}
|
|
1425
|
-
return result = true;
|
|
1426
|
-
}
|
|
1427
|
-
let count = 0;
|
|
1428
|
-
for (let key in a) {
|
|
1429
|
-
try {
|
|
1430
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
1431
|
-
return result = false;
|
|
1432
|
-
}
|
|
1433
|
-
catch (error) {
|
|
1434
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
1435
|
-
}
|
|
1436
|
-
++count;
|
|
1437
|
-
}
|
|
1438
|
-
for (let key in b) {
|
|
1439
|
-
--count;
|
|
1440
|
-
if (count < 0)
|
|
1441
|
-
return result = false;
|
|
1442
|
-
}
|
|
1443
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
1444
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
1445
|
-
return result = false;
|
|
1446
|
-
}
|
|
1447
|
-
return result = true;
|
|
1362
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
1363
|
+
result = compare_pojo(left, right);
|
|
1364
|
+
else if (Array.isArray(left))
|
|
1365
|
+
result = compare_array(left, right);
|
|
1366
|
+
else if (left instanceof Set)
|
|
1367
|
+
result = compare_set(left, right);
|
|
1368
|
+
else if (left instanceof Map)
|
|
1369
|
+
result = compare_map(left, right);
|
|
1370
|
+
else if (ArrayBuffer.isView(left))
|
|
1371
|
+
result = compare_buffer(left, right);
|
|
1372
|
+
else
|
|
1373
|
+
result = false;
|
|
1448
1374
|
}
|
|
1449
1375
|
finally {
|
|
1450
|
-
|
|
1451
|
-
b_stack.pop();
|
|
1452
|
-
if (a_stack.length === 0) {
|
|
1453
|
-
cache = null;
|
|
1454
|
-
}
|
|
1455
|
-
else {
|
|
1456
|
-
a_cache.set(b, result);
|
|
1457
|
-
}
|
|
1376
|
+
left_cache.set(right, result);
|
|
1458
1377
|
}
|
|
1378
|
+
return result;
|
|
1459
1379
|
}
|
|
1460
1380
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
1381
|
+
function compare_array(left, right) {
|
|
1382
|
+
const len = left.length;
|
|
1383
|
+
if (len !== right.length)
|
|
1384
|
+
return false;
|
|
1385
|
+
for (let i = 0; i < len; ++i) {
|
|
1386
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
return true;
|
|
1390
|
+
}
|
|
1391
|
+
function compare_buffer(left, right) {
|
|
1392
|
+
const len = left.byteLength;
|
|
1393
|
+
if (len !== right.byteLength)
|
|
1394
|
+
return false;
|
|
1395
|
+
for (let i = 0; i < len; ++i) {
|
|
1396
|
+
if (left[i] !== right[i])
|
|
1397
|
+
return false;
|
|
1398
|
+
}
|
|
1399
|
+
return true;
|
|
1400
|
+
}
|
|
1401
|
+
function compare_iterator(left, right, compare) {
|
|
1402
|
+
while (true) {
|
|
1403
|
+
const left_next = left.next();
|
|
1404
|
+
const right_next = right.next();
|
|
1405
|
+
if (left_next.done !== right_next.done)
|
|
1406
|
+
return false;
|
|
1407
|
+
if (left_next.done)
|
|
1408
|
+
break;
|
|
1409
|
+
if (!compare(left_next.value, right_next.value))
|
|
1410
|
+
return false;
|
|
1411
|
+
}
|
|
1412
|
+
return true;
|
|
1413
|
+
}
|
|
1414
|
+
function compare_set(left, right) {
|
|
1415
|
+
if (left.size !== right.size)
|
|
1416
|
+
return false;
|
|
1417
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1418
|
+
}
|
|
1419
|
+
function compare_map(left, right) {
|
|
1420
|
+
if (left.size !== right.size)
|
|
1421
|
+
return false;
|
|
1422
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
1423
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1424
|
+
}
|
|
1425
|
+
function compare_pojo(left, right) {
|
|
1426
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1427
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1428
|
+
if (left_keys.length !== right_keys.length)
|
|
1429
|
+
return false;
|
|
1430
|
+
for (let key of left_keys) {
|
|
1431
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
1432
|
+
return false;
|
|
1433
|
+
}
|
|
1434
|
+
return true;
|
|
1435
|
+
}
|
|
1461
1436
|
})($ || ($ = {}));
|
|
1462
1437
|
//deep.js.map
|
|
1463
1438
|
;
|
|
@@ -1810,92 +1785,6 @@ var $;
|
|
|
1810
1785
|
;
|
|
1811
1786
|
"use strict";
|
|
1812
1787
|
var $;
|
|
1813
|
-
(function ($) {
|
|
1814
|
-
$.$mol_test({
|
|
1815
|
-
'equal paths'() {
|
|
1816
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
1817
|
-
$.$mol_assert_like(diff, {
|
|
1818
|
-
prefix: [1, 2, 3, 4],
|
|
1819
|
-
suffix: [[], [], []],
|
|
1820
|
-
});
|
|
1821
|
-
},
|
|
1822
|
-
'different suffix'() {
|
|
1823
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
1824
|
-
$.$mol_assert_like(diff, {
|
|
1825
|
-
prefix: [1, 2],
|
|
1826
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
1827
|
-
});
|
|
1828
|
-
},
|
|
1829
|
-
'one contains other'() {
|
|
1830
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
1831
|
-
$.$mol_assert_like(diff, {
|
|
1832
|
-
prefix: [1, 2],
|
|
1833
|
-
suffix: [[3, 4], [], [3]],
|
|
1834
|
-
});
|
|
1835
|
-
},
|
|
1836
|
-
'fully different'() {
|
|
1837
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
1838
|
-
$.$mol_assert_like(diff, {
|
|
1839
|
-
prefix: [],
|
|
1840
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
1841
|
-
});
|
|
1842
|
-
},
|
|
1843
|
-
});
|
|
1844
|
-
})($ || ($ = {}));
|
|
1845
|
-
//path.test.js.map
|
|
1846
|
-
;
|
|
1847
|
-
"use strict";
|
|
1848
|
-
var $;
|
|
1849
|
-
(function ($) {
|
|
1850
|
-
function $mol_diff_path(...paths) {
|
|
1851
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
1852
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
1853
|
-
const first = paths[0][i];
|
|
1854
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
1855
|
-
if (paths[j][i] !== first)
|
|
1856
|
-
break lookup;
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
return {
|
|
1860
|
-
prefix: paths[0].slice(0, i),
|
|
1861
|
-
suffix: paths.map(path => path.slice(i)),
|
|
1862
|
-
};
|
|
1863
|
-
}
|
|
1864
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
1865
|
-
})($ || ($ = {}));
|
|
1866
|
-
//path.js.map
|
|
1867
|
-
;
|
|
1868
|
-
"use strict";
|
|
1869
|
-
var $;
|
|
1870
|
-
(function ($) {
|
|
1871
|
-
class $mol_error_mix extends Error {
|
|
1872
|
-
errors;
|
|
1873
|
-
constructor(message, ...errors) {
|
|
1874
|
-
super(message);
|
|
1875
|
-
this.errors = errors;
|
|
1876
|
-
if (errors.length) {
|
|
1877
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
1878
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
1879
|
-
if (!stack)
|
|
1880
|
-
return [];
|
|
1881
|
-
return stack.split('\n').reverse();
|
|
1882
|
-
}));
|
|
1883
|
-
const head = diff.prefix.reverse().join('\n');
|
|
1884
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
1885
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
1886
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
toJSON() {
|
|
1890
|
-
return this.message;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
1894
|
-
})($ || ($ = {}));
|
|
1895
|
-
//mix.js.map
|
|
1896
|
-
;
|
|
1897
|
-
"use strict";
|
|
1898
|
-
var $;
|
|
1899
1788
|
(function ($) {
|
|
1900
1789
|
$.$mol_test({
|
|
1901
1790
|
async 'unique index'() {
|