mol_regexp 0.0.200 → 0.0.204
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
|
@@ -701,23 +701,16 @@ var $;
|
|
|
701
701
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
702
702
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
703
703
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
704
|
-
},
|
|
705
|
-
'Number'() {
|
|
706
704
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
707
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
708
705
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
709
706
|
},
|
|
710
|
-
'
|
|
707
|
+
'POJO'() {
|
|
711
708
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
712
|
-
},
|
|
713
|
-
'different POJOs'() {
|
|
714
709
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
715
|
-
},
|
|
716
|
-
'different POJOs with same keys but different values'() {
|
|
717
710
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
718
|
-
},
|
|
719
|
-
'different POJOs with different keys but same values'() {
|
|
720
711
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
712
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
713
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
721
714
|
},
|
|
722
715
|
'Array'() {
|
|
723
716
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -725,17 +718,12 @@ var $;
|
|
|
725
718
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
726
719
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
727
720
|
},
|
|
728
|
-
'
|
|
729
|
-
|
|
730
|
-
},
|
|
731
|
-
'different classes with same values'() {
|
|
732
|
-
class Obj {
|
|
733
|
-
foo = 1;
|
|
721
|
+
'Non POJO are different'() {
|
|
722
|
+
class Thing extends Object {
|
|
734
723
|
}
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
724
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
725
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
726
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
739
727
|
},
|
|
740
728
|
'same POJOs with cyclic reference'() {
|
|
741
729
|
const a = { foo: {} };
|
|
@@ -744,41 +732,6 @@ var $;
|
|
|
744
732
|
b['self'] = b;
|
|
745
733
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
746
734
|
},
|
|
747
|
-
'empty Element'() {
|
|
748
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
749
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
750
|
-
},
|
|
751
|
-
'Element with attributes'() {
|
|
752
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
753
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
754
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
755
|
-
},
|
|
756
|
-
'Element with styles'() {
|
|
757
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
758
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
759
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
760
|
-
},
|
|
761
|
-
'Element with content'() {
|
|
762
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
763
|
-
"foo",
|
|
764
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
765
|
-
"foo",
|
|
766
|
-
$.$mol_jsx("br", null))));
|
|
767
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
768
|
-
"foo",
|
|
769
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
770
|
-
"bar",
|
|
771
|
-
$.$mol_jsx("br", null))));
|
|
772
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
773
|
-
"foo",
|
|
774
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
775
|
-
"foo",
|
|
776
|
-
$.$mol_jsx("hr", null))));
|
|
777
|
-
},
|
|
778
|
-
'Element with handlers'() {
|
|
779
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
780
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
781
|
-
},
|
|
782
735
|
'Date'() {
|
|
783
736
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
784
737
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -790,8 +743,9 @@ var $;
|
|
|
790
743
|
},
|
|
791
744
|
'Map'() {
|
|
792
745
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
793
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
746
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
794
747
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
748
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
795
749
|
},
|
|
796
750
|
'Set'() {
|
|
797
751
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -810,97 +764,118 @@ var $;
|
|
|
810
764
|
"use strict";
|
|
811
765
|
var $;
|
|
812
766
|
(function ($) {
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
function $mol_compare_deep(a, b) {
|
|
817
|
-
if (Object.is(a, b))
|
|
767
|
+
let cache = new WeakMap();
|
|
768
|
+
function $mol_compare_deep(left, right) {
|
|
769
|
+
if (Object.is(left, right))
|
|
818
770
|
return true;
|
|
819
|
-
|
|
820
|
-
const b_type = typeof b;
|
|
821
|
-
if (a_type !== b_type)
|
|
771
|
+
if (left === null)
|
|
822
772
|
return false;
|
|
823
|
-
if (
|
|
824
|
-
return a['toString']() === b['toString']();
|
|
825
|
-
if (a_type !== 'object')
|
|
773
|
+
if (right === null)
|
|
826
774
|
return false;
|
|
827
|
-
if (
|
|
775
|
+
if (typeof left !== 'object')
|
|
828
776
|
return false;
|
|
829
|
-
if (
|
|
777
|
+
if (typeof right !== 'object')
|
|
830
778
|
return false;
|
|
831
|
-
|
|
779
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
780
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
781
|
+
if (left_proto !== right_proto)
|
|
832
782
|
return false;
|
|
833
|
-
if (
|
|
834
|
-
return
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
if (
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
783
|
+
if (left instanceof Boolean)
|
|
784
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
785
|
+
if (left instanceof Number)
|
|
786
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
787
|
+
if (left instanceof String)
|
|
788
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
789
|
+
if (left instanceof Date)
|
|
790
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
791
|
+
if (left instanceof RegExp)
|
|
792
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
793
|
+
let left_cache = cache.get(left);
|
|
794
|
+
if (left_cache) {
|
|
795
|
+
const right_cache = left_cache.get(right);
|
|
796
|
+
if (typeof right_cache === 'boolean')
|
|
797
|
+
return right_cache;
|
|
846
798
|
}
|
|
847
799
|
else {
|
|
848
|
-
|
|
849
|
-
cache.set(
|
|
800
|
+
left_cache = new WeakMap([[right, true]]);
|
|
801
|
+
cache.set(left, left_cache);
|
|
850
802
|
}
|
|
851
|
-
a_stack.push(a);
|
|
852
|
-
b_stack.push(b);
|
|
853
803
|
let result;
|
|
854
804
|
try {
|
|
855
|
-
if (
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
868
|
-
return result = true;
|
|
869
|
-
}
|
|
870
|
-
let count = 0;
|
|
871
|
-
for (let key in a) {
|
|
872
|
-
try {
|
|
873
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
874
|
-
return result = false;
|
|
875
|
-
}
|
|
876
|
-
catch (error) {
|
|
877
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
878
|
-
}
|
|
879
|
-
++count;
|
|
880
|
-
}
|
|
881
|
-
for (let key in b) {
|
|
882
|
-
--count;
|
|
883
|
-
if (count < 0)
|
|
884
|
-
return result = false;
|
|
885
|
-
}
|
|
886
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
887
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
888
|
-
return result = false;
|
|
889
|
-
}
|
|
890
|
-
return result = true;
|
|
805
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
806
|
+
result = compare_pojo(left, right);
|
|
807
|
+
else if (Array.isArray(left))
|
|
808
|
+
result = compare_array(left, right);
|
|
809
|
+
else if (left instanceof Set)
|
|
810
|
+
result = compare_set(left, right);
|
|
811
|
+
else if (left instanceof Map)
|
|
812
|
+
result = compare_map(left, right);
|
|
813
|
+
else if (ArrayBuffer.isView(left))
|
|
814
|
+
result = compare_buffer(left, right);
|
|
815
|
+
else
|
|
816
|
+
result = false;
|
|
891
817
|
}
|
|
892
818
|
finally {
|
|
893
|
-
|
|
894
|
-
b_stack.pop();
|
|
895
|
-
if (a_stack.length === 0) {
|
|
896
|
-
cache = null;
|
|
897
|
-
}
|
|
898
|
-
else {
|
|
899
|
-
a_cache.set(b, result);
|
|
900
|
-
}
|
|
819
|
+
left_cache.set(right, result);
|
|
901
820
|
}
|
|
821
|
+
return result;
|
|
902
822
|
}
|
|
903
823
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
824
|
+
function compare_array(left, right) {
|
|
825
|
+
const len = left.length;
|
|
826
|
+
if (len !== right.length)
|
|
827
|
+
return false;
|
|
828
|
+
for (let i = 0; i < len; ++i) {
|
|
829
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
return true;
|
|
833
|
+
}
|
|
834
|
+
function compare_buffer(left, right) {
|
|
835
|
+
const len = left.byteLength;
|
|
836
|
+
if (len !== right.byteLength)
|
|
837
|
+
return false;
|
|
838
|
+
for (let i = 0; i < len; ++i) {
|
|
839
|
+
if (left[i] !== right[i])
|
|
840
|
+
return false;
|
|
841
|
+
}
|
|
842
|
+
return true;
|
|
843
|
+
}
|
|
844
|
+
function compare_iterator(left, right, compare) {
|
|
845
|
+
while (true) {
|
|
846
|
+
const left_next = left.next();
|
|
847
|
+
const right_next = right.next();
|
|
848
|
+
if (left_next.done !== right_next.done)
|
|
849
|
+
return false;
|
|
850
|
+
if (left_next.done)
|
|
851
|
+
break;
|
|
852
|
+
if (!compare(left_next.value, right_next.value))
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
function compare_set(left, right) {
|
|
858
|
+
if (left.size !== right.size)
|
|
859
|
+
return false;
|
|
860
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
861
|
+
}
|
|
862
|
+
function compare_map(left, right) {
|
|
863
|
+
if (left.size !== right.size)
|
|
864
|
+
return false;
|
|
865
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
866
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
867
|
+
}
|
|
868
|
+
function compare_pojo(left, right) {
|
|
869
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
870
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
871
|
+
if (left_keys.length !== right_keys.length)
|
|
872
|
+
return false;
|
|
873
|
+
for (let key of left_keys) {
|
|
874
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
return true;
|
|
878
|
+
}
|
|
904
879
|
})($ || ($ = {}));
|
|
905
880
|
//deep.js.map
|
|
906
881
|
;
|
|
@@ -2061,91 +2036,5 @@ var $;
|
|
|
2061
2036
|
$.$mol_tree = $mol_tree;
|
|
2062
2037
|
})($ || ($ = {}));
|
|
2063
2038
|
//tree.js.map
|
|
2064
|
-
;
|
|
2065
|
-
"use strict";
|
|
2066
|
-
var $;
|
|
2067
|
-
(function ($) {
|
|
2068
|
-
$.$mol_test({
|
|
2069
|
-
'equal paths'() {
|
|
2070
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
|
|
2071
|
-
$.$mol_assert_like(diff, {
|
|
2072
|
-
prefix: [1, 2, 3, 4],
|
|
2073
|
-
suffix: [[], [], []],
|
|
2074
|
-
});
|
|
2075
|
-
},
|
|
2076
|
-
'different suffix'() {
|
|
2077
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
|
|
2078
|
-
$.$mol_assert_like(diff, {
|
|
2079
|
-
prefix: [1, 2],
|
|
2080
|
-
suffix: [[3, 4], [3, 5], [5, 4]],
|
|
2081
|
-
});
|
|
2082
|
-
},
|
|
2083
|
-
'one contains other'() {
|
|
2084
|
-
const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
|
|
2085
|
-
$.$mol_assert_like(diff, {
|
|
2086
|
-
prefix: [1, 2],
|
|
2087
|
-
suffix: [[3, 4], [], [3]],
|
|
2088
|
-
});
|
|
2089
|
-
},
|
|
2090
|
-
'fully different'() {
|
|
2091
|
-
const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
|
|
2092
|
-
$.$mol_assert_like(diff, {
|
|
2093
|
-
prefix: [],
|
|
2094
|
-
suffix: [[1, 2], [3, 4], [5, 6]],
|
|
2095
|
-
});
|
|
2096
|
-
},
|
|
2097
|
-
});
|
|
2098
|
-
})($ || ($ = {}));
|
|
2099
|
-
//path.test.js.map
|
|
2100
|
-
;
|
|
2101
|
-
"use strict";
|
|
2102
|
-
var $;
|
|
2103
|
-
(function ($) {
|
|
2104
|
-
function $mol_diff_path(...paths) {
|
|
2105
|
-
const limit = Math.min(...paths.map(path => path.length));
|
|
2106
|
-
lookup: for (var i = 0; i < limit; ++i) {
|
|
2107
|
-
const first = paths[0][i];
|
|
2108
|
-
for (let j = 1; j < paths.length; ++j) {
|
|
2109
|
-
if (paths[j][i] !== first)
|
|
2110
|
-
break lookup;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return {
|
|
2114
|
-
prefix: paths[0].slice(0, i),
|
|
2115
|
-
suffix: paths.map(path => path.slice(i)),
|
|
2116
|
-
};
|
|
2117
|
-
}
|
|
2118
|
-
$.$mol_diff_path = $mol_diff_path;
|
|
2119
|
-
})($ || ($ = {}));
|
|
2120
|
-
//path.js.map
|
|
2121
|
-
;
|
|
2122
|
-
"use strict";
|
|
2123
|
-
var $;
|
|
2124
|
-
(function ($) {
|
|
2125
|
-
class $mol_error_mix extends Error {
|
|
2126
|
-
errors;
|
|
2127
|
-
constructor(message, ...errors) {
|
|
2128
|
-
super(message);
|
|
2129
|
-
this.errors = errors;
|
|
2130
|
-
if (errors.length) {
|
|
2131
|
-
const stacks = [...errors.map(error => error.stack), this.stack];
|
|
2132
|
-
const diff = $.$mol_diff_path(...stacks.map(stack => {
|
|
2133
|
-
if (!stack)
|
|
2134
|
-
return [];
|
|
2135
|
-
return stack.split('\n').reverse();
|
|
2136
|
-
}));
|
|
2137
|
-
const head = diff.prefix.reverse().join('\n');
|
|
2138
|
-
const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
|
|
2139
|
-
this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
|
|
2140
|
-
this.message += errors.map(error => '\n' + error.message).join('');
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
toJSON() {
|
|
2144
|
-
return this.message;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
$.$mol_error_mix = $mol_error_mix;
|
|
2148
|
-
})($ || ($ = {}));
|
|
2149
|
-
//mix.js.map
|
|
2150
2039
|
|
|
2151
2040
|
//# sourceMappingURL=node.test.js.map
|