mol_data_all 1.1.152 → 1.1.156
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 +113 -43
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +113 -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));
|
|
@@ -846,6 +848,21 @@ var $;
|
|
|
846
848
|
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
847
849
|
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
848
850
|
},
|
|
851
|
+
'Custom comparator'() {
|
|
852
|
+
class User {
|
|
853
|
+
name;
|
|
854
|
+
rand;
|
|
855
|
+
constructor(name, rand = Math.random()) {
|
|
856
|
+
this.name = name;
|
|
857
|
+
this.rand = rand;
|
|
858
|
+
}
|
|
859
|
+
[Symbol.toPrimitive](mode) {
|
|
860
|
+
return this.name;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
$.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
864
|
+
$.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
|
|
865
|
+
},
|
|
849
866
|
});
|
|
850
867
|
})($ || ($ = {}));
|
|
851
868
|
//deep.test.js.map
|
|
@@ -865,8 +882,20 @@ var $;
|
|
|
865
882
|
return false;
|
|
866
883
|
if (typeof right !== 'object')
|
|
867
884
|
return false;
|
|
868
|
-
|
|
885
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
886
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
887
|
+
if (left_proto !== right_proto)
|
|
869
888
|
return false;
|
|
889
|
+
if (left instanceof Boolean)
|
|
890
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
891
|
+
if (left instanceof Number)
|
|
892
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
893
|
+
if (left instanceof String)
|
|
894
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
895
|
+
if (left instanceof Date)
|
|
896
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
897
|
+
if (left instanceof RegExp)
|
|
898
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
870
899
|
let left_cache = cache.get(left);
|
|
871
900
|
if (left_cache) {
|
|
872
901
|
const right_cache = left_cache.get(right);
|
|
@@ -874,56 +903,90 @@ var $;
|
|
|
874
903
|
return right_cache;
|
|
875
904
|
}
|
|
876
905
|
else {
|
|
877
|
-
left_cache = new WeakMap();
|
|
906
|
+
left_cache = new WeakMap([[right, true]]);
|
|
878
907
|
cache.set(left, left_cache);
|
|
879
|
-
left_cache.set(right, true);
|
|
880
908
|
}
|
|
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
909
|
let result;
|
|
886
910
|
try {
|
|
887
|
-
if (
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
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;
|
|
911
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
912
|
+
result = compare_pojo(left, right);
|
|
913
|
+
else if (Array.isArray(left))
|
|
914
|
+
result = compare_array(left, right);
|
|
915
|
+
else if (left instanceof Set)
|
|
916
|
+
result = compare_set(left, right);
|
|
917
|
+
else if (left instanceof Map)
|
|
918
|
+
result = compare_map(left, right);
|
|
919
|
+
else if (ArrayBuffer.isView(left))
|
|
920
|
+
result = compare_buffer(left, right);
|
|
921
|
+
else if (Symbol.toPrimitive in left)
|
|
922
|
+
result = compare_primitive(left, right);
|
|
923
|
+
else
|
|
924
|
+
result = false;
|
|
921
925
|
}
|
|
922
926
|
finally {
|
|
923
927
|
left_cache.set(right, result);
|
|
924
928
|
}
|
|
929
|
+
return result;
|
|
925
930
|
}
|
|
926
931
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
932
|
+
function compare_array(left, right) {
|
|
933
|
+
const len = left.length;
|
|
934
|
+
if (len !== right.length)
|
|
935
|
+
return false;
|
|
936
|
+
for (let i = 0; i < len; ++i) {
|
|
937
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
938
|
+
return false;
|
|
939
|
+
}
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
function compare_buffer(left, right) {
|
|
943
|
+
const len = left.byteLength;
|
|
944
|
+
if (len !== right.byteLength)
|
|
945
|
+
return false;
|
|
946
|
+
for (let i = 0; i < len; ++i) {
|
|
947
|
+
if (left[i] !== right[i])
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
return true;
|
|
951
|
+
}
|
|
952
|
+
function compare_iterator(left, right, compare) {
|
|
953
|
+
while (true) {
|
|
954
|
+
const left_next = left.next();
|
|
955
|
+
const right_next = right.next();
|
|
956
|
+
if (left_next.done !== right_next.done)
|
|
957
|
+
return false;
|
|
958
|
+
if (left_next.done)
|
|
959
|
+
break;
|
|
960
|
+
if (!compare(left_next.value, right_next.value))
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
return true;
|
|
964
|
+
}
|
|
965
|
+
function compare_set(left, right) {
|
|
966
|
+
if (left.size !== right.size)
|
|
967
|
+
return false;
|
|
968
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
969
|
+
}
|
|
970
|
+
function compare_map(left, right) {
|
|
971
|
+
if (left.size !== right.size)
|
|
972
|
+
return false;
|
|
973
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
974
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
975
|
+
}
|
|
976
|
+
function compare_pojo(left, right) {
|
|
977
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
978
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
979
|
+
if (left_keys.length !== right_keys.length)
|
|
980
|
+
return false;
|
|
981
|
+
for (let key of left_keys) {
|
|
982
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
983
|
+
return false;
|
|
984
|
+
}
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
function compare_primitive(left, right) {
|
|
988
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
989
|
+
}
|
|
927
990
|
})($ || ($ = {}));
|
|
928
991
|
//deep.js.map
|
|
929
992
|
;
|
|
@@ -1519,6 +1582,10 @@ var $;
|
|
|
1519
1582
|
'format typed'() {
|
|
1520
1583
|
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1521
1584
|
},
|
|
1585
|
+
'comparison'() {
|
|
1586
|
+
const iso = 'P1Y1M1DT1h1m1s';
|
|
1587
|
+
$.$mol_assert_like(new $.$mol_time_duration(iso), new $.$mol_time_duration(iso));
|
|
1588
|
+
},
|
|
1522
1589
|
});
|
|
1523
1590
|
})($ || ($ = {}));
|
|
1524
1591
|
//duration.test.js.map
|
|
@@ -1618,6 +1685,9 @@ var $;
|
|
|
1618
1685
|
toString(pattern = 'P#Y#M#DT#h#m#s') {
|
|
1619
1686
|
return super.toString(pattern);
|
|
1620
1687
|
}
|
|
1688
|
+
[Symbol.toPrimitive](mode) {
|
|
1689
|
+
return mode === 'number' ? this.valueOf() : this.toString();
|
|
1690
|
+
}
|
|
1621
1691
|
static patterns = {
|
|
1622
1692
|
'#Y': (duration) => {
|
|
1623
1693
|
if (!duration.year)
|