mol_regexp 0.0.204 → 0.0.205

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
@@ -757,6 +757,21 @@ var $;
757
757
  $.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
758
758
  $.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
759
759
  },
760
+ 'Custom comparator'() {
761
+ class User {
762
+ name;
763
+ rand;
764
+ constructor(name, rand = Math.random()) {
765
+ this.name = name;
766
+ this.rand = rand;
767
+ }
768
+ [Symbol.toPrimitive](mode) {
769
+ return this.name;
770
+ }
771
+ }
772
+ $.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
773
+ $.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
774
+ },
760
775
  });
761
776
  })($ || ($ = {}));
762
777
  //deep.test.js.map
@@ -812,6 +827,8 @@ var $;
812
827
  result = compare_map(left, right);
813
828
  else if (ArrayBuffer.isView(left))
814
829
  result = compare_buffer(left, right);
830
+ else if (Symbol.toPrimitive in left)
831
+ result = compare_primitive(left, right);
815
832
  else
816
833
  result = false;
817
834
  }
@@ -876,6 +893,9 @@ var $;
876
893
  }
877
894
  return true;
878
895
  }
896
+ function compare_primitive(left, right) {
897
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
898
+ }
879
899
  })($ || ($ = {}));
880
900
  //deep.js.map
881
901
  ;