mol_schema 0.0.23 → 0.0.24

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
@@ -72,34 +72,36 @@ var $;
72
72
  static toString() {
73
73
  return $$.$mol_func_name(this);
74
74
  }
75
- /** Type-guard that checks value by schema. */
76
- static check(val) {
75
+ /** Type-predicate that checks value by schema. */
76
+ static check(value) {
77
77
  try {
78
- this.guard(val);
78
+ this.guard(value);
79
79
  return true;
80
80
  }
81
81
  catch (error) {
82
82
  return false;
83
83
  }
84
84
  }
85
- static [Symbol.hasInstance](val) {
86
- return this.check(val);
85
+ /** `instanceof` support */
86
+ static [Symbol.hasInstance](value) {
87
+ return this.check(value);
87
88
  }
88
- /** Strict parse. Fails of wrong values. */
89
+ /** Type-parser that fails of wrong values. */
89
90
  static guard(value) {
90
91
  return value;
91
92
  }
92
- /** Relaxed cast. Normalizes wrong values. */
93
+ /** Type-caster that normalizes wrong values. */
93
94
  static cast(value) {
94
95
  try {
95
- return this.guard(value);
96
+ this.guard(value);
97
+ return value;
96
98
  }
97
99
  catch (error) {
98
100
  return this.default;
99
101
  }
100
102
  }
101
103
  /** Default value which conforms schema. */
102
- static default = undefined;
104
+ static default = null;
103
105
  }
104
106
  $.$mol_schema_any = $mol_schema_any;
105
107
  })($ || ($ = {}));
@@ -559,7 +561,7 @@ var $;
559
561
  "use strict";
560
562
  var $;
561
563
  (function ($) {
562
- $.$mol_schema_instance = $mol_memo_key.func(function $mol_schema_instance(Class, ...args) {
564
+ $.$mol_schema_instance = $mol_memo_key.func(function $mol_schema_instance(Class) {
563
565
  class $mol_schema_instance_ extends $mol_schema_any {
564
566
  static Class = Class;
565
567
  static toString() {
@@ -572,9 +574,12 @@ var $;
572
574
  return value;
573
575
  return $mol_fail(new TypeError('Wrong class', { cause: { value, schema: this } }));
574
576
  }
575
- static default = new Class(...args);
577
+ static cast(value) {
578
+ return this.guard(value);
579
+ }
580
+ static default;
576
581
  }
577
- return ((Class[Symbol.hasInstance] === $mol_schema_any[Symbol.hasInstance])
582
+ return ((Class?.[Symbol.hasInstance] === $mol_schema_any[Symbol.hasInstance])
578
583
  ? Class
579
584
  : $mol_schema_instance_);
580
585
  });
@@ -582,31 +587,59 @@ var $;
582
587
 
583
588
  ;
584
589
  "use strict";
590
+ var $;
591
+ (function ($) {
592
+ function $mol_schema_lazy(Schema) {
593
+ // return $mol_delegate( $mol_schema_any, Schema )
594
+ return class $mol_schema_lazy_ extends $mol_schema_any {
595
+ static Schema = $mol_memo.func(Schema);
596
+ static guard(value) {
597
+ return this.Schema().guard(value);
598
+ }
599
+ static cast(value) {
600
+ return this.Schema().cast(value);
601
+ }
602
+ static get default() {
603
+ return this.Schema().default;
604
+ }
605
+ };
606
+ }
607
+ $.$mol_schema_lazy = $mol_schema_lazy;
608
+ })($ || ($ = {}));
585
609
 
586
610
  ;
587
611
  "use strict";
588
612
  var $;
589
613
  (function ($) {
590
- $.$mol_schema_every = $mol_memo_key.func(function $mol_schema_every(Schemas) {
591
- return class $mol_schema_every_ extends $mol_schema_any {
592
- static Schemas = Schemas;
614
+ $.$mol_schema_some = $mol_memo_key.func(function $mol_schema_some(Variants) {
615
+ return class $mol_schema_some_ extends $mol_schema_any {
616
+ static Variants = Variants;
593
617
  static toString() {
594
- if (this !== $mol_schema_every_)
618
+ if (this !== $mol_schema_some_)
595
619
  return super.toString();
596
- return '$mol_schema_every<' + $mol_key(Schemas) + '>';
620
+ return '$mol_schema_some<' + $mol_key(Variants) + '>';
597
621
  }
598
622
  static guard(value) {
599
- for (const Schema of Schemas) {
600
- Schema.guard(value);
623
+ const errors = [];
624
+ for (const Variant of Variants) {
625
+ try {
626
+ return Variant.guard(value);
627
+ }
628
+ catch (error) {
629
+ errors.push(error);
630
+ }
601
631
  }
602
- return value;
632
+ return $mol_fail(new AggregateError(errors, 'Wrong variant', { cause: { value, schema: this } }));
603
633
  }
604
634
  static cast(value) {
605
- for (const Scheme of Schemas)
606
- value = Scheme.cast(value);
607
- return value;
635
+ try {
636
+ return this.guard(value);
637
+ }
638
+ catch (error) {
639
+ return Variants[0].cast(value);
640
+ }
608
641
  }
609
- static default = Schemas.find(Scheme => this.check(Scheme.default));
642
+ static default = Variants[0].default;
610
643
  };
611
644
  });
612
645
  })($ || ($ = {}));
@@ -615,56 +648,50 @@ var $;
615
648
  "use strict";
616
649
  var $;
617
650
  (function ($) {
618
- $.$mol_schema_range = $mol_memo_key.func(function $mol_schema_range(Range) {
619
- return class $mol_schema_range_ extends $mol_schema_any {
620
- static Range = Range;
651
+ $.$mol_schema_dict = $mol_memo_key.func(function $mol_schema_dict(Pair) {
652
+ return class $mol_schema_dict_ extends $mol_schema_any {
653
+ static Pair = Pair;
621
654
  static toString() {
622
- if (this !== $mol_schema_range_)
655
+ if (this !== $mol_schema_dict_)
623
656
  return super.toString();
624
- return '$mol_schema_range<' + $mol_key(Range) + '>';
657
+ return '$mol_schema_dict<' + $mol_key(Pair) + '>';
625
658
  }
626
659
  static guard(value) {
627
- if (typeof value !== 'number' && typeof value !== 'bigint')
628
- return $mol_fail(new TypeError('Uncomparable type', { cause: { value, schema: this } }));
629
- if (!(value <= Range[1]))
630
- return $mol_fail(new TypeError('Too large', { cause: { value, schema: this } }));
631
- if (!(value >= Range[0]))
632
- return $mol_fail(new TypeError('Too small', { cause: { value, schema: this } }));
660
+ if (Object.getPrototypeOf(Object.getPrototypeOf(value))) {
661
+ return $mol_fail(new TypeError('Non dictionary', { cause: { value, schema: this } }));
662
+ }
663
+ for (const key in value) {
664
+ try {
665
+ Pair[0].guard(key);
666
+ }
667
+ catch (error) {
668
+ return $mol_fail(new TypeError('Wrong key', { cause: { key, error, value, schema: this } }));
669
+ }
670
+ try {
671
+ Pair[1].guard(value[key]);
672
+ }
673
+ catch (error) {
674
+ return $mol_fail(new TypeError('Wrong val', { cause: { key, error, value, schema: this } }));
675
+ }
676
+ }
633
677
  return value;
634
678
  }
635
- static cast(val) {
636
- if (val > Range[1])
637
- return Range[1];
638
- if (val >= Range[0])
639
- return val;
640
- return Range[0];
679
+ static cast(value) {
680
+ if (Object.getPrototypeOf(Object.getPrototypeOf(value)))
681
+ return this.default;
682
+ const res = {};
683
+ for (const key in value) {
684
+ if (!Pair[0].check(key))
685
+ continue;
686
+ res[key] = Pair[1].cast(value[key]);
687
+ }
688
+ return res;
641
689
  }
642
- static default = Range[0];
690
+ static default = {};
643
691
  };
644
692
  });
645
693
  })($ || ($ = {}));
646
694
 
647
- ;
648
- "use strict";
649
- var $;
650
- (function ($) {
651
- class $mol_schema_positive extends $mol_schema_range([0, Number.POSITIVE_INFINITY]) {
652
- }
653
- $.$mol_schema_positive = $mol_schema_positive;
654
- })($ || ($ = {}));
655
-
656
- ;
657
- "use strict";
658
- var $;
659
- (function ($) {
660
- class $mol_schema_natural extends $mol_schema_every([
661
- $mol_schema_integer,
662
- $mol_schema_positive,
663
- ]) {
664
- }
665
- $.$mol_schema_natural = $mol_schema_natural;
666
- })($ || ($ = {}));
667
-
668
695
  ;
669
696
  "use strict";
670
697
  var $;
@@ -680,11 +707,11 @@ var $;
680
707
  static guard(value) {
681
708
  if (Options.some(Option => Object.is(Option, value)))
682
709
  return value;
683
- return $mol_fail(new TypeError('No one option', { cause: { value, schema: this } }));
710
+ return $mol_fail(new TypeError('Wrong option', { cause: { value, schema: this } }));
684
711
  }
685
- static cast(val) {
686
- if (this.check(val))
687
- return val;
712
+ static cast(value) {
713
+ if (this.check(value))
714
+ return value;
688
715
  return Options[0];
689
716
  }
690
717
  static default = Options[0];
@@ -696,44 +723,33 @@ var $;
696
723
  "use strict";
697
724
  var $;
698
725
  (function ($) {
699
- class $mol_schema_negative extends $mol_schema_range([Number.NEGATIVE_INFINITY, 0]) {
700
- }
701
- $.$mol_schema_negative = $mol_schema_negative;
702
- })($ || ($ = {}));
703
-
704
- ;
705
- "use strict";
706
- var $;
707
- (function ($) {
708
- $.$mol_schema_some = $mol_memo_key.func(function $mol_schema_some(Variants) {
709
- return class $mol_schema_some_ extends $mol_schema_any {
710
- static Variants = Variants;
726
+ $.$mol_schema_list = $mol_memo_key.func(function $mol_schema_list(Item) {
727
+ return class $mol_schema_list_ extends $mol_schema_any {
728
+ static Item = Item;
711
729
  static toString() {
712
- if (this !== $mol_schema_some_)
730
+ if (this !== $mol_schema_list_)
713
731
  return super.toString();
714
- return '$mol_schema_some<' + $mol_key(Variants) + '>';
732
+ return '$mol_schema_list<' + $mol_key(Item) + '>';
715
733
  }
716
734
  static guard(value) {
717
- const errors = [];
718
- for (const Variant of Variants) {
735
+ if (!Array.isArray(value))
736
+ return $mol_fail(new TypeError('Non array', { cause: { value, schema: this } }));
737
+ for (const [index, item] of super.guard(value).entries()) {
719
738
  try {
720
- return Variant.guard(value);
739
+ Item.guard(item);
721
740
  }
722
741
  catch (error) {
723
- errors.push(error);
742
+ return $mol_fail(new TypeError('Wrong item', { cause: { index, error, value, schema: this } }));
724
743
  }
725
744
  }
726
- return $mol_fail(new AggregateError(errors, 'No one variant', { cause: { value, schema: this } }));
745
+ return value;
727
746
  }
728
747
  static cast(value) {
729
- try {
730
- return this.guard(value);
731
- }
732
- catch (error) {
733
- return Variants[0].cast(value);
734
- }
748
+ if (!Array.isArray(value))
749
+ return this.default;
750
+ return value.map(item => Item.cast(item));
735
751
  }
736
- static default = Variants[0].default;
752
+ static default = [];
737
753
  };
738
754
  });
739
755
  })($ || ($ = {}));
@@ -742,14 +758,43 @@ var $;
742
758
  "use strict";
743
759
  var $;
744
760
  (function ($) {
745
- $.$mol_schema_maybe = $mol_memo_key.func(function $mol_schema_maybe(Some) {
746
- return class $mol_schema_maybe_ extends $mol_schema_some([$mol_schema_enum([undefined, null]), Some]) {
747
- static Some = Some;
761
+ class $mol_schema_json extends $mol_schema_lazy(() => $mol_schema_some([
762
+ $mol_schema_dict([$mol_schema_string, $mol_schema_json]),
763
+ $mol_schema_enum([null]),
764
+ $mol_schema_boolean, $mol_schema_float, $mol_schema_string,
765
+ $mol_schema_list($mol_schema_json),
766
+ ])) {
767
+ }
768
+ $.$mol_schema_json = $mol_schema_json;
769
+ })($ || ($ = {}));
770
+
771
+ ;
772
+ "use strict";
773
+
774
+ ;
775
+ "use strict";
776
+ var $;
777
+ (function ($) {
778
+ $.$mol_schema_every = $mol_memo_key.func(function $mol_schema_every(Schemas) {
779
+ return class $mol_schema_every_ extends $mol_schema_any {
780
+ static Schemas = Schemas;
748
781
  static toString() {
749
- if (this !== $mol_schema_maybe_)
782
+ if (this !== $mol_schema_every_)
750
783
  return super.toString();
751
- return '$mol_schema_maybe<' + $mol_key(Some) + '>';
784
+ return '$mol_schema_every<' + $mol_key(Schemas) + '>';
785
+ }
786
+ static guard(value) {
787
+ for (const Schema of Schemas) {
788
+ Schema.guard(value);
789
+ }
790
+ return value;
752
791
  }
792
+ static cast(value) {
793
+ for (const Scheme of Schemas)
794
+ value = Scheme.cast(value);
795
+ return value;
796
+ }
797
+ static default = Schemas.find(Scheme => this.check(Scheme.default));
753
798
  };
754
799
  });
755
800
  })($ || ($ = {}));
@@ -758,33 +803,31 @@ var $;
758
803
  "use strict";
759
804
  var $;
760
805
  (function ($) {
761
- $.$mol_schema_list = $mol_memo_key.func(function $mol_schema_list(Item) {
762
- return class $mol_schema_list_ extends $mol_schema_any {
763
- static Item = Item;
806
+ $.$mol_schema_range = $mol_memo_key.func(function $mol_schema_range(Range) {
807
+ return class $mol_schema_range_ extends $mol_schema_any {
808
+ static Range = Range;
764
809
  static toString() {
765
- if (this !== $mol_schema_list_)
810
+ if (this !== $mol_schema_range_)
766
811
  return super.toString();
767
- return '$mol_schema_list<' + $mol_key(Item) + '>';
812
+ return '$mol_schema_range<' + $mol_key(Range) + '>';
768
813
  }
769
814
  static guard(value) {
770
- if (!Array.isArray(value))
771
- return $mol_fail(new TypeError('Non array', { cause: { value, schema: this } }));
772
- for (const [index, item] of super.guard(value).entries()) {
773
- try {
774
- Item.guard(item);
775
- }
776
- catch (error) {
777
- return $mol_fail(new TypeError('Wrong item', { cause: { index, error, value, schema: this } }));
778
- }
779
- }
815
+ if (typeof value !== 'number' && typeof value !== 'bigint')
816
+ return $mol_fail(new TypeError('Uncomparable type', { cause: { value, schema: this } }));
817
+ if (!(value <= Range[1]))
818
+ return $mol_fail(new TypeError('Too large', { cause: { value, schema: this } }));
819
+ if (!(value >= Range[0]))
820
+ return $mol_fail(new TypeError('Too small', { cause: { value, schema: this } }));
780
821
  return value;
781
822
  }
782
823
  static cast(value) {
783
- if (!Array.isArray(value))
784
- return this.default;
785
- return value.map(item => Item.cast(item));
824
+ if (value > Range[1])
825
+ return Range[1];
826
+ if (value >= Range[0])
827
+ return value;
828
+ return Range[0];
786
829
  }
787
- static default = [];
830
+ static default = Range[0];
788
831
  };
789
832
  });
790
833
  })($ || ($ = {}));
@@ -793,46 +836,50 @@ var $;
793
836
  "use strict";
794
837
  var $;
795
838
  (function ($) {
796
- $.$mol_schema_dict = $mol_memo_key.func(function $mol_schema_dict(Pair) {
797
- return class $mol_schema_dict_ extends $mol_schema_any {
798
- static Pair = Pair;
839
+ class $mol_schema_positive extends $mol_schema_range([0, Number.POSITIVE_INFINITY]) {
840
+ }
841
+ $.$mol_schema_positive = $mol_schema_positive;
842
+ })($ || ($ = {}));
843
+
844
+ ;
845
+ "use strict";
846
+ var $;
847
+ (function ($) {
848
+ class $mol_schema_natural extends $mol_schema_every([
849
+ $mol_schema_integer,
850
+ $mol_schema_positive,
851
+ ]) {
852
+ }
853
+ $.$mol_schema_natural = $mol_schema_natural;
854
+ })($ || ($ = {}));
855
+
856
+ ;
857
+ "use strict";
858
+ var $;
859
+ (function ($) {
860
+ class $mol_schema_negative extends $mol_schema_range([Number.NEGATIVE_INFINITY, 0]) {
861
+ }
862
+ $.$mol_schema_negative = $mol_schema_negative;
863
+ })($ || ($ = {}));
864
+
865
+ ;
866
+ "use strict";
867
+ var $;
868
+ (function ($) {
869
+ $.$mol_schema_maybe = $mol_memo_key.func(function $mol_schema_maybe(Some) {
870
+ return class $mol_schema_maybe_ extends $mol_schema_any {
871
+ static Some = Some;
799
872
  static toString() {
800
- if (this !== $mol_schema_dict_)
873
+ if (this !== $mol_schema_maybe_)
801
874
  return super.toString();
802
- return '$mol_schema_dict<' + $mol_key(Pair) + '>';
875
+ return '$mol_schema_maybe<' + $mol_key(Some) + '>';
803
876
  }
804
877
  static guard(value) {
805
- if (Object.getPrototypeOf(Object.getPrototypeOf(value))) {
806
- return $mol_fail(new TypeError('Non dictionary', { cause: { value, schema: this } }));
807
- }
808
- for (const key in value) {
809
- try {
810
- Pair[0].guard(key);
811
- }
812
- catch (error) {
813
- return $mol_fail(new TypeError('Wrong key', { cause: { key, error, value, schema: this } }));
814
- }
815
- try {
816
- Pair[1].guard(value[key]);
817
- }
818
- catch (error) {
819
- return $mol_fail(new TypeError('Wrong val', { cause: { key, error, value, schema: this } }));
820
- }
821
- }
822
- return value;
823
- }
824
- static cast(value) {
825
- if (Object.getPrototypeOf(Object.getPrototypeOf(value)))
826
- return this.default;
827
- const res = {};
828
- for (const key in value) {
829
- if (!Pair[0].check(key))
830
- continue;
831
- res[key] = Pair[1].cast(value[key]);
832
- }
833
- return res;
878
+ if (value == null)
879
+ return value;
880
+ return Some.guard(value);
834
881
  }
835
- static default = {};
882
+ static default = null;
836
883
  };
837
884
  });
838
885
  })($ || ($ = {}));
@@ -1547,12 +1594,18 @@ var $;
1547
1594
  'color': 'gray',
1548
1595
  });
1549
1596
  $.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
1550
- 'margin-left': '13px'
1597
+ 'margin-inline-start': '13px'
1551
1598
  });
1552
1599
  class Stack extends Array {
1553
1600
  // [ Symbol.toPrimitive ]() {
1554
1601
  // return this.toString()
1555
1602
  // }
1603
+ match(...args) {
1604
+ return this.toString().match(...args);
1605
+ }
1606
+ split(...args) {
1607
+ return this.toString().split(...args);
1608
+ }
1556
1609
  toString() {
1557
1610
  return this.join('\n');
1558
1611
  }
@@ -2390,14 +2443,14 @@ var $;
2390
2443
  reuse: if (existen) {
2391
2444
  if (!existen.temp)
2392
2445
  break reuse;
2393
- if (existen.task !== task) {
2394
- cause = 'task';
2395
- break reuse;
2396
- }
2397
2446
  if (existen.host !== host) {
2398
2447
  cause = 'host';
2399
2448
  break reuse;
2400
2449
  }
2450
+ if (existen.task !== task) {
2451
+ cause = 'task';
2452
+ break reuse;
2453
+ }
2401
2454
  if (!$mol_compare_deep(existen.args, args)) {
2402
2455
  cause = 'args';
2403
2456
  break reuse;
@@ -3015,7 +3068,7 @@ var $;
3015
3068
  "use strict";
3016
3069
  var $;
3017
3070
  (function ($) {
3018
- $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
3071
+ $.$mol_dom_context = new $node.jsdom.JSDOM('', { url: `http://${process.env.DOMAIN || 'localhost'}/` }).window;
3019
3072
  })($ || ($ = {}));
3020
3073
 
3021
3074
  ;
@@ -4267,7 +4320,7 @@ var $;
4267
4320
  $mol_assert_equal(Config.cast('foo'), 'foo');
4268
4321
  $mol_assert_equal(Config.cast('bar'), 123);
4269
4322
  $mol_assert_equal(123, Config.guard(123));
4270
- $mol_assert_fail(() => Config.guard(321), 'No one option');
4323
+ $mol_assert_fail(() => Config.guard(321), 'Wrong option');
4271
4324
  },
4272
4325
  });
4273
4326
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -4336,7 +4389,7 @@ var $;
4336
4389
  $mol_assert_equal('foo', Config.cast('foo'));
4337
4390
  $mol_assert_equal(Number.NaN, Config.cast(true));
4338
4391
  $mol_assert_equal(123, Config.guard(123));
4339
- $mol_assert_fail(() => Config.guard(false), 'No one variant');
4392
+ $mol_assert_fail(() => Config.guard(false), 'Wrong variant');
4340
4393
  },
4341
4394
  });
4342
4395
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -4363,9 +4416,9 @@ var $;
4363
4416
  $mol_assert_equal('foo', Config.cast('foo'));
4364
4417
  $mol_assert_equal(undefined, Config.cast(undefined));
4365
4418
  $mol_assert_equal(null, Config.cast(null));
4366
- $mol_assert_equal(undefined, Config.cast(0));
4419
+ $mol_assert_equal(null, Config.cast(0));
4367
4420
  $mol_assert_equal('foo', Config.guard('foo'));
4368
- $mol_assert_fail(() => Config.guard(123), 'No one variant');
4421
+ $mol_assert_fail(() => Config.guard(123), 'Wrong type');
4369
4422
  },
4370
4423
  });
4371
4424
  })($$ = $_1.$$ || ($_1.$$ = {}));
@@ -4627,7 +4680,7 @@ var $;
4627
4680
  });
4628
4681
  $mol_assert_equal(true, User.check({ name: 'foo', age: 123 }));
4629
4682
  $mol_assert_equal(true, User.check({ name: null }));
4630
- $mol_assert_equal({ name: 'foo', age: undefined }, User.cast({ name: 'foo', age: false }));
4683
+ $mol_assert_equal({ name: 'foo', age: null }, User.cast({ name: 'foo', age: false }));
4631
4684
  $mol_assert_equal({ name: 'foo', age: undefined }, User.guard({ name: 'foo', age: undefined }));
4632
4685
  $mol_assert_fail(() => User.guard({ name: 'foo', age: 'bar' }), 'Wrong field');
4633
4686
  },
@@ -4673,7 +4726,7 @@ var $;
4673
4726
  $mol_assert_equal(false, Blob.check(new Int8Array));
4674
4727
  $mol_assert_equal(false, Blob.check(null));
4675
4728
  $mol_assert_equal(new Uint8Array([0, 1]), Blob.cast(new Uint8Array([0, 1])));
4676
- $mol_assert_equal(new Uint8Array, Blob.cast(new Int8Array([1, -1])));
4729
+ $mol_assert_fail(() => Blob.cast(new Int8Array), 'Wrong class');
4677
4730
  $mol_assert_equal(new Uint8Array, Blob.guard(new Uint8Array));
4678
4731
  $mol_assert_fail(() => Blob.guard(new Int8Array), 'Wrong class');
4679
4732
  },
@@ -4695,6 +4748,55 @@ var $;
4695
4748
  })($$ = $_1.$$ || ($_1.$$ = {}));
4696
4749
  })($ || ($ = {}));
4697
4750
 
4751
+ ;
4752
+ "use strict";
4753
+ var $;
4754
+ (function ($_1) {
4755
+ var $$;
4756
+ (function ($$) {
4757
+ $mol_test({
4758
+ "Integers as recursive Sets"($) {
4759
+ class Schema extends $mol_schema_lazy(() => $mol_schema_list(Schema)) {
4760
+ }
4761
+ $mol_assert_equal(Schema.default, []);
4762
+ $mol_assert_equal(Schema.check([]), true);
4763
+ $mol_assert_equal(Schema.check(''), false);
4764
+ $mol_assert_equal(Schema.guard([]), []);
4765
+ $mol_assert_fail(() => Schema.guard(''), 'Non array');
4766
+ $mol_assert_equal(Schema.cast([]), []);
4767
+ $mol_assert_equal(Schema.cast(''), []);
4768
+ },
4769
+ });
4770
+ })($$ = $_1.$$ || ($_1.$$ = {}));
4771
+ })($ || ($ = {}));
4772
+
4773
+ ;
4774
+ "use strict";
4775
+ var $;
4776
+ (function ($_1) {
4777
+ var $$;
4778
+ (function ($$) {
4779
+ $mol_test({
4780
+ "JSON schema"($) {
4781
+ $mol_assert_equal('$mol_schema_json', $mol_schema_json + '', $mol_key($mol_schema_json));
4782
+ $mol_assert_equal(true, $mol_schema_json.check(null));
4783
+ $mol_assert_equal(true, $mol_schema_json.check(0));
4784
+ $mol_assert_equal(true, $mol_schema_json.check(false));
4785
+ $mol_assert_equal(true, $mol_schema_json.check(''));
4786
+ $mol_assert_equal(true, $mol_schema_json.check([]));
4787
+ $mol_assert_equal(true, $mol_schema_json.check({}));
4788
+ $mol_assert_equal(false, $mol_schema_json.check(undefined));
4789
+ $mol_assert_equal(false, $mol_schema_json.check(new Date));
4790
+ $mol_assert_equal(false, $mol_schema_json.check({ __proto__: {} }));
4791
+ $mol_assert_equal({}, $mol_schema_json.cast(new Date));
4792
+ $mol_assert_equal({ foo: 777, bar: {} }, $mol_schema_json.cast({ foo: 777, bar: new Date }));
4793
+ $mol_assert_equal({ foo: [null, 0, false, ''] }, $mol_schema_json.guard({ foo: [null, 0, false, ''] }));
4794
+ $mol_assert_fail(() => $mol_schema_json.guard({ foo: [new Date] }), 'Wrong variant');
4795
+ },
4796
+ });
4797
+ })($$ = $_1.$$ || ($_1.$$ = {}));
4798
+ })($ || ($ = {}));
4799
+
4698
4800
  ;
4699
4801
  "use strict";
4700
4802
  var $;