mol_schema 0.0.23 → 0.0.25

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/web.mjs CHANGED
@@ -81,34 +81,36 @@ var $;
81
81
  static toString() {
82
82
  return $$.$mol_func_name(this);
83
83
  }
84
- /** Type-guard that checks value by schema. */
85
- static check(val) {
84
+ /** Type-predicate that checks value by schema. */
85
+ static check(value) {
86
86
  try {
87
- this.guard(val);
87
+ this.guard(value);
88
88
  return true;
89
89
  }
90
90
  catch (error) {
91
91
  return false;
92
92
  }
93
93
  }
94
- static [Symbol.hasInstance](val) {
95
- return this.check(val);
94
+ /** `instanceof` support */
95
+ static [Symbol.hasInstance](value) {
96
+ return this.check(value);
96
97
  }
97
- /** Strict parse. Fails of wrong values. */
98
+ /** Type-parser that fails of wrong values. */
98
99
  static guard(value) {
99
100
  return value;
100
101
  }
101
- /** Relaxed cast. Normalizes wrong values. */
102
+ /** Type-caster that normalizes wrong values. */
102
103
  static cast(value) {
103
104
  try {
104
- return this.guard(value);
105
+ this.guard(value);
106
+ return value;
105
107
  }
106
108
  catch (error) {
107
109
  return this.default;
108
110
  }
109
111
  }
110
112
  /** Default value which conforms schema. */
111
- static default = undefined;
113
+ static default = null;
112
114
  }
113
115
  $.$mol_schema_any = $mol_schema_any;
114
116
  })($ || ($ = {}));
@@ -568,7 +570,7 @@ var $;
568
570
  "use strict";
569
571
  var $;
570
572
  (function ($) {
571
- $.$mol_schema_instance = $mol_memo_key.func(function $mol_schema_instance(Class, ...args) {
573
+ $.$mol_schema_instance = $mol_memo_key.func(function $mol_schema_instance(Class) {
572
574
  class $mol_schema_instance_ extends $mol_schema_any {
573
575
  static Class = Class;
574
576
  static toString() {
@@ -581,9 +583,12 @@ var $;
581
583
  return value;
582
584
  return $mol_fail(new TypeError('Wrong class', { cause: { value, schema: this } }));
583
585
  }
584
- static default = new Class(...args);
586
+ static cast(value) {
587
+ return this.guard(value);
588
+ }
589
+ static default;
585
590
  }
586
- return ((Class[Symbol.hasInstance] === $mol_schema_any[Symbol.hasInstance])
591
+ return ((Class?.[Symbol.hasInstance] === $mol_schema_any[Symbol.hasInstance])
587
592
  ? Class
588
593
  : $mol_schema_instance_);
589
594
  });
@@ -591,31 +596,59 @@ var $;
591
596
 
592
597
  ;
593
598
  "use strict";
599
+ var $;
600
+ (function ($) {
601
+ function $mol_schema_lazy(Schema) {
602
+ // return $mol_delegate( $mol_schema_any, Schema )
603
+ return class $mol_schema_lazy_ extends $mol_schema_any {
604
+ static Schema = $mol_memo.func(Schema);
605
+ static guard(value) {
606
+ return this.Schema().guard(value);
607
+ }
608
+ static cast(value) {
609
+ return this.Schema().cast(value);
610
+ }
611
+ static get default() {
612
+ return this.Schema().default;
613
+ }
614
+ };
615
+ }
616
+ $.$mol_schema_lazy = $mol_schema_lazy;
617
+ })($ || ($ = {}));
594
618
 
595
619
  ;
596
620
  "use strict";
597
621
  var $;
598
622
  (function ($) {
599
- $.$mol_schema_every = $mol_memo_key.func(function $mol_schema_every(Schemas) {
600
- return class $mol_schema_every_ extends $mol_schema_any {
601
- static Schemas = Schemas;
623
+ $.$mol_schema_some = $mol_memo_key.func(function $mol_schema_some(Variants) {
624
+ return class $mol_schema_some_ extends $mol_schema_any {
625
+ static Variants = Variants;
602
626
  static toString() {
603
- if (this !== $mol_schema_every_)
627
+ if (this !== $mol_schema_some_)
604
628
  return super.toString();
605
- return '$mol_schema_every<' + $mol_key(Schemas) + '>';
629
+ return '$mol_schema_some<' + $mol_key(Variants) + '>';
606
630
  }
607
631
  static guard(value) {
608
- for (const Schema of Schemas) {
609
- Schema.guard(value);
632
+ const errors = [];
633
+ for (const Variant of Variants) {
634
+ try {
635
+ return Variant.guard(value);
636
+ }
637
+ catch (error) {
638
+ errors.push(error);
639
+ }
610
640
  }
611
- return value;
641
+ return $mol_fail(new AggregateError(errors, 'Wrong variant', { cause: { value, schema: this } }));
612
642
  }
613
643
  static cast(value) {
614
- for (const Scheme of Schemas)
615
- value = Scheme.cast(value);
616
- return value;
644
+ try {
645
+ return this.guard(value);
646
+ }
647
+ catch (error) {
648
+ return Variants[0].cast(value);
649
+ }
617
650
  }
618
- static default = Schemas.find(Scheme => this.check(Scheme.default));
651
+ static default = Variants[0].default;
619
652
  };
620
653
  });
621
654
  })($ || ($ = {}));
@@ -624,56 +657,50 @@ var $;
624
657
  "use strict";
625
658
  var $;
626
659
  (function ($) {
627
- $.$mol_schema_range = $mol_memo_key.func(function $mol_schema_range(Range) {
628
- return class $mol_schema_range_ extends $mol_schema_any {
629
- static Range = Range;
660
+ $.$mol_schema_dict = $mol_memo_key.func(function $mol_schema_dict(Pair) {
661
+ return class $mol_schema_dict_ extends $mol_schema_any {
662
+ static Pair = Pair;
630
663
  static toString() {
631
- if (this !== $mol_schema_range_)
664
+ if (this !== $mol_schema_dict_)
632
665
  return super.toString();
633
- return '$mol_schema_range<' + $mol_key(Range) + '>';
666
+ return '$mol_schema_dict<' + $mol_key(Pair) + '>';
634
667
  }
635
668
  static guard(value) {
636
- if (typeof value !== 'number' && typeof value !== 'bigint')
637
- return $mol_fail(new TypeError('Uncomparable type', { cause: { value, schema: this } }));
638
- if (!(value <= Range[1]))
639
- return $mol_fail(new TypeError('Too large', { cause: { value, schema: this } }));
640
- if (!(value >= Range[0]))
641
- return $mol_fail(new TypeError('Too small', { cause: { value, schema: this } }));
669
+ if (Object.getPrototypeOf(Object.getPrototypeOf(value))) {
670
+ return $mol_fail(new TypeError('Non dictionary', { cause: { value, schema: this } }));
671
+ }
672
+ for (const key in value) {
673
+ try {
674
+ Pair[0].guard(key);
675
+ }
676
+ catch (error) {
677
+ return $mol_fail(new TypeError('Wrong key', { cause: { key, error, value, schema: this } }));
678
+ }
679
+ try {
680
+ Pair[1].guard(value[key]);
681
+ }
682
+ catch (error) {
683
+ return $mol_fail(new TypeError('Wrong val', { cause: { key, error, value, schema: this } }));
684
+ }
685
+ }
642
686
  return value;
643
687
  }
644
- static cast(val) {
645
- if (val > Range[1])
646
- return Range[1];
647
- if (val >= Range[0])
648
- return val;
649
- return Range[0];
688
+ static cast(value) {
689
+ if (Object.getPrototypeOf(Object.getPrototypeOf(value)))
690
+ return this.default;
691
+ const res = {};
692
+ for (const key in value) {
693
+ if (!Pair[0].check(key))
694
+ continue;
695
+ res[key] = Pair[1].cast(value[key]);
696
+ }
697
+ return res;
650
698
  }
651
- static default = Range[0];
699
+ static default = {};
652
700
  };
653
701
  });
654
702
  })($ || ($ = {}));
655
703
 
656
- ;
657
- "use strict";
658
- var $;
659
- (function ($) {
660
- class $mol_schema_positive extends $mol_schema_range([0, Number.POSITIVE_INFINITY]) {
661
- }
662
- $.$mol_schema_positive = $mol_schema_positive;
663
- })($ || ($ = {}));
664
-
665
- ;
666
- "use strict";
667
- var $;
668
- (function ($) {
669
- class $mol_schema_natural extends $mol_schema_every([
670
- $mol_schema_integer,
671
- $mol_schema_positive,
672
- ]) {
673
- }
674
- $.$mol_schema_natural = $mol_schema_natural;
675
- })($ || ($ = {}));
676
-
677
704
  ;
678
705
  "use strict";
679
706
  var $;
@@ -689,11 +716,11 @@ var $;
689
716
  static guard(value) {
690
717
  if (Options.some(Option => Object.is(Option, value)))
691
718
  return value;
692
- return $mol_fail(new TypeError('No one option', { cause: { value, schema: this } }));
719
+ return $mol_fail(new TypeError('Wrong option', { cause: { value, schema: this } }));
693
720
  }
694
- static cast(val) {
695
- if (this.check(val))
696
- return val;
721
+ static cast(value) {
722
+ if (this.check(value))
723
+ return value;
697
724
  return Options[0];
698
725
  }
699
726
  static default = Options[0];
@@ -705,44 +732,33 @@ var $;
705
732
  "use strict";
706
733
  var $;
707
734
  (function ($) {
708
- class $mol_schema_negative extends $mol_schema_range([Number.NEGATIVE_INFINITY, 0]) {
709
- }
710
- $.$mol_schema_negative = $mol_schema_negative;
711
- })($ || ($ = {}));
712
-
713
- ;
714
- "use strict";
715
- var $;
716
- (function ($) {
717
- $.$mol_schema_some = $mol_memo_key.func(function $mol_schema_some(Variants) {
718
- return class $mol_schema_some_ extends $mol_schema_any {
719
- static Variants = Variants;
735
+ $.$mol_schema_list = $mol_memo_key.func(function $mol_schema_list(Item) {
736
+ return class $mol_schema_list_ extends $mol_schema_any {
737
+ static Item = Item;
720
738
  static toString() {
721
- if (this !== $mol_schema_some_)
739
+ if (this !== $mol_schema_list_)
722
740
  return super.toString();
723
- return '$mol_schema_some<' + $mol_key(Variants) + '>';
741
+ return '$mol_schema_list<' + $mol_key(Item) + '>';
724
742
  }
725
743
  static guard(value) {
726
- const errors = [];
727
- for (const Variant of Variants) {
744
+ if (!Array.isArray(value))
745
+ return $mol_fail(new TypeError('Non array', { cause: { value, schema: this } }));
746
+ for (const [index, item] of super.guard(value).entries()) {
728
747
  try {
729
- return Variant.guard(value);
748
+ Item.guard(item);
730
749
  }
731
750
  catch (error) {
732
- errors.push(error);
751
+ return $mol_fail(new TypeError('Wrong item', { cause: { index, error, value, schema: this } }));
733
752
  }
734
753
  }
735
- return $mol_fail(new AggregateError(errors, 'No one variant', { cause: { value, schema: this } }));
754
+ return value;
736
755
  }
737
756
  static cast(value) {
738
- try {
739
- return this.guard(value);
740
- }
741
- catch (error) {
742
- return Variants[0].cast(value);
743
- }
757
+ if (!Array.isArray(value))
758
+ return this.default;
759
+ return value.map(item => Item.cast(item));
744
760
  }
745
- static default = Variants[0].default;
761
+ static default = [];
746
762
  };
747
763
  });
748
764
  })($ || ($ = {}));
@@ -751,14 +767,43 @@ var $;
751
767
  "use strict";
752
768
  var $;
753
769
  (function ($) {
754
- $.$mol_schema_maybe = $mol_memo_key.func(function $mol_schema_maybe(Some) {
755
- return class $mol_schema_maybe_ extends $mol_schema_some([$mol_schema_enum([undefined, null]), Some]) {
756
- static Some = Some;
770
+ class $mol_schema_json extends $mol_schema_lazy(() => $mol_schema_some([
771
+ $mol_schema_dict([$mol_schema_string, $mol_schema_json]),
772
+ $mol_schema_enum([null]),
773
+ $mol_schema_boolean, $mol_schema_float, $mol_schema_string,
774
+ $mol_schema_list($mol_schema_json),
775
+ ])) {
776
+ }
777
+ $.$mol_schema_json = $mol_schema_json;
778
+ })($ || ($ = {}));
779
+
780
+ ;
781
+ "use strict";
782
+
783
+ ;
784
+ "use strict";
785
+ var $;
786
+ (function ($) {
787
+ $.$mol_schema_every = $mol_memo_key.func(function $mol_schema_every(Schemas) {
788
+ return class $mol_schema_every_ extends $mol_schema_any {
789
+ static Schemas = Schemas;
757
790
  static toString() {
758
- if (this !== $mol_schema_maybe_)
791
+ if (this !== $mol_schema_every_)
759
792
  return super.toString();
760
- return '$mol_schema_maybe<' + $mol_key(Some) + '>';
793
+ return '$mol_schema_every<' + $mol_key(Schemas) + '>';
761
794
  }
795
+ static guard(value) {
796
+ for (const Schema of Schemas) {
797
+ Schema.guard(value);
798
+ }
799
+ return value;
800
+ }
801
+ static cast(value) {
802
+ for (const Scheme of Schemas)
803
+ value = Scheme.cast(value);
804
+ return value;
805
+ }
806
+ static default = Schemas.find(Scheme => this.check(Scheme.default));
762
807
  };
763
808
  });
764
809
  })($ || ($ = {}));
@@ -767,33 +812,31 @@ var $;
767
812
  "use strict";
768
813
  var $;
769
814
  (function ($) {
770
- $.$mol_schema_list = $mol_memo_key.func(function $mol_schema_list(Item) {
771
- return class $mol_schema_list_ extends $mol_schema_any {
772
- static Item = Item;
815
+ $.$mol_schema_range = $mol_memo_key.func(function $mol_schema_range(Range) {
816
+ return class $mol_schema_range_ extends $mol_schema_any {
817
+ static Range = Range;
773
818
  static toString() {
774
- if (this !== $mol_schema_list_)
819
+ if (this !== $mol_schema_range_)
775
820
  return super.toString();
776
- return '$mol_schema_list<' + $mol_key(Item) + '>';
821
+ return '$mol_schema_range<' + $mol_key(Range) + '>';
777
822
  }
778
823
  static guard(value) {
779
- if (!Array.isArray(value))
780
- return $mol_fail(new TypeError('Non array', { cause: { value, schema: this } }));
781
- for (const [index, item] of super.guard(value).entries()) {
782
- try {
783
- Item.guard(item);
784
- }
785
- catch (error) {
786
- return $mol_fail(new TypeError('Wrong item', { cause: { index, error, value, schema: this } }));
787
- }
788
- }
824
+ if (typeof value !== 'number' && typeof value !== 'bigint')
825
+ return $mol_fail(new TypeError('Uncomparable type', { cause: { value, schema: this } }));
826
+ if (!(value <= Range[1]))
827
+ return $mol_fail(new TypeError('Too large', { cause: { value, schema: this } }));
828
+ if (!(value >= Range[0]))
829
+ return $mol_fail(new TypeError('Too small', { cause: { value, schema: this } }));
789
830
  return value;
790
831
  }
791
832
  static cast(value) {
792
- if (!Array.isArray(value))
793
- return this.default;
794
- return value.map(item => Item.cast(item));
833
+ if (value > Range[1])
834
+ return Range[1];
835
+ if (value >= Range[0])
836
+ return value;
837
+ return Range[0];
795
838
  }
796
- static default = [];
839
+ static default = Range[0];
797
840
  };
798
841
  });
799
842
  })($ || ($ = {}));
@@ -802,46 +845,50 @@ var $;
802
845
  "use strict";
803
846
  var $;
804
847
  (function ($) {
805
- $.$mol_schema_dict = $mol_memo_key.func(function $mol_schema_dict(Pair) {
806
- return class $mol_schema_dict_ extends $mol_schema_any {
807
- static Pair = Pair;
848
+ class $mol_schema_positive extends $mol_schema_range([0, Number.POSITIVE_INFINITY]) {
849
+ }
850
+ $.$mol_schema_positive = $mol_schema_positive;
851
+ })($ || ($ = {}));
852
+
853
+ ;
854
+ "use strict";
855
+ var $;
856
+ (function ($) {
857
+ class $mol_schema_natural extends $mol_schema_every([
858
+ $mol_schema_integer,
859
+ $mol_schema_positive,
860
+ ]) {
861
+ }
862
+ $.$mol_schema_natural = $mol_schema_natural;
863
+ })($ || ($ = {}));
864
+
865
+ ;
866
+ "use strict";
867
+ var $;
868
+ (function ($) {
869
+ class $mol_schema_negative extends $mol_schema_range([Number.NEGATIVE_INFINITY, 0]) {
870
+ }
871
+ $.$mol_schema_negative = $mol_schema_negative;
872
+ })($ || ($ = {}));
873
+
874
+ ;
875
+ "use strict";
876
+ var $;
877
+ (function ($) {
878
+ $.$mol_schema_maybe = $mol_memo_key.func(function $mol_schema_maybe(Some) {
879
+ return class $mol_schema_maybe_ extends $mol_schema_any {
880
+ static Some = Some;
808
881
  static toString() {
809
- if (this !== $mol_schema_dict_)
882
+ if (this !== $mol_schema_maybe_)
810
883
  return super.toString();
811
- return '$mol_schema_dict<' + $mol_key(Pair) + '>';
884
+ return '$mol_schema_maybe<' + $mol_key(Some) + '>';
812
885
  }
813
886
  static guard(value) {
814
- if (Object.getPrototypeOf(Object.getPrototypeOf(value))) {
815
- return $mol_fail(new TypeError('Non dictionary', { cause: { value, schema: this } }));
816
- }
817
- for (const key in value) {
818
- try {
819
- Pair[0].guard(key);
820
- }
821
- catch (error) {
822
- return $mol_fail(new TypeError('Wrong key', { cause: { key, error, value, schema: this } }));
823
- }
824
- try {
825
- Pair[1].guard(value[key]);
826
- }
827
- catch (error) {
828
- return $mol_fail(new TypeError('Wrong val', { cause: { key, error, value, schema: this } }));
829
- }
830
- }
831
- return value;
832
- }
833
- static cast(value) {
834
- if (Object.getPrototypeOf(Object.getPrototypeOf(value)))
835
- return this.default;
836
- const res = {};
837
- for (const key in value) {
838
- if (!Pair[0].check(key))
839
- continue;
840
- res[key] = Pair[1].cast(value[key]);
841
- }
842
- return res;
887
+ if (value == null)
888
+ return value;
889
+ return Some.guard(value);
843
890
  }
844
- static default = {};
891
+ static default = null;
845
892
  };
846
893
  });
847
894
  })($ || ($ = {}));
package/web.test.js CHANGED
@@ -1152,12 +1152,18 @@ var $;
1152
1152
  'color': 'gray',
1153
1153
  });
1154
1154
  $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
1155
- 'margin-left': '13px'
1155
+ 'margin-inline-start': '13px'
1156
1156
  });
1157
1157
  class Stack extends Array {
1158
1158
  // [ Symbol.toPrimitive ]() {
1159
1159
  // return this.toString()
1160
1160
  // }
1161
+ match(...args) {
1162
+ return this.toString().match(...args);
1163
+ }
1164
+ split(...args) {
1165
+ return this.toString().split(...args);
1166
+ }
1161
1167
  toString() {
1162
1168
  return this.join('\n');
1163
1169
  }
@@ -1670,7 +1676,7 @@ var $;
1670
1676
  $mol_assert_equal(Config.cast('foo'), 'foo');
1671
1677
  $mol_assert_equal(Config.cast('bar'), 123);
1672
1678
  $mol_assert_equal(123, Config.guard(123));
1673
- $mol_assert_fail(() => Config.guard(321), 'No one option');
1679
+ $mol_assert_fail(() => Config.guard(321), 'Wrong option');
1674
1680
  },
1675
1681
  });
1676
1682
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -1739,7 +1745,7 @@ var $;
1739
1745
  $mol_assert_equal('foo', Config.cast('foo'));
1740
1746
  $mol_assert_equal(Number.NaN, Config.cast(true));
1741
1747
  $mol_assert_equal(123, Config.guard(123));
1742
- $mol_assert_fail(() => Config.guard(false), 'No one variant');
1748
+ $mol_assert_fail(() => Config.guard(false), 'Wrong variant');
1743
1749
  },
1744
1750
  });
1745
1751
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -1766,9 +1772,9 @@ var $;
1766
1772
  $mol_assert_equal('foo', Config.cast('foo'));
1767
1773
  $mol_assert_equal(undefined, Config.cast(undefined));
1768
1774
  $mol_assert_equal(null, Config.cast(null));
1769
- $mol_assert_equal(undefined, Config.cast(0));
1775
+ $mol_assert_equal(null, Config.cast(0));
1770
1776
  $mol_assert_equal('foo', Config.guard('foo'));
1771
- $mol_assert_fail(() => Config.guard(123), 'No one variant');
1777
+ $mol_assert_fail(() => Config.guard(123), 'Wrong type');
1772
1778
  },
1773
1779
  });
1774
1780
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -2030,7 +2036,7 @@ var $;
2030
2036
  });
2031
2037
  $mol_assert_equal(true, User.check({ name: 'foo', age: 123 }));
2032
2038
  $mol_assert_equal(true, User.check({ name: null }));
2033
- $mol_assert_equal({ name: 'foo', age: undefined }, User.cast({ name: 'foo', age: false }));
2039
+ $mol_assert_equal({ name: 'foo', age: null }, User.cast({ name: 'foo', age: false }));
2034
2040
  $mol_assert_equal({ name: 'foo', age: undefined }, User.guard({ name: 'foo', age: undefined }));
2035
2041
  $mol_assert_fail(() => User.guard({ name: 'foo', age: 'bar' }), 'Wrong field');
2036
2042
  },
@@ -2076,7 +2082,7 @@ var $;
2076
2082
  $mol_assert_equal(false, Blob.check(new Int8Array));
2077
2083
  $mol_assert_equal(false, Blob.check(null));
2078
2084
  $mol_assert_equal(new Uint8Array([0, 1]), Blob.cast(new Uint8Array([0, 1])));
2079
- $mol_assert_equal(new Uint8Array, Blob.cast(new Int8Array([1, -1])));
2085
+ $mol_assert_fail(() => Blob.cast(new Int8Array), 'Wrong class');
2080
2086
  $mol_assert_equal(new Uint8Array, Blob.guard(new Uint8Array));
2081
2087
  $mol_assert_fail(() => Blob.guard(new Int8Array), 'Wrong class');
2082
2088
  },
@@ -2098,6 +2104,55 @@ var $;
2098
2104
  })($$ = $_1.$$ || ($_1.$$ = {}));
2099
2105
  })($ || ($ = {}));
2100
2106
 
2107
+ ;
2108
+ "use strict";
2109
+ var $;
2110
+ (function ($_1) {
2111
+ var $$;
2112
+ (function ($$) {
2113
+ $mol_test({
2114
+ "Integers as recursive Sets"($) {
2115
+ class Schema extends $mol_schema_lazy(() => $mol_schema_list(Schema)) {
2116
+ }
2117
+ $mol_assert_equal(Schema.default, []);
2118
+ $mol_assert_equal(Schema.check([]), true);
2119
+ $mol_assert_equal(Schema.check(''), false);
2120
+ $mol_assert_equal(Schema.guard([]), []);
2121
+ $mol_assert_fail(() => Schema.guard(''), 'Non array');
2122
+ $mol_assert_equal(Schema.cast([]), []);
2123
+ $mol_assert_equal(Schema.cast(''), []);
2124
+ },
2125
+ });
2126
+ })($$ = $_1.$$ || ($_1.$$ = {}));
2127
+ })($ || ($ = {}));
2128
+
2129
+ ;
2130
+ "use strict";
2131
+ var $;
2132
+ (function ($_1) {
2133
+ var $$;
2134
+ (function ($$) {
2135
+ $mol_test({
2136
+ "JSON schema"($) {
2137
+ $mol_assert_equal('$mol_schema_json', $mol_schema_json + '', $mol_key($mol_schema_json));
2138
+ $mol_assert_equal(true, $mol_schema_json.check(null));
2139
+ $mol_assert_equal(true, $mol_schema_json.check(0));
2140
+ $mol_assert_equal(true, $mol_schema_json.check(false));
2141
+ $mol_assert_equal(true, $mol_schema_json.check(''));
2142
+ $mol_assert_equal(true, $mol_schema_json.check([]));
2143
+ $mol_assert_equal(true, $mol_schema_json.check({}));
2144
+ $mol_assert_equal(false, $mol_schema_json.check(undefined));
2145
+ $mol_assert_equal(false, $mol_schema_json.check(new Date));
2146
+ $mol_assert_equal(false, $mol_schema_json.check({ __proto__: {} }));
2147
+ $mol_assert_equal({}, $mol_schema_json.cast(new Date));
2148
+ $mol_assert_equal({ foo: 777, bar: {} }, $mol_schema_json.cast({ foo: 777, bar: new Date }));
2149
+ $mol_assert_equal({ foo: [null, 0, false, ''] }, $mol_schema_json.guard({ foo: [null, 0, false, ''] }));
2150
+ $mol_assert_fail(() => $mol_schema_json.guard({ foo: [new Date] }), 'Wrong variant');
2151
+ },
2152
+ });
2153
+ })($$ = $_1.$$ || ($_1.$$ = {}));
2154
+ })($ || ($ = {}));
2155
+
2101
2156
  ;
2102
2157
  "use strict";
2103
2158
  var $;