mol_crypto_lib 0.0.655 → 0.0.657

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 CHANGED
@@ -1517,7 +1517,9 @@ var $;
1517
1517
  }
1518
1518
  let result;
1519
1519
  try {
1520
- if (left_proto && !Reflect.getPrototypeOf(left_proto))
1520
+ if (!left_proto)
1521
+ result = compare_pojo(left, right);
1522
+ else if (!Reflect.getPrototypeOf(left_proto))
1521
1523
  result = compare_pojo(left, right);
1522
1524
  else if (Array.isArray(left))
1523
1525
  result = compare_array(left, right);
@@ -1585,10 +1587,18 @@ var $;
1585
1587
  function compare_pojo(left, right) {
1586
1588
  const left_keys = Object.getOwnPropertyNames(left);
1587
1589
  const right_keys = Object.getOwnPropertyNames(right);
1588
- if (left_keys.length !== right_keys.length)
1590
+ if (!compare_array(left_keys, right_keys))
1589
1591
  return false;
1590
1592
  for (let key of left_keys) {
1591
- if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
1593
+ if (!$mol_compare_deep(left[key], right[key]))
1594
+ return false;
1595
+ }
1596
+ const left_syms = Object.getOwnPropertySymbols(left);
1597
+ const right_syms = Object.getOwnPropertySymbols(right);
1598
+ if (!compare_array(left_syms, right_syms))
1599
+ return false;
1600
+ for (let key of left_syms) {
1601
+ if (!$mol_compare_deep(left[key], right[key]))
1592
1602
  return false;
1593
1603
  }
1594
1604
  return true;
@@ -1621,8 +1631,9 @@ var $;
1621
1631
  $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
1622
1632
  $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
1623
1633
  $mol_assert_not($mol_compare_deep({}, { a: undefined }));
1624
- $mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
1634
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
1625
1635
  $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
1636
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
1626
1637
  },
1627
1638
  'Array'() {
1628
1639
  $mol_assert_ok($mol_compare_deep([], []));
@@ -1637,6 +1648,11 @@ var $;
1637
1648
  $mol_assert_not($mol_compare_deep(() => 1, () => 1));
1638
1649
  $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
1639
1650
  },
1651
+ 'POJO with symbols'() {
1652
+ const sym = Symbol();
1653
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
1654
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
1655
+ },
1640
1656
  'same POJOs with cyclic reference'() {
1641
1657
  const a = { foo: {} };
1642
1658
  a['self'] = a;