pema 0.7.0 → 0.8.0

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.
Files changed (107) hide show
  1. package/lib/private/ArrayType.d.ts +5 -2
  2. package/lib/private/ArrayType.js +4 -2
  3. package/lib/private/BigIntType.d.ts +1 -1
  4. package/lib/private/BigUintType.d.ts +1 -1
  5. package/lib/private/BooleanType.d.ts +5 -1
  6. package/lib/private/BooleanType.js +6 -0
  7. package/lib/private/DateType.d.ts +4 -1
  8. package/lib/private/DateType.js +6 -0
  9. package/lib/private/IntType.d.ts +1 -1
  10. package/lib/private/LiteralType.d.ts +5 -2
  11. package/lib/private/LiteralType.js +7 -4
  12. package/lib/private/Mode.d.ts +3 -0
  13. package/lib/private/Mode.js +2 -0
  14. package/lib/private/NumberType.d.ts +1 -1
  15. package/lib/private/NumericType.d.ts +5 -2
  16. package/lib/private/NumericType.js +5 -2
  17. package/lib/private/ObjectType.d.ts +7 -4
  18. package/lib/private/ObjectType.js +6 -8
  19. package/lib/private/OmitType.d.ts +5 -2
  20. package/lib/private/OmitType.js +4 -1
  21. package/lib/private/PartialType.d.ts +5 -2
  22. package/lib/private/PartialType.js +4 -1
  23. package/lib/private/RecordType.d.ts +7 -4
  24. package/lib/private/RecordType.js +4 -1
  25. package/lib/private/Serialized.d.ts +13 -13
  26. package/lib/private/StoreType.d.ts +1 -1
  27. package/lib/private/TupleType.d.ts +5 -2
  28. package/lib/private/TupleType.js +3 -1
  29. package/lib/private/URLType.d.ts +6 -1
  30. package/lib/private/URLType.js +21 -0
  31. package/lib/private/UintType.d.ts +1 -1
  32. package/lib/private/UnionType.d.ts +5 -2
  33. package/lib/private/UnionType.js +4 -1
  34. package/lib/private/array.d.ts +2 -2
  35. package/lib/private/array.js +2 -7
  36. package/lib/private/blob.js +0 -3
  37. package/lib/private/boolean.d.ts +5 -5
  38. package/lib/private/boolean.js +5 -8
  39. package/lib/private/constructor.js +2 -7
  40. package/lib/private/date.d.ts +3 -3
  41. package/lib/private/date.js +2 -5
  42. package/lib/private/dict.d.ts +4 -4
  43. package/lib/private/enum.d.ts +3 -3
  44. package/lib/private/enum.js +3 -9
  45. package/lib/private/f32.d.ts +3 -3
  46. package/lib/private/f32.js +3 -6
  47. package/lib/private/f64.d.ts +3 -3
  48. package/lib/private/f64.js +2 -5
  49. package/lib/private/file.js +0 -3
  50. package/lib/private/function.js +0 -3
  51. package/lib/private/i128.d.ts +3 -3
  52. package/lib/private/i128.js +3 -6
  53. package/lib/private/i16.d.ts +3 -3
  54. package/lib/private/i16.js +3 -6
  55. package/lib/private/i32.d.ts +3 -3
  56. package/lib/private/i32.js +3 -6
  57. package/lib/private/i64.d.ts +3 -3
  58. package/lib/private/i64.js +3 -6
  59. package/lib/private/i8.d.ts +3 -3
  60. package/lib/private/i8.js +3 -6
  61. package/lib/private/index.d.ts +241 -43
  62. package/lib/private/is.js +2 -7
  63. package/lib/private/json.js +2 -7
  64. package/lib/private/literal.d.ts +5 -5
  65. package/lib/private/literal.js +3 -9
  66. package/lib/private/null.js +0 -3
  67. package/lib/private/object.d.ts +2 -2
  68. package/lib/private/object.js +2 -7
  69. package/lib/private/omit.d.ts +2 -2
  70. package/lib/private/omit.js +2 -7
  71. package/lib/private/partial.d.ts +2 -2
  72. package/lib/private/partial.js +2 -7
  73. package/lib/private/pure.js +2 -7
  74. package/lib/private/record.d.ts +3 -3
  75. package/lib/private/record.js +2 -7
  76. package/lib/private/spec/bigint.d.ts +3 -2
  77. package/lib/private/spec/bigint.js +1 -0
  78. package/lib/private/spec/biguint.d.ts +3 -2
  79. package/lib/private/spec/biguint.js +7 -0
  80. package/lib/private/spec/int.d.ts +3 -2
  81. package/lib/private/spec/int.js +2 -1
  82. package/lib/private/spec/uint.d.ts +3 -2
  83. package/lib/private/spec/uint.js +1 -0
  84. package/lib/private/string.js +0 -3
  85. package/lib/private/symbol.js +0 -3
  86. package/lib/private/tuple.d.ts +2 -2
  87. package/lib/private/tuple.js +2 -7
  88. package/lib/private/u128.d.ts +3 -3
  89. package/lib/private/u128.js +3 -6
  90. package/lib/private/u16.d.ts +3 -3
  91. package/lib/private/u16.js +3 -6
  92. package/lib/private/u32.d.ts +3 -3
  93. package/lib/private/u32.js +3 -9
  94. package/lib/private/u64.d.ts +3 -3
  95. package/lib/private/u64.js +3 -6
  96. package/lib/private/u8.d.ts +3 -3
  97. package/lib/private/u8.js +3 -6
  98. package/lib/private/undefined.d.ts +2 -2
  99. package/lib/private/undefined.js +1 -5
  100. package/lib/private/union.d.ts +4 -4
  101. package/lib/private/union.js +2 -7
  102. package/lib/private/unknown.d.ts +2 -2
  103. package/lib/private/unknown.js +1 -5
  104. package/lib/private/url.d.ts +3 -3
  105. package/lib/private/url.js +2 -5
  106. package/lib/private/uuid.js +0 -3
  107. package/package.json +2 -2
@@ -7,6 +7,7 @@ import ParseError from "#ParseError";
7
7
  import resolve from "#resolve";
8
8
  import S from "#schema-errors";
9
9
  import assert from "@rcompat/assert";
10
+ import Loose from "#Loose";
10
11
  const print = (type) => {
11
12
  const parsed = is_parsed(type);
12
13
  if (parsed) {
@@ -29,10 +30,12 @@ const print = (type) => {
29
30
  const union_error = (types) => `\`${types.map(t => is_parsed(t) ? t.name : print(t)).join(" | ")}\``;
30
31
  export default class UnionType extends GenericType {
31
32
  #of;
32
- constructor(of) {
33
+ [Loose];
34
+ constructor(of, mode) {
33
35
  assert.true(of.length > 1, S.union_at_least_two_members());
34
36
  super();
35
37
  this.#of = of;
38
+ this[Loose] = mode;
36
39
  }
37
40
  get name() {
38
41
  return "union";
@@ -2,8 +2,8 @@ import ArrayType from "#ArrayType";
2
2
  import type NormalizeSchema from "#NormalizeSchema";
3
3
  import type Schema from "#Schema";
4
4
  declare const array: {
5
- strict: <const S extends Schema>(of: S) => ArrayType<NormalizeSchema<S>>;
6
- loose: <const S extends Schema>(of: S) => ArrayType<NormalizeSchema<S>>;
5
+ strict: <const S extends Schema>(of: S) => ArrayType<NormalizeSchema<S>, false>;
6
+ loose: <const S extends Schema>(of: S) => ArrayType<NormalizeSchema<S>, true>;
7
7
  vanilla: <const S extends Schema>(of: S) => ArrayType<NormalizeSchema<S>>;
8
8
  };
9
9
  export default array;
@@ -1,5 +1,4 @@
1
1
  import ArrayType from "#ArrayType";
2
- import Loose from "#Loose";
3
2
  import normalize from "#normalize";
4
3
  /**
5
4
  * Value is an array of the given type.
@@ -8,14 +7,10 @@ const vanilla = function array(of) {
8
7
  return new ArrayType(normalize(of));
9
8
  };
10
9
  const loose = function array(of) {
11
- const i = new ArrayType(normalize(of));
12
- i[Loose] = true;
13
- return i;
10
+ return new ArrayType(normalize(of), true);
14
11
  };
15
12
  const strict = function array(of) {
16
- const i = new ArrayType(normalize(of));
17
- i[Loose] = false;
18
- return i;
13
+ return new ArrayType(normalize(of), false);
19
14
  };
20
15
  const array = { strict, loose, vanilla };
21
16
  export default array;
@@ -1,10 +1,7 @@
1
1
  import BlobType from "#BlobType";
2
- import Loose from "#Loose";
3
2
  const vanilla = new BlobType();
4
3
  const loose = new BlobType();
5
- loose[Loose] = true;
6
4
  const strict = new BlobType();
7
- strict[Loose] = false;
8
5
  const blob = { vanilla, loose, strict };
9
6
  export default blob;
10
7
  //# sourceMappingURL=blob.js.map
@@ -1,8 +1,8 @@
1
1
  import BooleanType from "#BooleanType";
2
- declare const boolean: {
3
- vanilla: BooleanType;
4
- loose: BooleanType;
5
- strict: BooleanType;
2
+ declare const _default: {
3
+ strict: BooleanType<false>;
4
+ loose: BooleanType<true>;
5
+ vanilla: BooleanType<undefined>;
6
6
  };
7
- export default boolean;
7
+ export default _default;
8
8
  //# sourceMappingURL=boolean.d.ts.map
@@ -1,10 +1,7 @@
1
1
  import BooleanType from "#BooleanType";
2
- import Loose from "#Loose";
3
- const vanilla = new BooleanType();
4
- const loose = new BooleanType();
5
- loose[Loose] = true;
6
- const strict = new BooleanType();
7
- strict[Loose] = false;
8
- const boolean = { vanilla, loose, strict };
9
- export default boolean;
2
+ export default {
3
+ strict: new BooleanType(false),
4
+ loose: new BooleanType(true),
5
+ vanilla: new BooleanType(),
6
+ };
10
7
  //# sourceMappingURL=boolean.js.map
@@ -1,5 +1,4 @@
1
1
  import ConstructorType from "#ConstructorType";
2
- import Loose from "#Loose";
3
2
  /**
4
3
  * Value is a constructed instance of the given class.
5
4
  */
@@ -7,14 +6,10 @@ const vanilla = function constructor(c) {
7
6
  return new ConstructorType(c);
8
7
  };
9
8
  const loose = function constructor(c) {
10
- const i = new ConstructorType(c);
11
- i[Loose] = true;
12
- return i;
9
+ return new ConstructorType(c);
13
10
  };
14
11
  const strict = function constructor(c) {
15
- const i = new ConstructorType(c);
16
- i[Loose] = false;
17
- return i;
12
+ return new ConstructorType(c);
18
13
  };
19
14
  const constructor = { vanilla, loose, strict };
20
15
  export default constructor;
@@ -1,8 +1,8 @@
1
1
  import DateType from "#DateType";
2
2
  declare const date: {
3
- vanilla: DateType;
4
- loose: DateType;
5
- strict: DateType;
3
+ vanilla: DateType<undefined>;
4
+ loose: DateType<true>;
5
+ strict: DateType<false>;
6
6
  };
7
7
  export default date;
8
8
  //# sourceMappingURL=date.d.ts.map
@@ -1,10 +1,7 @@
1
1
  import DateType from "#DateType";
2
- import Loose from "#Loose";
3
2
  const vanilla = new DateType();
4
- const loose = new DateType();
5
- loose[Loose] = true;
6
- const strict = new DateType();
7
- strict[Loose] = false;
3
+ const loose = new DateType(true);
4
+ const strict = new DateType(false);
8
5
  const date = { vanilla, loose, strict };
9
6
  export default date;
10
7
  //# sourceMappingURL=date.js.map
@@ -8,10 +8,10 @@ import type StringType from "#StringType";
8
8
  */
9
9
  declare function vanilla(): RecordType<StringType, StringType>;
10
10
  declare function vanilla<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value>;
11
- declare function loose(): RecordType<StringType, StringType>;
12
- declare function loose<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value>;
13
- declare function strict(): RecordType<StringType, StringType>;
14
- declare function strict<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value>;
11
+ declare function loose(): RecordType<StringType, StringType, true>;
12
+ declare function loose<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value, true>;
13
+ declare function strict(): RecordType<StringType, StringType, false>;
14
+ declare function strict<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value, false>;
15
15
  declare const dict: {
16
16
  vanilla: typeof vanilla;
17
17
  loose: typeof loose;
@@ -2,10 +2,10 @@ import EnumType from "#EnumType";
2
2
  declare function vanilla<T extends readonly string[]>(values: T): EnumType<T>;
3
3
  declare function loose<T extends readonly string[]>(values: T): EnumType<T>;
4
4
  declare function strict<T extends readonly string[]>(values: T): EnumType<T>;
5
- declare const _enum: {
6
- vanilla: typeof vanilla;
5
+ declare const _default: {
7
6
  loose: typeof loose;
8
7
  strict: typeof strict;
8
+ vanilla: typeof vanilla;
9
9
  };
10
- export default _enum;
10
+ export default _default;
11
11
  //# sourceMappingURL=enum.d.ts.map
@@ -1,18 +1,12 @@
1
1
  import EnumType from "#EnumType";
2
- import Loose from "#Loose";
3
2
  function vanilla(values) {
4
3
  return new EnumType(values);
5
4
  }
6
5
  function loose(values) {
7
- const i = new EnumType(values);
8
- i[Loose] = true;
9
- return i;
6
+ return new EnumType(values);
10
7
  }
11
8
  function strict(values) {
12
- const i = new EnumType(values);
13
- i[Loose] = false;
14
- return i;
9
+ return new EnumType(values);
15
10
  }
16
- const _enum = { vanilla, loose, strict };
17
- export default _enum;
11
+ export default { loose, strict, vanilla };
18
12
  //# sourceMappingURL=enum.js.map
@@ -1,8 +1,8 @@
1
1
  import NumberType from "#NumberType";
2
2
  declare const f32$: {
3
- vanilla: NumberType<"f32">;
4
- loose: NumberType<"f32">;
5
- strict: NumberType<"f32">;
3
+ vanilla: NumberType<"f32", undefined>;
4
+ loose: NumberType<"f32", true>;
5
+ strict: NumberType<"f32", false>;
6
6
  };
7
7
  export default f32$;
8
8
  //# sourceMappingURL=f32.d.ts.map
@@ -1,11 +1,8 @@
1
- import Loose from "#Loose";
2
1
  import NumberType from "#NumberType";
3
2
  import f32 from "#validator/f32";
4
- const vanilla = new NumberType("f32", [f32]);
5
- const loose = new NumberType("f32", [f32]);
6
- loose[Loose] = true;
7
- const strict = new NumberType("f32", [f32]);
8
- strict[Loose] = false;
3
+ const vanilla = new NumberType("f32", undefined, [f32]);
4
+ const strict = new NumberType("f32", false, [f32]);
5
+ const loose = new NumberType("f32", true, [f32]);
9
6
  const f32$ = { vanilla, loose, strict };
10
7
  export default f32$;
11
8
  //# sourceMappingURL=f32.js.map
@@ -1,8 +1,8 @@
1
1
  import NumberType from "#NumberType";
2
2
  declare const f64: {
3
- strict: NumberType<"f64">;
4
- loose: NumberType<"f64">;
5
- vanilla: NumberType<"f64">;
3
+ strict: NumberType<"f64", false>;
4
+ loose: NumberType<"f64", true>;
5
+ vanilla: NumberType<"f64", undefined>;
6
6
  };
7
7
  export default f64;
8
8
  //# sourceMappingURL=f64.d.ts.map
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import NumberType from "#NumberType";
3
- const strict = new NumberType("f64");
4
- strict[Loose] = false;
5
- const loose = new NumberType("f64");
6
- loose[Loose] = true;
7
2
  const vanilla = new NumberType("f64");
3
+ const loose = new NumberType("f64", true);
4
+ const strict = new NumberType("f64", false);
8
5
  const f64 = { strict, loose, vanilla };
9
6
  export default f64;
10
7
  //# sourceMappingURL=f64.js.map
@@ -1,10 +1,7 @@
1
1
  import FileType from "#FileType";
2
- import Loose from "#Loose";
3
2
  const vanilla = new FileType();
4
3
  const loose = new FileType();
5
- loose[Loose] = true;
6
4
  const strict = new FileType();
7
- strict[Loose] = false;
8
5
  const file = { vanilla, loose, strict };
9
6
  export default file;
10
7
  //# sourceMappingURL=file.js.map
@@ -1,13 +1,10 @@
1
1
  import FunctionType from "#FunctionType";
2
- import Loose from "#Loose";
3
2
  /**
4
3
  * Value is a function.
5
4
  */
6
5
  const vanilla = new FunctionType();
7
6
  const loose = new FunctionType();
8
- loose[Loose] = true;
9
7
  const strict = new FunctionType();
10
- strict[Loose] = false;
11
8
  const function$ = { vanilla, loose, strict };
12
9
  export default function$;
13
10
  //# sourceMappingURL=function.js.map
@@ -1,8 +1,8 @@
1
1
  import BigIntType from "#BigIntType";
2
2
  declare const i128: {
3
- vanilla: BigIntType<"i128">;
4
- loose: BigIntType<"i128">;
5
- strict: BigIntType<"i128">;
3
+ vanilla: BigIntType<"i128", undefined>;
4
+ loose: BigIntType<"i128", true>;
5
+ strict: BigIntType<"i128", false>;
6
6
  };
7
7
  export default i128;
8
8
  //# sourceMappingURL=i128.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import BigIntType from "#BigIntType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = -(2n ** 127n);
5
4
  const to = 2n ** 127n - 1n;
6
- const vanilla = new BigIntType("i128", [range(from, to)]);
7
- const loose = new BigIntType("i128", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new BigIntType("i128", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new BigIntType("i128", undefined, [range(from, to)]);
6
+ const loose = new BigIntType("i128", true, [range(from, to)]);
7
+ const strict = new BigIntType("i128", false, [range(from, to)]);
11
8
  const i128 = { vanilla, loose, strict };
12
9
  export default i128;
13
10
  //# sourceMappingURL=i128.js.map
@@ -1,8 +1,8 @@
1
1
  import IntType from "#IntType";
2
2
  declare const i16: {
3
- vanilla: IntType<"i16">;
4
- loose: IntType<"i16">;
5
- strict: IntType<"i16">;
3
+ vanilla: IntType<"i16", undefined>;
4
+ loose: IntType<"i16", true>;
5
+ strict: IntType<"i16", false>;
6
6
  };
7
7
  export default i16;
8
8
  //# sourceMappingURL=i16.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import IntType from "#IntType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = -(2 ** 15);
5
4
  const to = 2 ** 15 - 1;
6
- const vanilla = new IntType("i16", [range(from, to)]);
7
- const loose = new IntType("i16", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new IntType("i16", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new IntType("i16", undefined, [range(from, to)]);
6
+ const loose = new IntType("i16", true, [range(from, to)]);
7
+ const strict = new IntType("i16", false, [range(from, to)]);
11
8
  const i16 = { vanilla, loose, strict };
12
9
  export default i16;
13
10
  //# sourceMappingURL=i16.js.map
@@ -1,8 +1,8 @@
1
1
  import IntType from "#IntType";
2
2
  declare const i32: {
3
- vanilla: IntType<"i32">;
4
- loose: IntType<"i32">;
5
- strict: IntType<"i32">;
3
+ vanilla: IntType<"i32", undefined>;
4
+ loose: IntType<"i32", true>;
5
+ strict: IntType<"i32", false>;
6
6
  };
7
7
  export default i32;
8
8
  //# sourceMappingURL=i32.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import IntType from "#IntType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = -(2 ** 31);
5
4
  const to = 2 ** 31 - 1;
6
- const vanilla = new IntType("i32", [range(from, to)]);
7
- const loose = new IntType("i32", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new IntType("i32", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new IntType("i32", undefined, [range(from, to)]);
6
+ const loose = new IntType("i32", true, [range(from, to)]);
7
+ const strict = new IntType("i32", false, [range(from, to)]);
11
8
  const i32 = { vanilla, loose, strict };
12
9
  export default i32;
13
10
  //# sourceMappingURL=i32.js.map
@@ -1,8 +1,8 @@
1
1
  import BigIntType from "#BigIntType";
2
2
  declare const i64: {
3
- vanilla: BigIntType<"i64">;
4
- loose: BigIntType<"i64">;
5
- strict: BigIntType<"i64">;
3
+ vanilla: BigIntType<"i64", undefined>;
4
+ loose: BigIntType<"i64", true>;
5
+ strict: BigIntType<"i64", false>;
6
6
  };
7
7
  export default i64;
8
8
  //# sourceMappingURL=i64.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import BigIntType from "#BigIntType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = -(2n ** 63n);
5
4
  const to = (2n ** 63n) - 1n;
6
- const vanilla = new BigIntType("i64", [range(from, to)]);
7
- const loose = new BigIntType("i64", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new BigIntType("i64", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new BigIntType("i64", undefined, [range(from, to)]);
6
+ const loose = new BigIntType("i64", true, [range(from, to)]);
7
+ const strict = new BigIntType("i64", false, [range(from, to)]);
11
8
  const i64 = { vanilla, loose, strict };
12
9
  export default i64;
13
10
  //# sourceMappingURL=i64.js.map
@@ -1,8 +1,8 @@
1
1
  import IntType from "#IntType";
2
2
  declare const i8: {
3
- vanilla: IntType<"i8">;
4
- loose: IntType<"i8">;
5
- strict: IntType<"i8">;
3
+ vanilla: IntType<"i8", undefined>;
4
+ loose: IntType<"i8", true>;
5
+ strict: IntType<"i8", false>;
6
6
  };
7
7
  export default i8;
8
8
  //# sourceMappingURL=i8.d.ts.map
package/lib/private/i8.js CHANGED
@@ -1,13 +1,10 @@
1
1
  import IntType from "#IntType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = -(2 ** 7);
5
4
  const to = 2 ** 7 - 1;
6
- const vanilla = new IntType("i8", [range(from, to)]);
7
- const loose = new IntType("i8", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new IntType("i8", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new IntType("i8", undefined, [range(from, to)]);
6
+ const loose = new IntType("i8", true, [range(from, to)]);
7
+ const strict = new IntType("i8", false, [range(from, to)]);
11
8
  const i8 = { vanilla, loose, strict };
12
9
  export default i8;
13
10
  //# sourceMappingURL=i8.js.map