mol_tree2 1.0.237 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_tree2",
3
- "version": "1.0.237",
3
+ "version": "1.0.238",
4
4
  "exports": {
5
5
  "node": {
6
6
  "import": "./node.mjs",
package/web.test.js CHANGED
@@ -433,7 +433,9 @@ var $;
433
433
  }
434
434
  let result;
435
435
  try {
436
- if (left_proto && !Reflect.getPrototypeOf(left_proto))
436
+ if (!left_proto)
437
+ result = compare_pojo(left, right);
438
+ else if (!Reflect.getPrototypeOf(left_proto))
437
439
  result = compare_pojo(left, right);
438
440
  else if (Array.isArray(left))
439
441
  result = compare_array(left, right);
@@ -501,10 +503,18 @@ var $;
501
503
  function compare_pojo(left, right) {
502
504
  const left_keys = Object.getOwnPropertyNames(left);
503
505
  const right_keys = Object.getOwnPropertyNames(right);
504
- if (left_keys.length !== right_keys.length)
506
+ if (!compare_array(left_keys, right_keys))
505
507
  return false;
506
508
  for (let key of left_keys) {
507
- if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
509
+ if (!$mol_compare_deep(left[key], right[key]))
510
+ return false;
511
+ }
512
+ const left_syms = Object.getOwnPropertySymbols(left);
513
+ const right_syms = Object.getOwnPropertySymbols(right);
514
+ if (!compare_array(left_syms, right_syms))
515
+ return false;
516
+ for (let key of left_syms) {
517
+ if (!$mol_compare_deep(left[key], right[key]))
508
518
  return false;
509
519
  }
510
520
  return true;
@@ -537,8 +547,9 @@ var $;
537
547
  $mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
538
548
  $mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
539
549
  $mol_assert_not($mol_compare_deep({}, { a: undefined }));
540
- $mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
550
+ $mol_assert_not($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
541
551
  $mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
552
+ $mol_assert_ok($mol_compare_deep(Object.create(null), Object.create(null)));
542
553
  },
543
554
  'Array'() {
544
555
  $mol_assert_ok($mol_compare_deep([], []));
@@ -553,6 +564,11 @@ var $;
553
564
  $mol_assert_not($mol_compare_deep(() => 1, () => 1));
554
565
  $mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
555
566
  },
567
+ 'POJO with symbols'() {
568
+ const sym = Symbol();
569
+ $mol_assert_ok($mol_compare_deep({ [sym]: true }, { [sym]: true }));
570
+ $mol_assert_not($mol_compare_deep({ [Symbol()]: true }, { [Symbol()]: true }));
571
+ },
556
572
  'same POJOs with cyclic reference'() {
557
573
  const a = { foo: {} };
558
574
  a['self'] = a;