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/package.json
CHANGED
package/web.test.js
CHANGED
|
@@ -346,23 +346,16 @@ var $;
|
|
|
346
346
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
347
347
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
348
348
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
349
|
-
},
|
|
350
|
-
'Number'() {
|
|
351
349
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
352
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
353
350
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
354
351
|
},
|
|
355
|
-
'
|
|
352
|
+
'POJO'() {
|
|
356
353
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
357
|
-
},
|
|
358
|
-
'different POJOs'() {
|
|
359
354
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
360
|
-
},
|
|
361
|
-
'different POJOs with same keys but different values'() {
|
|
362
355
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
363
|
-
},
|
|
364
|
-
'different POJOs with different keys but same values'() {
|
|
365
356
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
357
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
358
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
366
359
|
},
|
|
367
360
|
'Array'() {
|
|
368
361
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -370,17 +363,12 @@ var $;
|
|
|
370
363
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
371
364
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
372
365
|
},
|
|
373
|
-
'
|
|
374
|
-
|
|
375
|
-
},
|
|
376
|
-
'different classes with same values'() {
|
|
377
|
-
class Obj {
|
|
378
|
-
foo = 1;
|
|
366
|
+
'Non POJO are different'() {
|
|
367
|
+
class Thing extends Object {
|
|
379
368
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
369
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
370
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
371
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
384
372
|
},
|
|
385
373
|
'same POJOs with cyclic reference'() {
|
|
386
374
|
const a = { foo: {} };
|
|
@@ -389,41 +377,6 @@ var $;
|
|
|
389
377
|
b['self'] = b;
|
|
390
378
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
391
379
|
},
|
|
392
|
-
'empty Element'() {
|
|
393
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
394
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
395
|
-
},
|
|
396
|
-
'Element with attributes'() {
|
|
397
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
398
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
399
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
400
|
-
},
|
|
401
|
-
'Element with styles'() {
|
|
402
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
403
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
404
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
405
|
-
},
|
|
406
|
-
'Element with content'() {
|
|
407
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
408
|
-
"foo",
|
|
409
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
410
|
-
"foo",
|
|
411
|
-
$.$mol_jsx("br", null))));
|
|
412
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
413
|
-
"foo",
|
|
414
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
415
|
-
"bar",
|
|
416
|
-
$.$mol_jsx("br", null))));
|
|
417
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
418
|
-
"foo",
|
|
419
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
420
|
-
"foo",
|
|
421
|
-
$.$mol_jsx("hr", null))));
|
|
422
|
-
},
|
|
423
|
-
'Element with handlers'() {
|
|
424
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
425
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
426
|
-
},
|
|
427
380
|
'Date'() {
|
|
428
381
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
429
382
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -435,8 +388,9 @@ var $;
|
|
|
435
388
|
},
|
|
436
389
|
'Map'() {
|
|
437
390
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
438
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
391
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
439
392
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
393
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
440
394
|
},
|
|
441
395
|
'Set'() {
|
|
442
396
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -455,97 +409,118 @@ var $;
|
|
|
455
409
|
"use strict";
|
|
456
410
|
var $;
|
|
457
411
|
(function ($) {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
function $mol_compare_deep(a, b) {
|
|
462
|
-
if (Object.is(a, b))
|
|
412
|
+
let cache = new WeakMap();
|
|
413
|
+
function $mol_compare_deep(left, right) {
|
|
414
|
+
if (Object.is(left, right))
|
|
463
415
|
return true;
|
|
464
|
-
|
|
465
|
-
const b_type = typeof b;
|
|
466
|
-
if (a_type !== b_type)
|
|
416
|
+
if (left === null)
|
|
467
417
|
return false;
|
|
468
|
-
if (
|
|
469
|
-
return a['toString']() === b['toString']();
|
|
470
|
-
if (a_type !== 'object')
|
|
418
|
+
if (right === null)
|
|
471
419
|
return false;
|
|
472
|
-
if (
|
|
420
|
+
if (typeof left !== 'object')
|
|
473
421
|
return false;
|
|
474
|
-
if (
|
|
422
|
+
if (typeof right !== 'object')
|
|
475
423
|
return false;
|
|
476
|
-
|
|
424
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
425
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
426
|
+
if (left_proto !== right_proto)
|
|
477
427
|
return false;
|
|
478
|
-
if (
|
|
479
|
-
return
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
428
|
+
if (left instanceof Boolean)
|
|
429
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
430
|
+
if (left instanceof Number)
|
|
431
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
432
|
+
if (left instanceof String)
|
|
433
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
434
|
+
if (left instanceof Date)
|
|
435
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
436
|
+
if (left instanceof RegExp)
|
|
437
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
438
|
+
let left_cache = cache.get(left);
|
|
439
|
+
if (left_cache) {
|
|
440
|
+
const right_cache = left_cache.get(right);
|
|
441
|
+
if (typeof right_cache === 'boolean')
|
|
442
|
+
return right_cache;
|
|
491
443
|
}
|
|
492
444
|
else {
|
|
493
|
-
|
|
494
|
-
cache.set(
|
|
445
|
+
left_cache = new WeakMap([[right, true]]);
|
|
446
|
+
cache.set(left, left_cache);
|
|
495
447
|
}
|
|
496
|
-
a_stack.push(a);
|
|
497
|
-
b_stack.push(b);
|
|
498
448
|
let result;
|
|
499
449
|
try {
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
return result = true;
|
|
514
|
-
}
|
|
515
|
-
let count = 0;
|
|
516
|
-
for (let key in a) {
|
|
517
|
-
try {
|
|
518
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
519
|
-
return result = false;
|
|
520
|
-
}
|
|
521
|
-
catch (error) {
|
|
522
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
523
|
-
}
|
|
524
|
-
++count;
|
|
525
|
-
}
|
|
526
|
-
for (let key in b) {
|
|
527
|
-
--count;
|
|
528
|
-
if (count < 0)
|
|
529
|
-
return result = false;
|
|
530
|
-
}
|
|
531
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
532
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
533
|
-
return result = false;
|
|
534
|
-
}
|
|
535
|
-
return result = true;
|
|
450
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
451
|
+
result = compare_pojo(left, right);
|
|
452
|
+
else if (Array.isArray(left))
|
|
453
|
+
result = compare_array(left, right);
|
|
454
|
+
else if (left instanceof Set)
|
|
455
|
+
result = compare_set(left, right);
|
|
456
|
+
else if (left instanceof Map)
|
|
457
|
+
result = compare_map(left, right);
|
|
458
|
+
else if (ArrayBuffer.isView(left))
|
|
459
|
+
result = compare_buffer(left, right);
|
|
460
|
+
else
|
|
461
|
+
result = false;
|
|
536
462
|
}
|
|
537
463
|
finally {
|
|
538
|
-
|
|
539
|
-
b_stack.pop();
|
|
540
|
-
if (a_stack.length === 0) {
|
|
541
|
-
cache = null;
|
|
542
|
-
}
|
|
543
|
-
else {
|
|
544
|
-
a_cache.set(b, result);
|
|
545
|
-
}
|
|
464
|
+
left_cache.set(right, result);
|
|
546
465
|
}
|
|
466
|
+
return result;
|
|
547
467
|
}
|
|
548
468
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
469
|
+
function compare_array(left, right) {
|
|
470
|
+
const len = left.length;
|
|
471
|
+
if (len !== right.length)
|
|
472
|
+
return false;
|
|
473
|
+
for (let i = 0; i < len; ++i) {
|
|
474
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
function compare_buffer(left, right) {
|
|
480
|
+
const len = left.byteLength;
|
|
481
|
+
if (len !== right.byteLength)
|
|
482
|
+
return false;
|
|
483
|
+
for (let i = 0; i < len; ++i) {
|
|
484
|
+
if (left[i] !== right[i])
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
function compare_iterator(left, right, compare) {
|
|
490
|
+
while (true) {
|
|
491
|
+
const left_next = left.next();
|
|
492
|
+
const right_next = right.next();
|
|
493
|
+
if (left_next.done !== right_next.done)
|
|
494
|
+
return false;
|
|
495
|
+
if (left_next.done)
|
|
496
|
+
break;
|
|
497
|
+
if (!compare(left_next.value, right_next.value))
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
return true;
|
|
501
|
+
}
|
|
502
|
+
function compare_set(left, right) {
|
|
503
|
+
if (left.size !== right.size)
|
|
504
|
+
return false;
|
|
505
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
506
|
+
}
|
|
507
|
+
function compare_map(left, right) {
|
|
508
|
+
if (left.size !== right.size)
|
|
509
|
+
return false;
|
|
510
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
511
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
512
|
+
}
|
|
513
|
+
function compare_pojo(left, right) {
|
|
514
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
515
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
516
|
+
if (left_keys.length !== right_keys.length)
|
|
517
|
+
return false;
|
|
518
|
+
for (let key of left_keys) {
|
|
519
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
549
524
|
})($ || ($ = {}));
|
|
550
525
|
//deep.js.map
|
|
551
526
|
;
|
|
@@ -831,92 +806,6 @@ var $;
|
|
|
831
806
|
;
|
|
832
807
|
"use strict";
|
|
833
808
|
var $;
|
|
834
|
-
(function ($) {
|
|
835
|
-
$.$mol_test({
|
|
836
|
-
'equal paths'() {
|
|
837
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
838
|
-
$.$mol_assert_like(diff, {
|
|
839
|
-
prefix: [1, 2, 3, 4],
|
|
840
|
-
suffix: [[], [], []],
|
|
841
|
-
});
|
|
842
|
-
},
|
|
843
|
-
'different suffix'() {
|
|
844
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
845
|
-
$.$mol_assert_like(diff, {
|
|
846
|
-
prefix: [1, 2],
|
|
847
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
848
|
-
});
|
|
849
|
-
},
|
|
850
|
-
'one contains other'() {
|
|
851
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
852
|
-
$.$mol_assert_like(diff, {
|
|
853
|
-
prefix: [1, 2],
|
|
854
|
-
suffix: [[3, 4], [], [3]],
|
|
855
|
-
});
|
|
856
|
-
},
|
|
857
|
-
'fully different'() {
|
|
858
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
859
|
-
$.$mol_assert_like(diff, {
|
|
860
|
-
prefix: [],
|
|
861
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
862
|
-
});
|
|
863
|
-
},
|
|
864
|
-
});
|
|
865
|
-
})($ || ($ = {}));
|
|
866
|
-
//path.test.js.map
|
|
867
|
-
;
|
|
868
|
-
"use strict";
|
|
869
|
-
var $;
|
|
870
|
-
(function ($) {
|
|
871
|
-
function $mol_diff_path(...paths) {
|
|
872
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
873
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
874
|
-
const first = paths[0][i];
|
|
875
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
876
|
-
if (paths[j][i] !== first)
|
|
877
|
-
break lookup;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
return {
|
|
881
|
-
prefix: paths[0].slice(0, i),
|
|
882
|
-
suffix: paths.map(path => path.slice(i)),
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
886
|
-
})($ || ($ = {}));
|
|
887
|
-
//path.js.map
|
|
888
|
-
;
|
|
889
|
-
"use strict";
|
|
890
|
-
var $;
|
|
891
|
-
(function ($) {
|
|
892
|
-
class $mol_error_mix extends Error {
|
|
893
|
-
errors;
|
|
894
|
-
constructor(message, ...errors) {
|
|
895
|
-
super(message);
|
|
896
|
-
this.errors = errors;
|
|
897
|
-
if (errors.length) {
|
|
898
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
899
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
900
|
-
if (!stack)
|
|
901
|
-
return [];
|
|
902
|
-
return stack.split('\n').reverse();
|
|
903
|
-
}));
|
|
904
|
-
const head = diff.prefix.reverse().join('\n');
|
|
905
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
906
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
907
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
toJSON() {
|
|
911
|
-
return this.message;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
915
|
-
})($ || ($ = {}));
|
|
916
|
-
//mix.js.map
|
|
917
|
-
;
|
|
918
|
-
"use strict";
|
|
919
|
-
var $;
|
|
920
809
|
(function ($) {
|
|
921
810
|
$.$mol_test({
|
|
922
811
|
async 'unique index'() {
|