mol_db 0.0.594 → 0.0.595

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
@@ -1467,7 +1467,9 @@ var $;
1467
1467
  }
1468
1468
  let result;
1469
1469
  try {
1470
- if (left_proto && !Reflect.getPrototypeOf(left_proto))
1470
+ if (!left_proto)
1471
+ result = compare_pojo(left, right);
1472
+ else if (!Reflect.getPrototypeOf(left_proto))
1471
1473
  result = compare_pojo(left, right);
1472
1474
  else if (Array.isArray(left))
1473
1475
  result = compare_array(left, right);
@@ -1535,10 +1537,18 @@ var $;
1535
1537
  function compare_pojo(left, right) {
1536
1538
  const left_keys = Object.getOwnPropertyNames(left);
1537
1539
  const right_keys = Object.getOwnPropertyNames(right);
1538
- if (left_keys.length !== right_keys.length)
1540
+ if (!compare_array(left_keys, right_keys))
1539
1541
  return false;
1540
1542
  for (let key of left_keys) {
1541
- if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
1543
+ if (!$mol_compare_deep(left[key], right[key]))
1544
+ return false;
1545
+ }
1546
+ const left_syms = Object.getOwnPropertySymbols(left);
1547
+ const right_syms = Object.getOwnPropertySymbols(right);
1548
+ if (!compare_array(left_syms, right_syms))
1549
+ return false;
1550
+ for (let key of left_syms) {
1551
+ if (!$mol_compare_deep(left[key], right[key]))
1542
1552
  return false;
1543
1553
  }
1544
1554
  return true;
@@ -1571,8 +1581,9 @@ var $;
1571
1581
  $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
1572
1582
  $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
1573
1583
  $mol_assert_not($mol_compare_deep({}, { a: undefined }));
1574
- $mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
1584
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
1575
1585
  $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
1586
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
1576
1587
  },
1577
1588
  'Array'() {
1578
1589
  $mol_assert_ok($mol_compare_deep([], []));
@@ -1587,6 +1598,11 @@ var $;
1587
1598
  $mol_assert_not($mol_compare_deep(() => 1, () => 1));
1588
1599
  $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
1589
1600
  },
1601
+ 'POJO with symbols'() {
1602
+ const sym = Symbol();
1603
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
1604
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
1605
+ },
1590
1606
  'same POJOs with cyclic reference'() {
1591
1607
  const a = { foo: {} };
1592
1608
  a['self'] = a;