mol_crypto_lib 0.0.152 → 0.0.153
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 +86 -129
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +86 -129
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -588,7 +588,8 @@ var $;
|
|
|
588
588
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
589
589
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
590
590
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
591
|
-
$.$
|
|
591
|
+
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
592
|
+
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
592
593
|
},
|
|
593
594
|
'POJO'() {
|
|
594
595
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
@@ -629,8 +630,9 @@ var $;
|
|
|
629
630
|
},
|
|
630
631
|
'Map'() {
|
|
631
632
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
632
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
633
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
633
634
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
635
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
634
636
|
},
|
|
635
637
|
'Set'() {
|
|
636
638
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -661,8 +663,20 @@ var $;
|
|
|
661
663
|
return false;
|
|
662
664
|
if (typeof right !== 'object')
|
|
663
665
|
return false;
|
|
664
|
-
|
|
666
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
667
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
668
|
+
if (left_proto !== right_proto)
|
|
665
669
|
return false;
|
|
670
|
+
if (left instanceof Boolean)
|
|
671
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
672
|
+
if (left instanceof Number)
|
|
673
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
674
|
+
if (left instanceof String)
|
|
675
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
676
|
+
if (left instanceof Date)
|
|
677
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
678
|
+
if (left instanceof RegExp)
|
|
679
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
666
680
|
let left_cache = cache.get(left);
|
|
667
681
|
if (left_cache) {
|
|
668
682
|
const right_cache = left_cache.get(right);
|
|
@@ -670,56 +684,85 @@ var $;
|
|
|
670
684
|
return right_cache;
|
|
671
685
|
}
|
|
672
686
|
else {
|
|
673
|
-
left_cache = new WeakMap();
|
|
687
|
+
left_cache = new WeakMap([[right, true]]);
|
|
674
688
|
cache.set(left, left_cache);
|
|
675
|
-
left_cache.set(right, true);
|
|
676
689
|
}
|
|
677
|
-
if (left instanceof RegExp)
|
|
678
|
-
return left.toString() === right['toString']();
|
|
679
|
-
if (left instanceof Date)
|
|
680
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
681
690
|
let result;
|
|
682
691
|
try {
|
|
683
|
-
if (
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
return result = true;
|
|
697
|
-
}
|
|
698
|
-
if (left['constructor'] !== ({}).constructor)
|
|
699
|
-
return result = false;
|
|
700
|
-
let count = 0;
|
|
701
|
-
for (let key in left) {
|
|
702
|
-
try {
|
|
703
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
704
|
-
return result = false;
|
|
705
|
-
}
|
|
706
|
-
catch (error) {
|
|
707
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${left} and ${right}`, error));
|
|
708
|
-
}
|
|
709
|
-
++count;
|
|
710
|
-
}
|
|
711
|
-
for (let key in right) {
|
|
712
|
-
--count;
|
|
713
|
-
if (count < 0)
|
|
714
|
-
return result = false;
|
|
715
|
-
}
|
|
716
|
-
return result = true;
|
|
692
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
693
|
+
result = compare_pojo(left, right);
|
|
694
|
+
else if (Array.isArray(left))
|
|
695
|
+
result = compare_array(left, right);
|
|
696
|
+
else if (left instanceof Set)
|
|
697
|
+
result = compare_set(left, right);
|
|
698
|
+
else if (left instanceof Map)
|
|
699
|
+
result = compare_map(left, right);
|
|
700
|
+
else if (ArrayBuffer.isView(left))
|
|
701
|
+
result = compare_buffer(left, right);
|
|
702
|
+
else
|
|
703
|
+
result = false;
|
|
717
704
|
}
|
|
718
705
|
finally {
|
|
719
706
|
left_cache.set(right, result);
|
|
720
707
|
}
|
|
708
|
+
return result;
|
|
721
709
|
}
|
|
722
710
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
711
|
+
function compare_array(left, right) {
|
|
712
|
+
const len = left.length;
|
|
713
|
+
if (len !== right.length)
|
|
714
|
+
return false;
|
|
715
|
+
for (let i = 0; i < len; ++i) {
|
|
716
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
function compare_buffer(left, right) {
|
|
722
|
+
const len = left.byteLength;
|
|
723
|
+
if (len !== right.byteLength)
|
|
724
|
+
return false;
|
|
725
|
+
for (let i = 0; i < len; ++i) {
|
|
726
|
+
if (left[i] !== right[i])
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
function compare_iterator(left, right, compare) {
|
|
732
|
+
while (true) {
|
|
733
|
+
const left_next = left.next();
|
|
734
|
+
const right_next = right.next();
|
|
735
|
+
if (left_next.done !== right_next.done)
|
|
736
|
+
return false;
|
|
737
|
+
if (left_next.done)
|
|
738
|
+
break;
|
|
739
|
+
if (!compare(left_next.value, right_next.value))
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
function compare_set(left, right) {
|
|
745
|
+
if (left.size !== right.size)
|
|
746
|
+
return false;
|
|
747
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
748
|
+
}
|
|
749
|
+
function compare_map(left, right) {
|
|
750
|
+
if (left.size !== right.size)
|
|
751
|
+
return false;
|
|
752
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
753
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
754
|
+
}
|
|
755
|
+
function compare_pojo(left, right) {
|
|
756
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
757
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
758
|
+
if (left_keys.length !== right_keys.length)
|
|
759
|
+
return false;
|
|
760
|
+
for (let key of left_keys) {
|
|
761
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
723
766
|
})($ || ($ = {}));
|
|
724
767
|
//deep.js.map
|
|
725
768
|
;
|
|
@@ -1700,91 +1743,5 @@ var $;
|
|
|
1700
1743
|
;
|
|
1701
1744
|
"use strict";
|
|
1702
1745
|
//equals.js.map
|
|
1703
|
-
;
|
|
1704
|
-
"use strict";
|
|
1705
|
-
var $;
|
|
1706
|
-
(function ($) {
|
|
1707
|
-
$.$mol_test({
|
|
1708
|
-
'equal paths'() {
|
|
1709
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
1710
|
-
$.$mol_assert_like(diff, {
|
|
1711
|
-
prefix: [1, 2, 3, 4],
|
|
1712
|
-
suffix: [[], [], []],
|
|
1713
|
-
});
|
|
1714
|
-
},
|
|
1715
|
-
'different suffix'() {
|
|
1716
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
1717
|
-
$.$mol_assert_like(diff, {
|
|
1718
|
-
prefix: [1, 2],
|
|
1719
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
1720
|
-
});
|
|
1721
|
-
},
|
|
1722
|
-
'one contains other'() {
|
|
1723
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
1724
|
-
$.$mol_assert_like(diff, {
|
|
1725
|
-
prefix: [1, 2],
|
|
1726
|
-
suffix: [[3, 4], [], [3]],
|
|
1727
|
-
});
|
|
1728
|
-
},
|
|
1729
|
-
'fully different'() {
|
|
1730
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
1731
|
-
$.$mol_assert_like(diff, {
|
|
1732
|
-
prefix: [],
|
|
1733
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
1734
|
-
});
|
|
1735
|
-
},
|
|
1736
|
-
});
|
|
1737
|
-
})($ || ($ = {}));
|
|
1738
|
-
//path.test.js.map
|
|
1739
|
-
;
|
|
1740
|
-
"use strict";
|
|
1741
|
-
var $;
|
|
1742
|
-
(function ($) {
|
|
1743
|
-
function $mol_diff_path(...paths) {
|
|
1744
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
1745
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
1746
|
-
const first = paths[0][i];
|
|
1747
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
1748
|
-
if (paths[j][i] !== first)
|
|
1749
|
-
break lookup;
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
return {
|
|
1753
|
-
prefix: paths[0].slice(0, i),
|
|
1754
|
-
suffix: paths.map(path => path.slice(i)),
|
|
1755
|
-
};
|
|
1756
|
-
}
|
|
1757
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
1758
|
-
})($ || ($ = {}));
|
|
1759
|
-
//path.js.map
|
|
1760
|
-
;
|
|
1761
|
-
"use strict";
|
|
1762
|
-
var $;
|
|
1763
|
-
(function ($) {
|
|
1764
|
-
class $mol_error_mix extends Error {
|
|
1765
|
-
errors;
|
|
1766
|
-
constructor(message, ...errors) {
|
|
1767
|
-
super(message);
|
|
1768
|
-
this.errors = errors;
|
|
1769
|
-
if (errors.length) {
|
|
1770
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
1771
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
1772
|
-
if (!stack)
|
|
1773
|
-
return [];
|
|
1774
|
-
return stack.split('\n').reverse();
|
|
1775
|
-
}));
|
|
1776
|
-
const head = diff.prefix.reverse().join('\n');
|
|
1777
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
1778
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
1779
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
toJSON() {
|
|
1783
|
-
return this.message;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
1787
|
-
})($ || ($ = {}));
|
|
1788
|
-
//mix.js.map
|
|
1789
1746
|
|
|
1790
1747
|
//# sourceMappingURL=node.test.js.map
|