mol_tree2 1.0.236 → 1.0.238
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 +20 -4
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +20 -4
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1952,7 +1952,9 @@ var $;
|
|
|
1952
1952
|
}
|
|
1953
1953
|
let result;
|
|
1954
1954
|
try {
|
|
1955
|
-
if (
|
|
1955
|
+
if (!left_proto)
|
|
1956
|
+
result = compare_pojo(left, right);
|
|
1957
|
+
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1956
1958
|
result = compare_pojo(left, right);
|
|
1957
1959
|
else if (Array.isArray(left))
|
|
1958
1960
|
result = compare_array(left, right);
|
|
@@ -2020,10 +2022,18 @@ var $;
|
|
|
2020
2022
|
function compare_pojo(left, right) {
|
|
2021
2023
|
const left_keys = Object.getOwnPropertyNames(left);
|
|
2022
2024
|
const right_keys = Object.getOwnPropertyNames(right);
|
|
2023
|
-
if (left_keys
|
|
2025
|
+
if (!compare_array(left_keys, right_keys))
|
|
2024
2026
|
return false;
|
|
2025
2027
|
for (let key of left_keys) {
|
|
2026
|
-
if (!$mol_compare_deep(left[key],
|
|
2028
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
2029
|
+
return false;
|
|
2030
|
+
}
|
|
2031
|
+
const left_syms = Object.getOwnPropertySymbols(left);
|
|
2032
|
+
const right_syms = Object.getOwnPropertySymbols(right);
|
|
2033
|
+
if (!compare_array(left_syms, right_syms))
|
|
2034
|
+
return false;
|
|
2035
|
+
for (let key of left_syms) {
|
|
2036
|
+
if (!$mol_compare_deep(left[key], right[key]))
|
|
2027
2037
|
return false;
|
|
2028
2038
|
}
|
|
2029
2039
|
return true;
|
|
@@ -2056,8 +2066,9 @@ var $;
|
|
|
2056
2066
|
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
2057
2067
|
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
2058
2068
|
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
2059
|
-
$
|
|
2069
|
+
$mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
2060
2070
|
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
2071
|
+
$mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
|
|
2061
2072
|
},
|
|
2062
2073
|
'Array'() {
|
|
2063
2074
|
$mol_assert_ok($mol_compare_deep([], []));
|
|
@@ -2072,6 +2083,11 @@ var $;
|
|
|
2072
2083
|
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
2073
2084
|
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
2074
2085
|
},
|
|
2086
|
+
'POJO with symbols'() {
|
|
2087
|
+
const sym = Symbol();
|
|
2088
|
+
$mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
|
|
2089
|
+
$mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
|
|
2090
|
+
},
|
|
2075
2091
|
'same POJOs with cyclic reference'() {
|
|
2076
2092
|
const a = { foo: {} };
|
|
2077
2093
|
a['self'] = a;
|