@sinclair/typebox 0.32.0-dev-20 → 0.32.0-dev-22

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 (208) hide show
  1. package/build/import/compiler/compiler.mjs +62 -62
  2. package/build/import/errors/errors.mjs +62 -62
  3. package/build/import/index.d.mts +6 -6
  4. package/build/import/index.mjs +1 -1
  5. package/build/import/type/awaited/awaited.d.mts +4 -6
  6. package/build/import/type/awaited/awaited.mjs +3 -3
  7. package/build/import/type/composite/composite.d.mts +8 -8
  8. package/build/import/type/const/const.d.mts +4 -7
  9. package/build/import/type/constructor/constructor.d.mts +4 -4
  10. package/build/import/type/deref/deref.d.mts +2 -2
  11. package/build/import/type/deref/deref.mjs +26 -36
  12. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +4 -6
  13. package/build/import/type/exclude/exclude.d.mts +7 -8
  14. package/build/import/type/extends/extends-from-mapped-key.d.mts +5 -8
  15. package/build/import/type/extends/extends-from-mapped-key.mjs +3 -3
  16. package/build/import/type/extends/extends-from-mapped-result.d.mts +4 -6
  17. package/build/import/type/extends/extends.d.mts +2 -3
  18. package/build/import/type/extract/extract-from-mapped-result.d.mts +4 -6
  19. package/build/import/type/extract/extract.d.mts +8 -8
  20. package/build/import/type/function/function.d.mts +1 -1
  21. package/build/import/type/helpers/helpers.d.mts +1 -1
  22. package/build/import/type/index.d.mts +0 -1
  23. package/build/import/type/index.mjs +0 -1
  24. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +5 -8
  25. package/build/import/type/indexed/indexed-from-mapped-key.mjs +3 -6
  26. package/build/import/type/indexed/indexed-property-keys.d.mts +5 -8
  27. package/build/import/type/indexed/indexed-property-keys.mjs +6 -11
  28. package/build/import/type/indexed/indexed.d.mts +13 -23
  29. package/build/import/type/indexed/indexed.mjs +13 -13
  30. package/build/import/type/intersect/intersect-create.mjs +0 -1
  31. package/build/import/type/intersect/intersect-evaluated.d.mts +7 -11
  32. package/build/import/type/intersect/intersect-evaluated.mjs +12 -7
  33. package/build/import/type/intersect/intersect-type.d.mts +2 -2
  34. package/build/import/type/intersect/intersect.mjs +1 -2
  35. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +7 -9
  36. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +3 -3
  37. package/build/import/type/intrinsic/intrinsic.d.mts +6 -8
  38. package/build/import/type/intrinsic/intrinsic.mjs +8 -6
  39. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +4 -6
  40. package/build/import/type/keyof/keyof-property-keys.d.mts +9 -13
  41. package/build/import/type/keyof/keyof-property-keys.mjs +12 -9
  42. package/build/import/type/keyof/keyof.d.mts +7 -8
  43. package/build/import/type/keyof/keyof.mjs +8 -6
  44. package/build/import/type/mapped/mapped.d.mts +9 -13
  45. package/build/import/type/mapped/mapped.mjs +9 -9
  46. package/build/import/type/omit/omit-from-mapped-key.d.mts +5 -8
  47. package/build/import/type/omit/omit-from-mapped-key.mjs +3 -3
  48. package/build/import/type/omit/omit.d.mts +6 -9
  49. package/build/import/type/omit/omit.mjs +0 -1
  50. package/build/import/type/operators/operators.d.mts +16 -16
  51. package/build/import/type/operators/operators.mjs +21 -25
  52. package/build/import/type/optional/optional-from-mapped-result.d.mts +4 -6
  53. package/build/import/type/optional/optional.d.mts +3 -7
  54. package/build/import/type/partial/partial-from-mapped-result.d.mts +4 -6
  55. package/build/import/type/partial/partial.d.mts +4 -7
  56. package/build/import/type/partial/partial.mjs +6 -7
  57. package/build/import/type/pick/pick-from-mapped-key.d.mts +5 -8
  58. package/build/import/type/pick/pick-from-mapped-key.mjs +3 -3
  59. package/build/import/type/pick/pick.d.mts +4 -4
  60. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +4 -6
  61. package/build/import/type/readonly/readonly.d.mts +3 -7
  62. package/build/import/type/record/record.d.mts +14 -20
  63. package/build/import/type/record/record.mjs +2 -4
  64. package/build/import/type/ref/ref.mjs +3 -0
  65. package/build/import/type/required/required-from-mapped-result.d.mts +4 -6
  66. package/build/import/type/required/required.d.mts +5 -9
  67. package/build/import/type/required/required.mjs +6 -7
  68. package/build/import/type/rest/rest.d.mts +3 -3
  69. package/build/import/type/schema/schema.d.mts +1 -1
  70. package/build/import/type/static/static.d.mts +1 -1
  71. package/build/import/type/symbol/symbol.d.mts +1 -1
  72. package/build/import/type/template-literal/finite.d.mts +7 -5
  73. package/build/import/type/template-literal/finite.mjs +14 -5
  74. package/build/import/type/template-literal/generate.d.mts +14 -9
  75. package/build/import/type/template-literal/generate.mjs +19 -9
  76. package/build/import/type/template-literal/index.d.mts +1 -1
  77. package/build/import/type/template-literal/index.mjs +1 -1
  78. package/build/import/type/template-literal/{parser.mjs → parse.mjs} +7 -2
  79. package/build/import/type/template-literal/syntax.d.mts +3 -3
  80. package/build/import/type/template-literal/syntax.mjs +2 -3
  81. package/build/import/type/template-literal/template-literal.d.mts +2 -2
  82. package/build/import/type/template-literal/template-literal.mjs +1 -1
  83. package/build/import/type/template-literal/union.d.mts +2 -2
  84. package/build/import/type/template-literal/union.mjs +5 -10
  85. package/build/import/type/transform/transform.mjs +0 -1
  86. package/build/import/type/tuple/tuple.d.mts +1 -2
  87. package/build/import/type/type/json.d.mts +2 -2
  88. package/build/import/type/union/union-evaluated.d.mts +6 -10
  89. package/build/import/type/union/union-evaluated.mjs +7 -2
  90. package/build/import/value/cast/cast.mjs +20 -20
  91. package/build/import/value/check/check.mjs +62 -62
  92. package/build/import/value/clean/clean.mjs +16 -16
  93. package/build/import/value/convert/convert.mjs +36 -36
  94. package/build/import/value/create/create.mjs +66 -67
  95. package/build/import/value/default/default.mjs +16 -16
  96. package/build/import/value/transform/decode.mjs +18 -18
  97. package/build/import/value/transform/encode.mjs +18 -18
  98. package/build/import/value/transform/has.mjs +28 -28
  99. package/build/require/compiler/compiler.js +62 -62
  100. package/build/require/errors/errors.js +62 -62
  101. package/build/require/index.d.ts +6 -6
  102. package/build/require/index.js +4 -2
  103. package/build/require/type/awaited/awaited.d.ts +4 -6
  104. package/build/require/type/awaited/awaited.js +3 -3
  105. package/build/require/type/composite/composite.d.ts +8 -8
  106. package/build/require/type/const/const.d.ts +4 -7
  107. package/build/require/type/constructor/constructor.d.ts +4 -4
  108. package/build/require/type/deref/deref.d.ts +2 -2
  109. package/build/require/type/deref/deref.js +25 -35
  110. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +4 -6
  111. package/build/require/type/exclude/exclude.d.ts +7 -8
  112. package/build/require/type/extends/extends-from-mapped-key.d.ts +5 -8
  113. package/build/require/type/extends/extends-from-mapped-key.js +3 -3
  114. package/build/require/type/extends/extends-from-mapped-result.d.ts +4 -6
  115. package/build/require/type/extends/extends.d.ts +2 -3
  116. package/build/require/type/extract/extract-from-mapped-result.d.ts +4 -6
  117. package/build/require/type/extract/extract.d.ts +8 -8
  118. package/build/require/type/function/function.d.ts +1 -1
  119. package/build/require/type/helpers/helpers.d.ts +1 -1
  120. package/build/require/type/index.d.ts +0 -1
  121. package/build/require/type/index.js +0 -1
  122. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +5 -8
  123. package/build/require/type/indexed/indexed-from-mapped-key.js +3 -6
  124. package/build/require/type/indexed/indexed-property-keys.d.ts +5 -8
  125. package/build/require/type/indexed/indexed-property-keys.js +4 -9
  126. package/build/require/type/indexed/indexed.d.ts +13 -23
  127. package/build/require/type/indexed/indexed.js +13 -13
  128. package/build/require/type/intersect/intersect-create.js +0 -1
  129. package/build/require/type/intersect/intersect-evaluated.d.ts +7 -11
  130. package/build/require/type/intersect/intersect-evaluated.js +9 -4
  131. package/build/require/type/intersect/intersect-type.d.ts +2 -2
  132. package/build/require/type/intersect/intersect.js +0 -1
  133. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +7 -9
  134. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +3 -3
  135. package/build/require/type/intrinsic/intrinsic.d.ts +6 -8
  136. package/build/require/type/intrinsic/intrinsic.js +7 -5
  137. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +4 -6
  138. package/build/require/type/keyof/keyof-property-keys.d.ts +9 -13
  139. package/build/require/type/keyof/keyof-property-keys.js +12 -9
  140. package/build/require/type/keyof/keyof.d.ts +7 -8
  141. package/build/require/type/keyof/keyof.js +8 -6
  142. package/build/require/type/mapped/mapped.d.ts +9 -13
  143. package/build/require/type/mapped/mapped.js +9 -9
  144. package/build/require/type/omit/omit-from-mapped-key.d.ts +5 -8
  145. package/build/require/type/omit/omit-from-mapped-key.js +3 -3
  146. package/build/require/type/omit/omit.d.ts +6 -9
  147. package/build/require/type/omit/omit.js +0 -1
  148. package/build/require/type/operators/operators.d.ts +16 -16
  149. package/build/require/type/operators/operators.js +21 -25
  150. package/build/require/type/optional/optional-from-mapped-result.d.ts +4 -6
  151. package/build/require/type/optional/optional.d.ts +3 -7
  152. package/build/require/type/partial/partial-from-mapped-result.d.ts +4 -6
  153. package/build/require/type/partial/partial.d.ts +4 -7
  154. package/build/require/type/partial/partial.js +6 -7
  155. package/build/require/type/pick/pick-from-mapped-key.d.ts +5 -8
  156. package/build/require/type/pick/pick-from-mapped-key.js +3 -3
  157. package/build/require/type/pick/pick.d.ts +4 -4
  158. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +4 -6
  159. package/build/require/type/readonly/readonly.d.ts +3 -7
  160. package/build/require/type/record/record.d.ts +14 -20
  161. package/build/require/type/record/record.js +1 -3
  162. package/build/require/type/ref/ref.js +3 -0
  163. package/build/require/type/required/required-from-mapped-result.d.ts +4 -6
  164. package/build/require/type/required/required.d.ts +5 -9
  165. package/build/require/type/required/required.js +6 -7
  166. package/build/require/type/rest/rest.d.ts +3 -3
  167. package/build/require/type/schema/schema.d.ts +1 -1
  168. package/build/require/type/static/static.d.ts +1 -1
  169. package/build/require/type/symbol/symbol.d.ts +1 -1
  170. package/build/require/type/template-literal/finite.d.ts +7 -5
  171. package/build/require/type/template-literal/finite.js +16 -6
  172. package/build/require/type/template-literal/generate.d.ts +14 -9
  173. package/build/require/type/template-literal/generate.js +22 -11
  174. package/build/require/type/template-literal/index.d.ts +1 -1
  175. package/build/require/type/template-literal/index.js +1 -1
  176. package/build/require/type/template-literal/{parser.js → parse.js} +7 -2
  177. package/build/require/type/template-literal/syntax.d.ts +3 -3
  178. package/build/require/type/template-literal/syntax.js +1 -2
  179. package/build/require/type/template-literal/template-literal.d.ts +2 -2
  180. package/build/require/type/template-literal/template-literal.js +1 -1
  181. package/build/require/type/template-literal/union.d.ts +2 -2
  182. package/build/require/type/template-literal/union.js +5 -10
  183. package/build/require/type/transform/transform.js +0 -1
  184. package/build/require/type/tuple/tuple.d.ts +1 -2
  185. package/build/require/type/type/json.d.ts +2 -2
  186. package/build/require/type/union/union-evaluated.d.ts +6 -10
  187. package/build/require/type/union/union-evaluated.js +7 -2
  188. package/build/require/value/cast/cast.js +20 -20
  189. package/build/require/value/check/check.js +62 -62
  190. package/build/require/value/clean/clean.js +16 -16
  191. package/build/require/value/convert/convert.js +36 -36
  192. package/build/require/value/create/create.js +65 -66
  193. package/build/require/value/default/default.js +16 -16
  194. package/build/require/value/transform/decode.js +18 -18
  195. package/build/require/value/transform/encode.js +18 -18
  196. package/build/require/value/transform/has.js +28 -28
  197. package/package.json +1 -1
  198. package/readme.md +47 -47
  199. package/build/import/type/modifiers/index.d.mts +0 -1
  200. package/build/import/type/modifiers/index.mjs +0 -1
  201. package/build/import/type/modifiers/modifiers.d.mts +0 -18
  202. package/build/import/type/modifiers/modifiers.mjs +0 -50
  203. package/build/require/type/modifiers/index.d.ts +0 -1
  204. package/build/require/type/modifiers/index.js +0 -18
  205. package/build/require/type/modifiers/modifiers.d.ts +0 -18
  206. package/build/require/type/modifiers/modifiers.js +0 -56
  207. /package/build/import/type/template-literal/{parser.d.mts → parse.d.mts} +0 -0
  208. /package/build/require/type/template-literal/{parser.d.ts → parse.d.ts} +0 -0
@@ -2,9 +2,9 @@ import type { TSchema } from '../schema/index.mjs';
2
2
  import type { TIntersect } from '../intersect/index.mjs';
3
3
  import type { TUnion } from '../union/index.mjs';
4
4
  import type { TTuple } from '../tuple/index.mjs';
5
- export type RestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
5
+ export type TRestResolve<T extends TSchema> = T extends TIntersect<infer S> ? [...S] : T extends TUnion<infer S> ? [...S] : T extends TTuple<infer S> ? [...S] : [
6
6
  ];
7
- export declare function RestResolve<T extends TSchema>(T: T): RestResolve<T>;
8
- export type TRest<T extends TSchema> = RestResolve<T>;
7
+ export declare function RestResolve<T extends TSchema>(T: T): TRestResolve<T>;
8
+ export type TRest<T extends TSchema> = TRestResolve<T>;
9
9
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
10
10
  export declare function Rest<T extends TSchema>(T: T): TRest<T>;
@@ -20,7 +20,7 @@ export interface SchemaOptions {
20
20
  export interface TKind {
21
21
  [Kind]: string;
22
22
  }
23
- export interface TSchema extends SchemaOptions, TKind {
23
+ export interface TSchema extends TKind, SchemaOptions {
24
24
  [ReadonlyKind]?: string;
25
25
  [OptionalKind]?: string;
26
26
  [Hint]?: string;
@@ -22,7 +22,7 @@ import type { TTransform } from '../transform/index.mjs';
22
22
  export type DecodeProperties<T extends TProperties> = {
23
23
  [K in keyof T]: DecodeType<T[K]>;
24
24
  };
25
- export type DecodeRest<T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [DecodeType<L>, ...DecodeRest<R>] : [];
25
+ export type DecodeRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? DecodeRest<R, [...Acc, DecodeType<L>]> : Acc;
26
26
  export type DecodeType<T extends TSchema> = (T extends TOptional<infer S extends TSchema> ? TOptional<DecodeType<S>> : T extends TReadonly<infer S extends TSchema> ? TReadonly<DecodeType<S>> : T extends TTransform<infer _, infer R> ? TUnsafe<R> : T extends TArray<infer S extends TSchema> ? TArray<DecodeType<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DecodeType<S>> : T extends TConstructor<infer P extends TSchema[], infer R extends TSchema> ? TConstructor<DecodeRest<P>, DecodeType<R>> : T extends TEnum<infer S> ? TEnum<S> : T extends TFunction<infer P extends TSchema[], infer R extends TSchema> ? TFunction<DecodeRest<P>, DecodeType<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<DecodeRest<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DecodeType<S>> : T extends TNot<infer S extends TSchema> ? TNot<DecodeType<S>> : T extends TObject<infer S> ? TObject<Evaluate<DecodeProperties<S>>> : T extends TPromise<infer S extends TSchema> ? TPromise<DecodeType<S>> : T extends TRecord<infer K, infer S> ? TRecord<K, DecodeType<S>> : T extends TRecursive<infer S extends TSchema> ? TRecursive<DecodeType<S>> : T extends TRef<infer S extends TSchema> ? TRef<DecodeType<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<DecodeRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<DecodeRest<S>> : T);
27
27
  /** Creates an decoded static type from a TypeBox type */
28
28
  export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<DecodeType<T>, P>;
@@ -1,6 +1,6 @@
1
1
  import { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import { Kind } from '../symbols/index.mjs';
3
- export type SymbolValue = string | number | undefined;
3
+ export type TSymbolValue = string | number | undefined;
4
4
  export interface TSymbol extends TSchema, SchemaOptions {
5
5
  [Kind]: 'Symbol';
6
6
  static: symbol;
@@ -6,11 +6,13 @@ import type { TNumber } from '../number/index.mjs';
6
6
  import type { TInteger } from '../integer/index.mjs';
7
7
  import type { TBigInt } from '../bigint/index.mjs';
8
8
  import type { TLiteral } from '../literal/index.mjs';
9
- import type { Expression } from './parser.mjs';
9
+ import type { Expression } from './parse.mjs';
10
10
  export declare class TemplateLiteralFiniteError extends Error {
11
11
  }
12
- type IsTemplateLiteralFiniteCheck<T> = T extends TTemplateLiteral<infer U extends TTemplateLiteralKind[]> ? IsTemplateLiteralFiniteArray<U> : T extends TUnion<infer U extends TTemplateLiteralKind[]> ? IsTemplateLiteralFiniteArray<U> : T extends TString ? false : T extends TBoolean ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TLiteral ? true : false;
13
- type IsTemplateLiteralFiniteArray<T extends TTemplateLiteralKind[]> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? IsTemplateLiteralFiniteCheck<L> extends false ? false : IsTemplateLiteralFiniteArray<R> : true;
14
- export type IsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ? IsTemplateLiteralFiniteArray<U> : false;
15
- export declare function IsTemplateLiteralFinite(expression: Expression): boolean;
12
+ type TFromTemplateLiteralKind<T> = T extends TTemplateLiteral<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TUnion<infer U extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<U> : T extends TString ? false : T extends TNumber ? false : T extends TInteger ? false : T extends TBigInt ? false : T extends TBoolean ? true : T extends TLiteral ? true : false;
13
+ type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? TFromTemplateLiteralKind<L> extends false ? false : TFromTemplateLiteralKinds<R> : true;
14
+ export declare function IsTemplateLiteralExpressionFinite(expression: Expression): boolean;
15
+ export type TIsTemplateLiteralFinite<T> = T extends TTemplateLiteral<infer U> ? TFromTemplateLiteralKinds<U> : false;
16
+ /** Returns true if this TemplateLiteral resolves to a finite set of values */
17
+ export declare function IsTemplateLiteralFinite<T extends TTemplateLiteral>(schema: T): boolean;
16
18
  export {};
@@ -1,3 +1,4 @@
1
+ import { TemplateLiteralParseExact } from './parse.mjs';
1
2
  // ------------------------------------------------------------------
2
3
  // TemplateLiteralFiniteError
3
4
  // ------------------------------------------------------------------
@@ -28,12 +29,20 @@ function IsBooleanExpression(expression) {
28
29
  function IsStringExpression(expression) {
29
30
  return expression.type === 'const' && expression.const === '.*';
30
31
  }
32
+ // ------------------------------------------------------------------
33
+ // IsTemplateLiteralExpressionFinite
34
+ // ------------------------------------------------------------------
31
35
  // prettier-ignore
32
- export function IsTemplateLiteralFinite(expression) {
33
- return (IsBooleanExpression(expression) ? true :
34
- IsNumberExpression(expression) || IsStringExpression(expression) ? false :
35
- (expression.type === 'and') ? expression.expr.every((expr) => IsTemplateLiteralFinite(expr)) :
36
- (expression.type === 'or') ? expression.expr.every((expr) => IsTemplateLiteralFinite(expr)) :
36
+ export function IsTemplateLiteralExpressionFinite(expression) {
37
+ return (IsNumberExpression(expression) || IsStringExpression(expression) ? false :
38
+ IsBooleanExpression(expression) ? true :
39
+ (expression.type === 'and') ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) :
40
+ (expression.type === 'or') ? expression.expr.every((expr) => IsTemplateLiteralExpressionFinite(expr)) :
37
41
  (expression.type === 'const') ? true :
38
42
  (() => { throw new TemplateLiteralFiniteError(`Unknown expression type`); })());
39
43
  }
44
+ /** Returns true if this TemplateLiteral resolves to a finite set of values */
45
+ export function IsTemplateLiteralFinite(schema) {
46
+ const expression = TemplateLiteralParseExact(schema.pattern);
47
+ return IsTemplateLiteralExpressionFinite(expression);
48
+ }
@@ -1,15 +1,20 @@
1
+ import { TIsTemplateLiteralFinite } from './finite.mjs';
2
+ import type { Assert } from '../helpers/index.mjs';
3
+ import type { TBoolean } from '../boolean/index.mjs';
1
4
  import type { TTemplateLiteral, TTemplateLiteralKind } from './index.mjs';
2
5
  import type { TLiteral, TLiteralValue } from '../literal/index.mjs';
3
- import type { Expression } from './parser.mjs';
6
+ import type { Expression } from './parse.mjs';
4
7
  import type { TUnion } from '../union/index.mjs';
5
- type StringReduceUnary<L extends string, R extends string[]> = R extends [infer A extends string, ...infer B extends string[]] ? [`${L}${A}`, ...StringReduceUnary<L, B>] : [];
6
- type StringReduceBinary<L extends string[], R extends string[]> = L extends [infer A extends string, ...infer B extends string[]] ? [...StringReduceUnary<A, R>, ...StringReduceBinary<B, R>] : [];
7
- type StringReduceMany<T extends string[][]> = T extends [infer L extends string[], infer R extends string[], ...infer Rest extends string[][]] ? StringReduceMany<[StringReduceBinary<L, R>, ...Rest]> : T;
8
- type StringReduce<T extends string[][], O = StringReduceMany<T>> = 0 extends keyof O ? O[0] : [];
9
- type TemplateLiteralReduceUnion<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [L['const'], ...TemplateLiteralReduceUnion<R>] : [];
10
- type TemplateLiteralReduce<T extends TTemplateLiteralKind[]> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? L extends TLiteral<infer S extends TLiteralValue> ? [[S], ...TemplateLiteralReduce<R>] : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? [TemplateLiteralReduceUnion<S>, ...TemplateLiteralReduce<R>] : [] : [];
11
8
  export declare class TemplateLiteralGenerateError extends Error {
12
9
  }
13
- export type TemplateLiteralGenerate<T> = T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TemplateLiteralReduce<S> extends infer R extends string[][] ? StringReduce<R> : [] : [];
14
- export declare function TemplateLiteralGenerate(expression: Expression): IterableIterator<string>;
10
+ type TStringReduceUnary<L extends string, R extends string[], Acc extends string[] = []> = R extends [infer A extends string, ...infer B extends string[]] ? TStringReduceUnary<L, B, [...Acc, `${L}${A}`]> : Acc;
11
+ type TStringReduceBinary<L extends string[], R extends string[], Acc extends string[] = []> = L extends [infer A extends string, ...infer B extends string[]] ? TStringReduceBinary<B, R, [...Acc, ...TStringReduceUnary<A, R>]> : Acc;
12
+ type TStringReduceMany<T extends string[][]> = T extends [infer L extends string[], infer R extends string[], ...infer Rest extends string[][]] ? TStringReduceMany<[TStringReduceBinary<L, R>, ...Rest]> : T;
13
+ type TStringReduce<T extends string[][], O = TStringReduceMany<T>> = 0 extends keyof O ? Assert<O[0], string[]> : [];
14
+ type TFromTemplateLiteralUnionKinds<T extends TTemplateLiteralKind[]> = T extends [infer L extends TLiteral, ...infer R extends TLiteral[]] ? [L['const'], ...TFromTemplateLiteralUnionKinds<R>] : [];
15
+ type TFromTemplateLiteralKinds<T extends TTemplateLiteralKind[], Acc extends TLiteralValue[][] = []> = T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? (L extends TLiteral<infer S extends TLiteralValue> ? TFromTemplateLiteralKinds<R, [...Acc, [S]]> : L extends TUnion<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<R, [...Acc, TFromTemplateLiteralUnionKinds<S>]> : L extends TBoolean ? TFromTemplateLiteralKinds<R, [...Acc, ['true', 'false']]> : Acc) : Acc;
16
+ export declare function TemplateLiteralExpressionGenerate(expression: Expression): IterableIterator<string>;
17
+ export type TTemplateLiteralGenerate<T extends TTemplateLiteral, F = TIsTemplateLiteralFinite<T>> = F extends true ? (T extends TTemplateLiteral<infer S extends TTemplateLiteralKind[]> ? TFromTemplateLiteralKinds<S> extends infer R extends string[][] ? TStringReduce<R> : [] : []) : [];
18
+ /** Generates a tuple of strings from the given TemplateLiteral. Returns an empty tuple if infinite. */
19
+ export declare function TemplateLiteralGenerate<T extends TTemplateLiteral>(schema: T): TTemplateLiteralGenerate<T>;
15
20
  export {};
@@ -1,5 +1,12 @@
1
+ import { IsTemplateLiteralExpressionFinite } from './finite.mjs';
2
+ import { TemplateLiteralParseExact } from './parse.mjs';
1
3
  // ------------------------------------------------------------------
2
- // GenerateFromExpression
4
+ // TemplateLiteralGenerateError
5
+ // ------------------------------------------------------------------
6
+ export class TemplateLiteralGenerateError extends Error {
7
+ }
8
+ // ------------------------------------------------------------------
9
+ // TemplateLiteralExpressionGenerate
3
10
  // ------------------------------------------------------------------
4
11
  // prettier-ignore
5
12
  function* GenerateReduce(buffer) {
@@ -13,23 +20,18 @@ function* GenerateReduce(buffer) {
13
20
  }
14
21
  // prettier-ignore
15
22
  function* GenerateAnd(expression) {
16
- return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralGenerate(expr)]));
23
+ return yield* GenerateReduce(expression.expr.map((expr) => [...TemplateLiteralExpressionGenerate(expr)]));
17
24
  }
18
25
  // prettier-ignore
19
26
  function* GenerateOr(expression) {
20
27
  for (const expr of expression.expr)
21
- yield* TemplateLiteralGenerate(expr);
28
+ yield* TemplateLiteralExpressionGenerate(expr);
22
29
  }
23
30
  // prettier-ignore
24
31
  function* GenerateConst(expression) {
25
32
  return yield expression.const;
26
33
  }
27
- // ------------------------------------------------------------------
28
- // TemplateLiteralGenerateError
29
- // ------------------------------------------------------------------
30
- export class TemplateLiteralGenerateError extends Error {
31
- }
32
- export function* TemplateLiteralGenerate(expression) {
34
+ export function* TemplateLiteralExpressionGenerate(expression) {
33
35
  return expression.type === 'and'
34
36
  ? yield* GenerateAnd(expression)
35
37
  : expression.type === 'or'
@@ -40,3 +42,11 @@ export function* TemplateLiteralGenerate(expression) {
40
42
  throw new TemplateLiteralGenerateError('Unknown expression');
41
43
  })();
42
44
  }
45
+ /** Generates a tuple of strings from the given TemplateLiteral. Returns an empty tuple if infinite. */
46
+ export function TemplateLiteralGenerate(schema) {
47
+ const expression = TemplateLiteralParseExact(schema.pattern);
48
+ // prettier-ignore
49
+ return (IsTemplateLiteralExpressionFinite(expression)
50
+ ? [...TemplateLiteralExpressionGenerate(expression)]
51
+ : []);
52
+ }
@@ -1,7 +1,7 @@
1
1
  export * from './finite.mjs';
2
2
  export * from './generate.mjs';
3
3
  export * from './syntax.mjs';
4
- export * from './parser.mjs';
4
+ export * from './parse.mjs';
5
5
  export * from './pattern.mjs';
6
6
  export * from './union.mjs';
7
7
  export * from './template-literal.mjs';
@@ -1,7 +1,7 @@
1
1
  export * from './finite.mjs';
2
2
  export * from './generate.mjs';
3
3
  export * from './syntax.mjs';
4
- export * from './parser.mjs';
4
+ export * from './parse.mjs';
5
5
  export * from './pattern.mjs';
6
6
  export * from './union.mjs';
7
7
  export * from './template-literal.mjs';
@@ -127,16 +127,21 @@ function And(pattern) {
127
127
  (expressions.length === 1) ? expressions[0] :
128
128
  { type: 'and', expr: expressions });
129
129
  }
130
+ // ------------------------------------------------------------------
131
+ // TemplateLiteralParse
132
+ // ------------------------------------------------------------------
130
133
  /** Parses a pattern and returns an expression tree */
131
- // prettier-ignore
132
134
  export function TemplateLiteralParse(pattern) {
135
+ // prettier-ignore
133
136
  return (IsGroup(pattern) ? TemplateLiteralParse(InGroup(pattern)) :
134
137
  IsPrecedenceOr(pattern) ? Or(pattern) :
135
138
  IsPrecedenceAnd(pattern) ? And(pattern) :
136
139
  { type: 'const', const: pattern });
137
140
  }
141
+ // ------------------------------------------------------------------
142
+ // TemplateLiteralParseExact
143
+ // ------------------------------------------------------------------
138
144
  /** Parses a pattern and strips forward and trailing ^ and $ */
139
- // prettier-ignore
140
145
  export function TemplateLiteralParseExact(pattern) {
141
146
  return TemplateLiteralParse(pattern.slice(1, pattern.length - 1));
142
147
  }
@@ -5,16 +5,16 @@ import { type TBoolean } from '../boolean/index.mjs';
5
5
  import { type TBigInt } from '../bigint/index.mjs';
6
6
  import { type TNumber } from '../number/index.mjs';
7
7
  import { type TString } from '../string/index.mjs';
8
- import { UnionEvaluated } from '../union/index.mjs';
8
+ import { type TUnionEvaluated } from '../union/index.mjs';
9
9
  declare function FromUnion(syntax: string): IterableIterator<TTemplateLiteralKind>;
10
10
  declare function FromTerminal(syntax: string): IterableIterator<TTemplateLiteralKind>;
11
11
  type FromUnionLiteral<T extends string> = T extends `${infer L}|${infer R}` ? [TLiteral<Trim<L>>, ...FromUnionLiteral<R>] : T extends `${infer L}` ? [TLiteral<Trim<L>>] : [
12
12
  ];
13
- type FromUnion<T extends string> = UnionEvaluated<FromUnionLiteral<T>>;
13
+ type FromUnion<T extends string> = TUnionEvaluated<FromUnionLiteral<T>>;
14
14
  type FromTerminal<T extends string> = T extends 'boolean' ? TBoolean : T extends 'bigint' ? TBigInt : T extends 'number' ? TNumber : T extends 'string' ? TString : FromUnion<T>;
15
15
  type FromString<T extends string> = T extends `{${infer L}}${infer R}` ? [FromTerminal<L>, ...FromString<R>] : T extends `${infer L}$${infer R}` ? [TLiteral<L>, ...FromString<R>] : T extends `${infer L}` ? [TLiteral<L>] : [
16
16
  ];
17
- export type TemplateLiteralSyntax<T extends string> = (TTemplateLiteral<Assert<FromString<T>, TTemplateLiteralKind[]>>);
17
+ export type TTemplateLiteralSyntax<T extends string> = (TTemplateLiteral<Assert<FromString<T>, TTemplateLiteralKind[]>>);
18
18
  /** Parses TemplateLiteralSyntax and returns a tuple of TemplateLiteralKinds */
19
19
  export declare function TemplateLiteralSyntax(syntax: string): TTemplateLiteralKind[];
20
20
  export {};
@@ -3,7 +3,7 @@ import { Boolean } from '../boolean/index.mjs';
3
3
  import { BigInt } from '../bigint/index.mjs';
4
4
  import { Number } from '../number/index.mjs';
5
5
  import { String } from '../string/index.mjs';
6
- import { Union } from '../union/index.mjs';
6
+ import { UnionEvaluated } from '../union/index.mjs';
7
7
  import { Never } from '../never/index.mjs';
8
8
  // ------------------------------------------------------------------
9
9
  // SyntaxParsers
@@ -19,7 +19,7 @@ function* FromUnion(syntax) {
19
19
  const literals = trim.split('|').map((literal) => Literal(literal.trim()));
20
20
  return (literals.length === 0 ? Never() :
21
21
  literals.length === 1 ? literals[0] :
22
- Union(literals));
22
+ UnionEvaluated(literals));
23
23
  })());
24
24
  }
25
25
  // prettier-ignore
@@ -49,7 +49,6 @@ function* FromSyntax(syntax) {
49
49
  }
50
50
  yield Literal(syntax);
51
51
  }
52
- // prettier-ignore
53
52
  /** Parses TemplateLiteralSyntax and returns a tuple of TemplateLiteralKinds */
54
53
  export function TemplateLiteralSyntax(syntax) {
55
54
  return [...FromSyntax(syntax)];
@@ -9,7 +9,7 @@ import type { TString } from '../string/index.mjs';
9
9
  import type { TBoolean } from '../boolean/index.mjs';
10
10
  import type { TNever } from '../never/index.mjs';
11
11
  import type { Static } from '../static/index.mjs';
12
- import { TemplateLiteralSyntax } from './syntax.mjs';
12
+ import { TTemplateLiteralSyntax } from './syntax.mjs';
13
13
  import { EmptyString } from '../helpers/index.mjs';
14
14
  import { Kind } from '../symbols/index.mjs';
15
15
  type TemplateLiteralStaticKind<T, Acc extends string> = T extends TUnion<infer U> ? {
@@ -24,7 +24,7 @@ export interface TTemplateLiteral<T extends TTemplateLiteralKind[] = TTemplateLi
24
24
  pattern: string;
25
25
  }
26
26
  /** `[Json]` Creates a TemplateLiteral type from template dsl string */
27
- export declare function TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TemplateLiteralSyntax<T>;
27
+ export declare function TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TTemplateLiteralSyntax<T>;
28
28
  /** `[Json]` Creates a TemplateLiteral type */
29
29
  export declare function TemplateLiteral<T extends TTemplateLiteralKind[]>(kinds: [...T], options?: SchemaOptions): TTemplateLiteral<T>;
30
30
  export {};
@@ -1,5 +1,5 @@
1
- import { TemplateLiteralPattern } from './pattern.mjs';
2
1
  import { TemplateLiteralSyntax } from './syntax.mjs';
2
+ import { TemplateLiteralPattern } from './pattern.mjs';
3
3
  import { IsString } from '../guard/value.mjs';
4
4
  import { Kind } from '../symbols/index.mjs';
5
5
  /** `[Json]` Creates a TemplateLiteral type */
@@ -3,5 +3,5 @@ import { type TUnion } from '../union/index.mjs';
3
3
  import { type TLiteral } from '../literal/index.mjs';
4
4
  import { type TString } from '../string/index.mjs';
5
5
  import { type TNever } from '../never/index.mjs';
6
- /** Resolves a template literal as a TUnion */
7
- export declare function TemplateLiteralToUnion(template: TTemplateLiteral): TNever | TString | TUnion<TLiteral[]>;
6
+ /** Returns a Union from the given TemplateLiteral */
7
+ export declare function TemplateLiteralToUnion(schema: TTemplateLiteral): TNever | TString | TUnion<TLiteral[]>;
@@ -1,17 +1,12 @@
1
1
  import { Union } from '../union/index.mjs';
2
2
  import { Literal } from '../literal/index.mjs';
3
- import { String } from '../string/index.mjs';
4
3
  import { TemplateLiteralGenerate } from './generate.mjs';
5
- import { TemplateLiteralParseExact } from './parser.mjs';
6
- import { IsTemplateLiteralFinite } from './finite.mjs';
7
4
  // ------------------------------------------------------------------
8
5
  // TemplateLiteralToUnion
9
6
  // ------------------------------------------------------------------
10
- /** Resolves a template literal as a TUnion */
11
- export function TemplateLiteralToUnion(template) {
12
- const expression = TemplateLiteralParseExact(template.pattern);
13
- if (!IsTemplateLiteralFinite(expression))
14
- return String();
15
- const literals = [...TemplateLiteralGenerate(expression)].map((value) => Literal(value));
16
- return Union(literals);
7
+ /** Returns a Union from the given TemplateLiteral */
8
+ export function TemplateLiteralToUnion(schema) {
9
+ const R = TemplateLiteralGenerate(schema);
10
+ const L = R.map((S) => Literal(S));
11
+ return Union(L);
17
12
  }
@@ -3,7 +3,6 @@ import { TransformKind } from '../symbols/index.mjs';
3
3
  // ------------------------------------------------------------------
4
4
  // TypeGuard
5
5
  // ------------------------------------------------------------------
6
- // prettier-ignore
7
6
  import { IsTransform } from '../guard/type.mjs';
8
7
  // ------------------------------------------------------------------
9
8
  // TransformBuilders
@@ -1,8 +1,7 @@
1
1
  import type { TSchema, SchemaOptions } from '../schema/index.mjs';
2
2
  import type { Static } from '../static/index.mjs';
3
3
  import { Kind } from '../symbols/index.mjs';
4
- type TupleStaticRest<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...TupleStaticRest<R, P>] : [];
5
- type TupleStatic<T extends TSchema[], P extends unknown[], R extends unknown[] = TupleStaticRest<T, P>> = R;
4
+ type TupleStatic<T extends TSchema[], P extends unknown[], Acc extends unknown[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TupleStatic<R, P, [...Acc, Static<L, P>]> : Acc;
6
5
  export interface TTuple<T extends TSchema[] = TSchema[]> extends TSchema {
7
6
  [Kind]: 'Tuple';
8
7
  static: TupleStatic<T, this['params']>;
@@ -34,7 +34,7 @@ import { type TRequired, type TRequiredFromMappedResult } from '../required/inde
34
34
  import { type TRest } from '../rest/index.mjs';
35
35
  import { type TSchema, type SchemaOptions } from '../schema/index.mjs';
36
36
  import { type TString, type StringOptions } from '../string/index.mjs';
37
- import { type TTemplateLiteral, type TTemplateLiteralKind, type TemplateLiteralSyntax } from '../template-literal/index.mjs';
37
+ import { type TTemplateLiteral, type TTemplateLiteralKind, type TTemplateLiteralSyntax } from '../template-literal/index.mjs';
38
38
  import { TransformDecodeBuilder } from '../transform/index.mjs';
39
39
  import { type TTuple } from '../tuple/index.mjs';
40
40
  import { Union } from '../union/index.mjs';
@@ -157,7 +157,7 @@ export declare class JsonTypeBuilder {
157
157
  /** `[Json]` Creates a String type */
158
158
  String(options?: StringOptions): TString;
159
159
  /** `[Json]` Creates a TemplateLiteral type from template dsl string */
160
- TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TemplateLiteralSyntax<T>;
160
+ TemplateLiteral<T extends string>(syntax: T, options?: SchemaOptions): TTemplateLiteralSyntax<T>;
161
161
  /** `[Json]` Creates a TemplateLiteral type */
162
162
  TemplateLiteral<T extends TTemplateLiteralKind[]>(kinds: [...T], options?: SchemaOptions): TTemplateLiteral<T>;
163
163
  /** `[Json]` Creates a Transform type */
@@ -3,15 +3,11 @@ import { type TNever } from '../never/index.mjs';
3
3
  import { type TOptional } from '../optional/index.mjs';
4
4
  import type { TReadonly } from '../readonly/index.mjs';
5
5
  import type { TUnion } from './union-type.mjs';
6
- type IsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : IsUnionOptional<R> : false);
7
- declare function IsUnionOptional<T extends TSchema[]>(T: T): IsUnionOptional<T>;
8
- type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
9
- declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
10
- type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
11
- declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
12
- type ResolveUnion<T extends TSchema[], R extends TSchema[] = RemoveOptionalFromRest<T>> = (IsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
13
- declare function ResolveUnion<T extends TSchema[]>(T: T, options: SchemaOptions): ResolveUnion<T>;
14
- export type UnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveUnion<T>);
6
+ type TIsUnionOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? true : TIsUnionOptional<R> : false);
7
+ type TRemoveOptionalFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromRest<R, [...Acc, TRemoveOptionalFromType<S>]> : TRemoveOptionalFromRest<R, [...Acc, L]> : Acc);
8
+ type TRemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<TRemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? TRemoveOptionalFromType<S> : T);
9
+ type TResolveUnion<T extends TSchema[], R extends TSchema[] = TRemoveOptionalFromRest<T>> = (TIsUnionOptional<T> extends true ? TOptional<TUnion<R>> : TUnion<R>);
10
+ export type TUnionEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TResolveUnion<T>);
15
11
  /** `[Json]` Creates an evaluated Union type */
16
- export declare function UnionEvaluated<T extends TSchema[], R = UnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
12
+ export declare function UnionEvaluated<T extends TSchema[], R = TUnionEvaluated<T>>(T: [...T], options?: SchemaOptions): R;
17
13
  export {};
@@ -19,8 +19,13 @@ function IsUnionOptional(T) {
19
19
  : false);
20
20
  }
21
21
  // prettier-ignore
22
- function RemoveOptionalFromRest(T) {
23
- return (T.map(T => RemoveOptionalFromType(T)));
22
+ function RemoveOptionalFromRest(T, Acc = []) {
23
+ const [L, ...R] = T;
24
+ return (T.length > 0
25
+ ? IsOptional(L)
26
+ ? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
27
+ : RemoveOptionalFromRest(R, [...Acc, L])
28
+ : Acc);
24
29
  }
25
30
  // prettier-ignore
26
31
  function RemoveOptionalFromType(T) {
@@ -94,7 +94,7 @@ function Default(schema, references, value) {
94
94
  // ------------------------------------------------------------------
95
95
  // Cast
96
96
  // ------------------------------------------------------------------
97
- function TArray(schema, references, value) {
97
+ function FromArray(schema, references, value) {
98
98
  if (Check(schema, references, value))
99
99
  return Clone(value);
100
100
  const created = IsArray(value) ? Clone(value) : Create(schema, references);
@@ -108,7 +108,7 @@ function TArray(schema, references, value) {
108
108
  throw new ValueCastArrayUniqueItemsTypeError(schema, unique);
109
109
  return unique;
110
110
  }
111
- function TConstructor(schema, references, value) {
111
+ function FromConstructor(schema, references, value) {
112
112
  if (Check(schema, references, value))
113
113
  return Create(schema, references);
114
114
  const required = new Set(schema.returns.required || []);
@@ -120,15 +120,15 @@ function TConstructor(schema, references, value) {
120
120
  }
121
121
  return result;
122
122
  }
123
- function TIntersect(schema, references, value) {
123
+ function FromIntersect(schema, references, value) {
124
124
  const created = Create(schema, references);
125
125
  const mapped = IsPlainObject(created) && IsPlainObject(value) ? { ...created, ...value } : value;
126
126
  return Check(schema, references, mapped) ? mapped : Create(schema, references);
127
127
  }
128
- function TNever(schema, references, value) {
128
+ function FromNever(schema, references, value) {
129
129
  throw new ValueCastNeverTypeError(schema);
130
130
  }
131
- function TObject(schema, references, value) {
131
+ function FromObject(schema, references, value) {
132
132
  if (Check(schema, references, value))
133
133
  return value;
134
134
  if (value === null || typeof value !== 'object')
@@ -151,7 +151,7 @@ function TObject(schema, references, value) {
151
151
  }
152
152
  return result;
153
153
  }
154
- function TRecord(schema, references, value) {
154
+ function FromRecord(schema, references, value) {
155
155
  if (Check(schema, references, value))
156
156
  return Clone(value);
157
157
  if (value === null || typeof value !== 'object' || Array.isArray(value) || value instanceof Date)
@@ -164,13 +164,13 @@ function TRecord(schema, references, value) {
164
164
  }
165
165
  return result;
166
166
  }
167
- function TRef(schema, references, value) {
167
+ function FromRef(schema, references, value) {
168
168
  return Visit(Deref(schema, references), references, value);
169
169
  }
170
- function TThis(schema, references, value) {
170
+ function FromThis(schema, references, value) {
171
171
  return Visit(Deref(schema, references), references, value);
172
172
  }
173
- function TTuple(schema, references, value) {
173
+ function FromTuple(schema, references, value) {
174
174
  if (Check(schema, references, value))
175
175
  return Clone(value);
176
176
  if (!IsArray(value))
@@ -179,7 +179,7 @@ function TTuple(schema, references, value) {
179
179
  return [];
180
180
  return schema.items.map((schema, index) => Visit(schema, references, value[index]));
181
181
  }
182
- function TUnion(schema, references, value) {
182
+ function FromUnion(schema, references, value) {
183
183
  return Check(schema, references, value) ? Clone(value) : CastUnion(schema, references, value);
184
184
  }
185
185
  function Visit(schema, references, value) {
@@ -190,25 +190,25 @@ function Visit(schema, references, value) {
190
190
  // Structural
191
191
  // --------------------------------------------------------------
192
192
  case 'Array':
193
- return TArray(schema_, references_, value);
193
+ return FromArray(schema_, references_, value);
194
194
  case 'Constructor':
195
- return TConstructor(schema_, references_, value);
195
+ return FromConstructor(schema_, references_, value);
196
196
  case 'Intersect':
197
- return TIntersect(schema_, references_, value);
197
+ return FromIntersect(schema_, references_, value);
198
198
  case 'Never':
199
- return TNever(schema_, references_, value);
199
+ return FromNever(schema_, references_, value);
200
200
  case 'Object':
201
- return TObject(schema_, references_, value);
201
+ return FromObject(schema_, references_, value);
202
202
  case 'Record':
203
- return TRecord(schema_, references_, value);
203
+ return FromRecord(schema_, references_, value);
204
204
  case 'Ref':
205
- return TRef(schema_, references_, value);
205
+ return FromRef(schema_, references_, value);
206
206
  case 'This':
207
- return TThis(schema_, references_, value);
207
+ return FromThis(schema_, references_, value);
208
208
  case 'Tuple':
209
- return TTuple(schema_, references_, value);
209
+ return FromTuple(schema_, references_, value);
210
210
  case 'Union':
211
- return TUnion(schema_, references_, value);
211
+ return FromUnion(schema_, references_, value);
212
212
  // --------------------------------------------------------------
213
213
  // DefaultClone
214
214
  // --------------------------------------------------------------