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
@@ -47,61 +47,259 @@ import type Schema from "#Schema";
47
47
  */
48
48
  declare function schema<const S extends Schema>(s: S): NormalizeSchema<S>;
49
49
  declare namespace schema {
50
- export var array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>>;
51
- export var bigint: import("./BigIntType.js").default<"i64">;
52
- export var biguint: import("./BigUintType.js").default<"u64">;
53
- export var blob: import("#BlobType").default;
54
- export var boolean: import("#BooleanType").default;
55
- export var constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
56
- export var date: import("#DateType").default;
57
- export var dict: {
50
+ var array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>>;
51
+ }
52
+ declare namespace schema {
53
+ var bigint: import("./BigIntType.js").default<"i64", undefined>;
54
+ }
55
+ declare namespace schema {
56
+ var biguint: import("./BigUintType.js").default<"u64", undefined>;
57
+ }
58
+ declare namespace schema {
59
+ var blob: import("#BlobType").default;
60
+ }
61
+ declare namespace schema {
62
+ var boolean: import("#BooleanType").default<undefined>;
63
+ }
64
+ declare namespace schema {
65
+ var constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
66
+ }
67
+ declare namespace schema {
68
+ var date: import("#DateType").default<undefined>;
69
+ }
70
+ declare namespace schema {
71
+ var dict: {
58
72
  (): import("#RecordType").default<import("#StringType").default, import("#StringType").default>;
59
73
  <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value>;
60
74
  };
75
+ }
76
+ declare namespace schema {
61
77
  var _a: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
62
- export var f32: import("#NumberType").default<"f32">;
63
- export var f64: import("#NumberType").default<"f64">;
64
- export var file: import("./FileType.js").default;
78
+ export { _a as enum };
79
+ }
80
+ declare namespace schema {
81
+ var f32: import("#NumberType").default<"f32", undefined>;
82
+ }
83
+ declare namespace schema {
84
+ var f64: import("#NumberType").default<"f64", undefined>;
85
+ }
86
+ declare namespace schema {
87
+ var file: import("./FileType.js").default;
88
+ }
89
+ declare namespace schema {
65
90
  var _b: import("#FunctionType").default;
66
- export var i128: import("./BigIntType.js").default<"i128">;
67
- export var i16: import("./IntType.js").default<"i16">;
68
- export var i32: import("./IntType.js").default<"i32">;
69
- export var i64: import("./BigIntType.js").default<"i64">;
70
- export var i8: import("./IntType.js").default<"i8">;
71
- export var int: import("./IntType.js").default<"i32">;
72
- export var is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
73
- export var json: {
91
+ export { _b as function };
92
+ }
93
+ declare namespace schema {
94
+ var i128: import("./BigIntType.js").default<"i128", undefined>;
95
+ }
96
+ declare namespace schema {
97
+ var i16: import("./IntType.js").default<"i16", undefined>;
98
+ }
99
+ declare namespace schema {
100
+ var i32: import("./IntType.js").default<"i32", undefined>;
101
+ }
102
+ declare namespace schema {
103
+ var i64: import("./BigIntType.js").default<"i64", undefined>;
104
+ }
105
+ declare namespace schema {
106
+ var i8: import("./IntType.js").default<"i8", undefined>;
107
+ }
108
+ declare namespace schema {
109
+ var int: import("./IntType.js").default<"i32", undefined>;
110
+ }
111
+ declare namespace schema {
112
+ var is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
113
+ }
114
+ declare namespace schema {
115
+ var json: {
74
116
  (): import("#JSONType").default<undefined>;
75
117
  <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
76
118
  };
77
- export var literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T>;
119
+ }
120
+ declare namespace schema {
121
+ var literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, undefined>;
122
+ }
123
+ declare namespace schema {
78
124
  var _c: import("#NullType").default;
79
- export var number: import("#NumberType").default<"f64">;
80
- export var object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }>;
81
- export var omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K>;
82
- export var record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value>;
83
- export var partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }>;
84
- export var pure: <T>() => import("#PureType").default<T, "PureType">;
85
- export var string: import("#StringType").default;
86
- export var symbol: import("./SymbolType.js").default;
87
- export var tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
88
- export var u128: import("./BigUintType.js").default<"u128">;
89
- export var u16: import("#UintType").default<"u16">;
90
- export var u32: import("#UintType").default<"u32">;
91
- export var u64: import("./BigUintType.js").default<"u64">;
92
- export var u8: import("#UintType").default<"u8">;
93
- export var uint: import("#UintType").default<"u32">;
94
- export var undefined: import("#UndefinedType").default;
95
- export var union: {
125
+ export { _c as null };
126
+ }
127
+ declare namespace schema {
128
+ var number: import("#NumberType").default<"f64", undefined>;
129
+ }
130
+ declare namespace schema {
131
+ var object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }>;
132
+ }
133
+ declare namespace schema {
134
+ var omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K>;
135
+ }
136
+ declare namespace schema {
137
+ var record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, undefined>;
138
+ }
139
+ declare namespace schema {
140
+ var partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }>;
141
+ }
142
+ declare namespace schema {
143
+ var pure: <T>() => import("#PureType").default<T, "PureType">;
144
+ }
145
+ declare namespace schema {
146
+ var string: import("#StringType").default;
147
+ }
148
+ declare namespace schema {
149
+ var symbol: import("./SymbolType.js").default;
150
+ }
151
+ declare namespace schema {
152
+ var tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
153
+ }
154
+ declare namespace schema {
155
+ var u128: import("./BigUintType.js").default<"u128", undefined>;
156
+ }
157
+ declare namespace schema {
158
+ var u16: import("#UintType").default<"u16", undefined>;
159
+ }
160
+ declare namespace schema {
161
+ var u32: import("#UintType").default<"u32", undefined>;
162
+ }
163
+ declare namespace schema {
164
+ var u64: import("./BigUintType.js").default<"u64", undefined>;
165
+ }
166
+ declare namespace schema {
167
+ var u8: import("#UintType").default<"u8", undefined>;
168
+ }
169
+ declare namespace schema {
170
+ var uint: import("#UintType").default<"u32", undefined>;
171
+ }
172
+ declare namespace schema {
173
+ var undefined: import("#UndefinedType").default;
174
+ }
175
+ declare namespace schema {
176
+ var union: {
96
177
  (): import("#UnionType").default<[]>;
97
178
  <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
98
179
  };
99
- export var unknown: import("#UnknownType").default;
100
- export var url: import("#URLType").default;
101
- export var uuid: import("#UUIDType").default;
102
- export var loose: typeof schema;
103
- export var strict: typeof schema;
104
- export { _a as enum, _b as function, _c as null };
180
+ }
181
+ declare namespace schema {
182
+ var unknown: import("#UnknownType").default;
183
+ }
184
+ declare namespace schema {
185
+ var url: import("#URLType").default<undefined>;
186
+ }
187
+ declare namespace schema {
188
+ var uuid: import("#UUIDType").default;
189
+ }
190
+ declare namespace schema {
191
+ var loose: {
192
+ <const S extends Schema>(s: S): NormalizeSchema<S>;
193
+ array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, true>;
194
+ bigint: import("./BigIntType.js").default<"i64", true>;
195
+ biguint: import("./BigUintType.js").default<"u64", true>;
196
+ blob: import("#BlobType").default;
197
+ boolean: import("#BooleanType").default<true>;
198
+ constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
199
+ date: import("#DateType").default<true>;
200
+ dict: {
201
+ (): import("#RecordType").default<import("#StringType").default, import("#StringType").default, true>;
202
+ <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, true>;
203
+ };
204
+ enum: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
205
+ f32: import("#NumberType").default<"f32", true>;
206
+ f64: import("#NumberType").default<"f64", true>;
207
+ file: import("./FileType.js").default;
208
+ function: import("#FunctionType").default;
209
+ i128: import("./BigIntType.js").default<"i128", true>;
210
+ i16: import("./IntType.js").default<"i16", true>;
211
+ i32: import("./IntType.js").default<"i32", true>;
212
+ i64: import("./BigIntType.js").default<"i64", true>;
213
+ i8: import("./IntType.js").default<"i8", true>;
214
+ int: import("./IntType.js").default<"i32", true>;
215
+ is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
216
+ json: {
217
+ (): import("#JSONType").default<undefined>;
218
+ <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
219
+ };
220
+ literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, true>;
221
+ null: import("#NullType").default;
222
+ number: import("#NumberType").default<"f64", true>;
223
+ object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }, true>;
224
+ omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K, true>;
225
+ record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, true>;
226
+ partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }, true>;
227
+ pure: <T>() => import("#PureType").default<T, "PureType">;
228
+ string: import("#StringType").default;
229
+ symbol: import("./SymbolType.js").default;
230
+ tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
231
+ u128: import("./BigUintType.js").default<"u128", true>;
232
+ u16: import("#UintType").default<"u16", true>;
233
+ u32: import("#UintType").default<"u32", true>;
234
+ u64: import("./BigUintType.js").default<"u64", true>;
235
+ u8: import("#UintType").default<"u8", true>;
236
+ uint: import("#UintType").default<"u32", true>;
237
+ undefined: import("#UndefinedType").default;
238
+ union: {
239
+ (): import("#UnionType").default<[], true>;
240
+ <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
241
+ };
242
+ unknown: import("#UnknownType").default;
243
+ url: import("#URLType").default<true>;
244
+ uuid: import("#UUIDType").default;
245
+ };
246
+ }
247
+ declare namespace schema {
248
+ var strict: {
249
+ <const S extends Schema>(s: S): NormalizeSchema<S>;
250
+ array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, false>;
251
+ bigint: import("./BigIntType.js").default<"i64", false>;
252
+ biguint: import("./BigUintType.js").default<"u64", false>;
253
+ blob: import("#BlobType").default;
254
+ boolean: import("#BooleanType").default<false>;
255
+ constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
256
+ date: import("#DateType").default<false>;
257
+ dict: {
258
+ (): import("#RecordType").default<import("#StringType").default, import("#StringType").default, false>;
259
+ <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, false>;
260
+ };
261
+ enum: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
262
+ f32: import("#NumberType").default<"f32", false>;
263
+ f64: import("#NumberType").default<"f64", false>;
264
+ file: import("./FileType.js").default;
265
+ function: import("#FunctionType").default;
266
+ i128: import("./BigIntType.js").default<"i128", false>;
267
+ i16: import("./IntType.js").default<"i16", false>;
268
+ i32: import("./IntType.js").default<"i32", false>;
269
+ i64: import("./BigIntType.js").default<"i64", false>;
270
+ i8: import("./IntType.js").default<"i8", false>;
271
+ int: import("./IntType.js").default<"i32", false>;
272
+ is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
273
+ json: {
274
+ (): import("#JSONType").default<undefined>;
275
+ <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
276
+ };
277
+ literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, false>;
278
+ null: import("#NullType").default;
279
+ number: import("#NumberType").default<"f64", false>;
280
+ object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }, false>;
281
+ omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K, false>;
282
+ record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, false>;
283
+ partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }, false>;
284
+ pure: <T>() => import("#PureType").default<T, "PureType">;
285
+ string: import("#StringType").default;
286
+ symbol: import("./SymbolType.js").default;
287
+ tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
288
+ u128: import("./BigUintType.js").default<"u128", false>;
289
+ u16: import("#UintType").default<"u16", false>;
290
+ u32: import("#UintType").default<"u32", false>;
291
+ u64: import("./BigUintType.js").default<"u64", false>;
292
+ u8: import("#UintType").default<"u8", false>;
293
+ uint: import("#UintType").default<"u32", false>;
294
+ undefined: import("#UndefinedType").default;
295
+ union: {
296
+ (): import("#UnionType").default<[], false>;
297
+ <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
298
+ };
299
+ unknown: import("#UnknownType").default;
300
+ url: import("#URLType").default<false>;
301
+ uuid: import("#UUIDType").default;
302
+ };
105
303
  }
106
304
  export default schema;
107
305
  //# sourceMappingURL=index.d.ts.map
package/lib/private/is.js CHANGED
@@ -1,15 +1,10 @@
1
1
  import IsType from "#IsType";
2
- import Loose from "#Loose";
3
2
  const vanilla = (predicate) => new IsType(predicate);
4
3
  const loose = (predicate) => {
5
- const i = new IsType(predicate);
6
- i[Loose] = true;
7
- return i;
4
+ return new IsType(predicate);
8
5
  };
9
6
  const strict = (predicate) => {
10
- const i = new IsType(predicate);
11
- i[Loose] = false;
12
- return i;
7
+ return new IsType(predicate);
13
8
  };
14
9
  const is = { vanilla, loose, strict };
15
10
  export default is;
@@ -1,17 +1,12 @@
1
1
  import JSONType from "#JSONType";
2
- import Loose from "#Loose";
3
2
  function vanilla(inner) {
4
3
  return new JSONType(inner);
5
4
  }
6
5
  function loose(inner) {
7
- const i = new JSONType(inner);
8
- i[Loose] = true;
9
- return i;
6
+ return new JSONType(inner);
10
7
  }
11
8
  function strict(inner) {
12
- const i = new JSONType(inner);
13
- i[Loose] = false;
14
- return i;
9
+ return new JSONType(inner);
15
10
  }
16
11
  const json = { vanilla, loose, strict };
17
12
  export default json;
@@ -1,12 +1,12 @@
1
1
  import LiteralType from "#LiteralType";
2
2
  type Literal = string | boolean | number;
3
- declare function vanilla<T extends Literal>(literal: T): LiteralType<T>;
4
- declare function loose<T extends Literal>(literal: T): LiteralType<T>;
5
- declare function strict<T extends Literal>(literal: T): LiteralType<T>;
6
- declare const literal: {
3
+ declare function vanilla<T extends Literal>(literal: T): LiteralType<T, undefined>;
4
+ declare function loose<T extends Literal>(literal: T): LiteralType<T, true>;
5
+ declare function strict<T extends Literal>(literal: T): LiteralType<T, false>;
6
+ declare const _default: {
7
7
  vanilla: typeof vanilla;
8
8
  loose: typeof loose;
9
9
  strict: typeof strict;
10
10
  };
11
- export default literal;
11
+ export default _default;
12
12
  //# sourceMappingURL=literal.d.ts.map
@@ -1,18 +1,12 @@
1
1
  import LiteralType from "#LiteralType";
2
- import Loose from "#Loose";
3
2
  function vanilla(literal) {
4
3
  return new LiteralType(literal);
5
4
  }
6
5
  function loose(literal) {
7
- const i = new LiteralType(literal);
8
- i[Loose] = true;
9
- return i;
6
+ return new LiteralType(literal, true);
10
7
  }
11
8
  function strict(literal) {
12
- const i = new LiteralType(literal);
13
- i[Loose] = false;
14
- return i;
9
+ return new LiteralType(literal, false);
15
10
  }
16
- const literal = { vanilla, loose, strict };
17
- export default literal;
11
+ export default { vanilla, loose, strict };
18
12
  //# sourceMappingURL=literal.js.map
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import NullType from "#NullType";
3
2
  const vanilla = new NullType();
4
3
  const loose = new NullType();
5
- loose[Loose] = true;
6
4
  const strict = new NullType();
7
- strict[Loose] = false;
8
5
  const null_ = { vanilla, loose, strict };
9
6
  export default null_;
10
7
  //# sourceMappingURL=null.js.map
@@ -6,8 +6,8 @@ type NormalizeProps<S extends Dict<Schema>> = keyof S extends never ? EmptyDict
6
6
  [K in keyof S]: NormalizeSchema<S[K]>;
7
7
  };
8
8
  declare function vanilla<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
9
- declare function loose<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
10
- declare function strict<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
9
+ declare function loose<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>, true>;
10
+ declare function strict<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>, false>;
11
11
  declare const object: {
12
12
  vanilla: typeof vanilla;
13
13
  loose: typeof loose;
@@ -1,4 +1,3 @@
1
- import Loose from "#Loose";
2
1
  import normalize from "#normalize";
3
2
  import ObjectType from "#ObjectType";
4
3
  function vanilla(properties) {
@@ -13,18 +12,14 @@ function loose(properties) {
13
12
  for (const [k, v] of Object.entries(properties)) {
14
13
  props[k] = normalize(v);
15
14
  }
16
- const i = new ObjectType(props);
17
- i[Loose] = true;
18
- return i;
15
+ return new ObjectType(props, true);
19
16
  }
20
17
  function strict(properties) {
21
18
  const props = {};
22
19
  for (const [k, v] of Object.entries(properties)) {
23
20
  props[k] = normalize(v);
24
21
  }
25
- const i = new ObjectType(props);
26
- i[Loose] = false;
27
- return i;
22
+ return new ObjectType(props, false);
28
23
  }
29
24
  const object = { vanilla, loose, strict };
30
25
  export default object;
@@ -3,8 +3,8 @@ import OmitType from "#OmitType";
3
3
  import type Parsed from "#Parsed";
4
4
  import type { Dict } from "@rcompat/type";
5
5
  declare function vanilla<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K>;
6
- declare function loose<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K>;
7
- declare function strict<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K>;
6
+ declare function loose<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K, true>;
7
+ declare function strict<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K, false>;
8
8
  declare const omit: {
9
9
  vanilla: typeof vanilla;
10
10
  loose: typeof loose;
@@ -1,17 +1,12 @@
1
- import Loose from "#Loose";
2
1
  import OmitType from "#OmitType";
3
2
  function vanilla(type, ...keys) {
4
3
  return new OmitType(type, keys);
5
4
  }
6
5
  function loose(type, ...keys) {
7
- const i = new OmitType(type, keys);
8
- i[Loose] = true;
9
- return i;
6
+ return new OmitType(type, keys, true);
10
7
  }
11
8
  function strict(type, ...keys) {
12
- const i = new OmitType(type, keys);
13
- i[Loose] = false;
14
- return i;
9
+ return new OmitType(type, keys, false);
15
10
  }
16
11
  const omit = { vanilla, loose, strict };
17
12
  export default omit;
@@ -5,8 +5,8 @@ type StripReadonly<T> = {
5
5
  -readonly [K in keyof T]: T[K];
6
6
  };
7
7
  declare function vanilla<const D extends Partialable>(input: D | ObjectType<D>): PartialType<StripReadonly<D>>;
8
- declare function loose<const D extends Partialable>(input: D | ObjectType<D>): PartialType<StripReadonly<D>>;
9
- declare function strict<const D extends Partialable>(input: D | ObjectType<D>): PartialType<StripReadonly<D>>;
8
+ declare function loose<const D extends Partialable>(input: D | ObjectType<D>): PartialType<StripReadonly<D>, true>;
9
+ declare function strict<const D extends Partialable>(input: D | ObjectType<D>): PartialType<StripReadonly<D>, false>;
10
10
  declare const partial: {
11
11
  vanilla: typeof vanilla;
12
12
  loose: typeof loose;
@@ -1,4 +1,3 @@
1
- import Loose from "#Loose";
2
1
  import ObjectType from "#ObjectType";
3
2
  import PartialType from "#PartialType";
4
3
  function vanilla(input) {
@@ -7,15 +6,11 @@ function vanilla(input) {
7
6
  }
8
7
  function loose(input) {
9
8
  const dict = input instanceof ObjectType ? input.properties : input;
10
- const i = new PartialType(dict);
11
- i[Loose] = true;
12
- return i;
9
+ return new PartialType(dict, true);
13
10
  }
14
11
  function strict(input) {
15
12
  const dict = input instanceof ObjectType ? input.properties : input;
16
- const i = new PartialType(dict);
17
- i[Loose] = false;
18
- return i;
13
+ return new PartialType(dict, false);
19
14
  }
20
15
  const partial = { vanilla, loose, strict };
21
16
  export default partial;
@@ -1,17 +1,12 @@
1
- import Loose from "#Loose";
2
1
  import PureType from "#PureType";
3
2
  function vanilla() {
4
3
  return new PureType();
5
4
  }
6
5
  function loose() {
7
- const i = new PureType();
8
- i[Loose] = true;
9
- return i;
6
+ return new PureType();
10
7
  }
11
8
  function strict() {
12
- const i = new PureType();
13
- i[Loose] = false;
14
- return i;
9
+ return new PureType();
15
10
  }
16
11
  const pure = { vanilla, loose, strict };
17
12
  export default pure;
@@ -2,9 +2,9 @@ import type Parsed from "#Parsed";
2
2
  import RecordType from "#RecordType";
3
3
  import type RecordTypeKey from "#RecordTypeKey";
4
4
  declare const record: {
5
- vanilla: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value>;
6
- loose: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value>;
7
- strict: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value>;
5
+ vanilla: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, undefined>;
6
+ loose: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, true>;
7
+ strict: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, false>;
8
8
  };
9
9
  export default record;
10
10
  //# sourceMappingURL=record.d.ts.map
@@ -1,18 +1,13 @@
1
- import Loose from "#Loose";
2
1
  import RecordType from "#RecordType";
3
2
  /**
4
3
  * Value is a record of the given key and value types.
5
4
  */
6
5
  const vanilla = (k, v) => new RecordType(k, v);
7
6
  const loose = (k, v) => {
8
- const i = new RecordType(k, v);
9
- i[Loose] = true;
10
- return i;
7
+ return new RecordType(k, v, true);
11
8
  };
12
9
  const strict = (k, v) => {
13
- const i = new RecordType(k, v);
14
- i[Loose] = false;
15
- return i;
10
+ return new RecordType(k, v, false);
16
11
  };
17
12
  const record = { vanilla, loose, strict };
18
13
  export default record;
@@ -1,8 +1,9 @@
1
1
  import type BigIntDataType from "#BigIntDataType";
2
2
  import type BigIntType from "#BigIntType";
3
3
  declare const _default: <T extends BigIntDataType>(t: {
4
- loose: BigIntType<T>;
5
- strict: BigIntType<T>;
4
+ vanilla: BigIntType<T>;
5
+ loose: BigIntType<T, true>;
6
+ strict: BigIntType<T, false>;
6
7
  }, min: bigint, max: bigint) => void;
7
8
  export default _default;
8
9
  //# sourceMappingURL=bigint.d.ts.map
@@ -15,6 +15,7 @@ export default (t, min, max) => {
15
15
  assert(strict).out_of_range([min - 1n, max + 1n]);
16
16
  });
17
17
  test.case("loose", assert => {
18
+ assert(loose).type();
18
19
  assert(loose.parse(0n)).equals(0n).type();
19
20
  assert(loose.parse(1n)).equals(1n).type();
20
21
  assert(loose.parse(0)).equals(0n).type();
@@ -1,8 +1,9 @@
1
1
  import type BigUintDataType from "#BigUintDataType";
2
2
  import type BigUintType from "#BigUintType";
3
3
  declare const _default: <T extends BigUintDataType>(t: {
4
- loose: BigUintType<T>;
5
- strict: BigUintType<T>;
4
+ vanilla: BigUintType<T>;
5
+ loose: BigUintType<T, true>;
6
+ strict: BigUintType<T, false>;
6
7
  }, min: bigint, max: bigint) => void;
7
8
  export default _default;
8
9
  //# sourceMappingURL=biguint.d.ts.map
@@ -15,6 +15,7 @@ export default (t, min, max) => {
15
15
  assert(strict).out_of_range([-1n, min - 1n, max + 1n]);
16
16
  });
17
17
  test.case("loose", assert => {
18
+ assert(loose).type();
18
19
  assert(loose.parse(0n)).equals(0n).type();
19
20
  assert(loose.parse(1n)).equals(1n).type();
20
21
  assert(loose.parse(0)).equals(0n).type();
@@ -33,6 +34,12 @@ export default (t, min, max) => {
33
34
  assert(d.parse(0n)).equals(0n).type();
34
35
  assert(d).invalid_type([1.2, -1.2]);
35
36
  });
37
+ [strict.default(-1n), strict.default(() => -1n)].forEach(d => {
38
+ assert(d).type();
39
+ assert(d).out_of_range([undefined]);
40
+ assert(d.parse(1n)).equals(1n).type();
41
+ assert(d.parse(0n)).equals(0n).type();
42
+ });
36
43
  });
37
44
  test.case("validator - range", assert => {
38
45
  const r = strict.range(0n, 10n);
@@ -1,8 +1,9 @@
1
1
  import type IntDataType from "#IntDataType";
2
2
  import type IntType from "#IntType";
3
3
  declare const _default: <T extends IntDataType>(t: {
4
- loose: IntType<T>;
5
- strict: IntType<T>;
4
+ vanilla: IntType<T>;
5
+ loose: IntType<T, true>;
6
+ strict: IntType<T, false>;
6
7
  }, min: number, max: number) => void;
7
8
  export default _default;
8
9
  //# sourceMappingURL=int.d.ts.map