mol_data_all 1.1.152 → 1.1.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 -43
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +86 -43
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -792,7 +792,8 @@ var $;
|
|
|
792
792
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
793
793
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
794
794
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
795
|
-
$.$
|
|
795
|
+
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
796
|
+
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
796
797
|
},
|
|
797
798
|
'POJO'() {
|
|
798
799
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
@@ -833,8 +834,9 @@ var $;
|
|
|
833
834
|
},
|
|
834
835
|
'Map'() {
|
|
835
836
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
836
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
837
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
837
838
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
839
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
838
840
|
},
|
|
839
841
|
'Set'() {
|
|
840
842
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -865,8 +867,20 @@ var $;
|
|
|
865
867
|
return false;
|
|
866
868
|
if (typeof right !== 'object')
|
|
867
869
|
return false;
|
|
868
|
-
|
|
870
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
871
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
872
|
+
if (left_proto !== right_proto)
|
|
869
873
|
return false;
|
|
874
|
+
if (left instanceof Boolean)
|
|
875
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
876
|
+
if (left instanceof Number)
|
|
877
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
878
|
+
if (left instanceof String)
|
|
879
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
880
|
+
if (left instanceof Date)
|
|
881
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
882
|
+
if (left instanceof RegExp)
|
|
883
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
870
884
|
let left_cache = cache.get(left);
|
|
871
885
|
if (left_cache) {
|
|
872
886
|
const right_cache = left_cache.get(right);
|
|
@@ -874,56 +888,85 @@ var $;
|
|
|
874
888
|
return right_cache;
|
|
875
889
|
}
|
|
876
890
|
else {
|
|
877
|
-
left_cache = new WeakMap();
|
|
891
|
+
left_cache = new WeakMap([[right, true]]);
|
|
878
892
|
cache.set(left, left_cache);
|
|
879
|
-
left_cache.set(right, true);
|
|
880
893
|
}
|
|
881
|
-
if (left instanceof RegExp)
|
|
882
|
-
return left.toString() === right['toString']();
|
|
883
|
-
if (left instanceof Date)
|
|
884
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
885
894
|
let result;
|
|
886
895
|
try {
|
|
887
|
-
if (
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
}
|
|
900
|
-
return result = true;
|
|
901
|
-
}
|
|
902
|
-
if (left['constructor'] !== ({}).constructor)
|
|
903
|
-
return result = false;
|
|
904
|
-
let count = 0;
|
|
905
|
-
for (let key in left) {
|
|
906
|
-
try {
|
|
907
|
-
if (!$mol_compare_deep(left[key], right[key]))
|
|
908
|
-
return result = false;
|
|
909
|
-
}
|
|
910
|
-
catch (error) {
|
|
911
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${left} and ${right}`, error));
|
|
912
|
-
}
|
|
913
|
-
++count;
|
|
914
|
-
}
|
|
915
|
-
for (let key in right) {
|
|
916
|
-
--count;
|
|
917
|
-
if (count < 0)
|
|
918
|
-
return result = false;
|
|
919
|
-
}
|
|
920
|
-
return result = true;
|
|
896
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
897
|
+
result = compare_pojo(left, right);
|
|
898
|
+
else if (Array.isArray(left))
|
|
899
|
+
result = compare_array(left, right);
|
|
900
|
+
else if (left instanceof Set)
|
|
901
|
+
result = compare_set(left, right);
|
|
902
|
+
else if (left instanceof Map)
|
|
903
|
+
result = compare_map(left, right);
|
|
904
|
+
else if (ArrayBuffer.isView(left))
|
|
905
|
+
result = compare_buffer(left, right);
|
|
906
|
+
else
|
|
907
|
+
result = false;
|
|
921
908
|
}
|
|
922
909
|
finally {
|
|
923
910
|
left_cache.set(right, result);
|
|
924
911
|
}
|
|
912
|
+
return result;
|
|
925
913
|
}
|
|
926
914
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
915
|
+
function compare_array(left, right) {
|
|
916
|
+
const len = left.length;
|
|
917
|
+
if (len !== right.length)
|
|
918
|
+
return false;
|
|
919
|
+
for (let i = 0; i < len; ++i) {
|
|
920
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
921
|
+
return false;
|
|
922
|
+
}
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
function compare_buffer(left, right) {
|
|
926
|
+
const len = left.byteLength;
|
|
927
|
+
if (len !== right.byteLength)
|
|
928
|
+
return false;
|
|
929
|
+
for (let i = 0; i < len; ++i) {
|
|
930
|
+
if (left[i] !== right[i])
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
935
|
+
function compare_iterator(left, right, compare) {
|
|
936
|
+
while (true) {
|
|
937
|
+
const left_next = left.next();
|
|
938
|
+
const right_next = right.next();
|
|
939
|
+
if (left_next.done !== right_next.done)
|
|
940
|
+
return false;
|
|
941
|
+
if (left_next.done)
|
|
942
|
+
break;
|
|
943
|
+
if (!compare(left_next.value, right_next.value))
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
948
|
+
function compare_set(left, right) {
|
|
949
|
+
if (left.size !== right.size)
|
|
950
|
+
return false;
|
|
951
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
952
|
+
}
|
|
953
|
+
function compare_map(left, right) {
|
|
954
|
+
if (left.size !== right.size)
|
|
955
|
+
return false;
|
|
956
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
957
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
958
|
+
}
|
|
959
|
+
function compare_pojo(left, right) {
|
|
960
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
961
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
962
|
+
if (left_keys.length !== right_keys.length)
|
|
963
|
+
return false;
|
|
964
|
+
for (let key of left_keys) {
|
|
965
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
966
|
+
return false;
|
|
967
|
+
}
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
927
970
|
})($ || ($ = {}));
|
|
928
971
|
//deep.js.map
|
|
929
972
|
;
|