@sinclair/typebox 0.32.0-dev-25 → 0.32.0-dev-27

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 (206) hide show
  1. package/build/import/errors/errors.mjs +2 -2
  2. package/build/import/errors/function.d.mts +13 -3
  3. package/build/import/errors/function.mjs +39 -39
  4. package/build/import/index.d.mts +2 -2
  5. package/build/import/type/awaited/awaited.mjs +2 -6
  6. package/build/import/type/composite/composite.d.mts +1 -2
  7. package/build/import/type/composite/composite.mjs +2 -2
  8. package/build/import/type/const/const.mjs +6 -6
  9. package/build/import/type/constructor/constructor.d.mts +1 -1
  10. package/build/import/type/constructor/constructor.mjs +1 -1
  11. package/build/import/type/deref/deref.mjs +1 -2
  12. package/build/import/type/discard/discard.mjs +2 -2
  13. package/build/import/type/enum/enum.mjs +3 -0
  14. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
  15. package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
  16. package/build/import/type/exclude/exclude.mjs +0 -1
  17. package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
  18. package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
  19. package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
  20. package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
  21. package/build/import/type/extends/extends.mjs +0 -1
  22. package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
  23. package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
  24. package/build/import/type/extract/extract.d.mts +1 -2
  25. package/build/import/type/extract/extract.mjs +4 -2
  26. package/build/import/type/index.d.mts +1 -1
  27. package/build/import/type/index.mjs +1 -1
  28. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
  29. package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
  30. package/build/import/type/indexed/indexed-from-mapped-result.d.mts +2 -2
  31. package/build/import/type/indexed/indexed-from-mapped-result.mjs +1 -1
  32. package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
  33. package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
  34. package/build/import/type/indexed/indexed.d.mts +1 -1
  35. package/build/import/type/indexed/indexed.mjs +9 -27
  36. package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
  37. package/build/import/type/intrinsic/capitalize.d.mts +2 -2
  38. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
  39. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
  40. package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
  41. package/build/import/type/intrinsic/intrinsic.mjs +2 -5
  42. package/build/import/type/intrinsic/lowercase.d.mts +2 -2
  43. package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
  44. package/build/import/type/intrinsic/uppercase.d.mts +2 -2
  45. package/build/import/type/iterator/iterator.mjs +1 -1
  46. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
  47. package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
  48. package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
  49. package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
  50. package/build/import/type/keyof/keyof.mjs +2 -8
  51. package/build/import/type/mapped/mapped.d.mts +6 -1
  52. package/build/import/type/mapped/mapped.mjs +21 -14
  53. package/build/import/type/not/not.mjs +1 -1
  54. package/build/import/type/object/object.d.mts +1 -1
  55. package/build/import/type/object/object.mjs +0 -1
  56. package/build/import/type/omit/index.d.mts +1 -0
  57. package/build/import/type/omit/index.mjs +1 -0
  58. package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
  59. package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
  60. package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
  61. package/build/import/type/omit/omit.d.mts +6 -3
  62. package/build/import/type/omit/omit.mjs +11 -9
  63. package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
  64. package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
  65. package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
  66. package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
  67. package/build/import/type/partial/partial.d.mts +2 -3
  68. package/build/import/type/partial/partial.mjs +8 -21
  69. package/build/import/type/pick/index.d.mts +1 -0
  70. package/build/import/type/pick/index.mjs +1 -0
  71. package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
  72. package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
  73. package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
  74. package/build/import/type/pick/pick.d.mts +5 -2
  75. package/build/import/type/pick/pick.mjs +11 -10
  76. package/build/import/type/promise/promise.mjs +1 -1
  77. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
  78. package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
  79. package/build/import/type/record/record.d.mts +2 -2
  80. package/build/import/type/record/record.mjs +3 -0
  81. package/build/import/type/ref/ref.mjs +1 -1
  82. package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
  83. package/build/import/type/required/required-from-mapped-result.mjs +7 -7
  84. package/build/import/type/required/required.d.mts +2 -3
  85. package/build/import/type/required/required.mjs +4 -14
  86. package/build/import/type/rest/rest.d.mts +2 -2
  87. package/build/import/type/rest/rest.mjs +1 -2
  88. package/build/import/type/sets/index.d.mts +1 -0
  89. package/build/import/type/sets/index.mjs +1 -0
  90. package/build/import/type/sets/set.d.mts +24 -0
  91. package/build/import/type/sets/set.mjs +35 -0
  92. package/build/import/type/strict/strict.d.mts +1 -1
  93. package/build/import/type/strict/strict.mjs +1 -1
  94. package/build/import/type/template-literal/syntax.d.mts +1 -1
  95. package/build/import/type/template-literal/template-literal.d.mts +1 -1
  96. package/build/import/type/transform/transform.mjs +1 -1
  97. package/build/import/type/type/json.d.mts +6 -2
  98. package/build/import/type/union/union-evaluated.mjs +3 -14
  99. package/build/require/errors/errors.js +2 -2
  100. package/build/require/errors/function.d.ts +13 -3
  101. package/build/require/errors/function.js +39 -39
  102. package/build/require/index.d.ts +2 -2
  103. package/build/require/type/awaited/awaited.js +2 -6
  104. package/build/require/type/composite/composite.d.ts +1 -2
  105. package/build/require/type/composite/composite.js +5 -6
  106. package/build/require/type/const/const.js +6 -6
  107. package/build/require/type/constructor/constructor.d.ts +1 -1
  108. package/build/require/type/constructor/constructor.js +1 -1
  109. package/build/require/type/deref/deref.js +0 -1
  110. package/build/require/type/discard/discard.js +2 -2
  111. package/build/require/type/enum/enum.js +3 -0
  112. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
  113. package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
  114. package/build/require/type/exclude/exclude.js +0 -1
  115. package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
  116. package/build/require/type/extends/extends-from-mapped-key.js +4 -5
  117. package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
  118. package/build/require/type/extends/extends-from-mapped-result.js +7 -7
  119. package/build/require/type/extends/extends.js +0 -1
  120. package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
  121. package/build/require/type/extract/extract-from-mapped-result.js +7 -7
  122. package/build/require/type/extract/extract.d.ts +1 -2
  123. package/build/require/type/extract/extract.js +4 -3
  124. package/build/require/type/index.d.ts +1 -1
  125. package/build/require/type/index.js +1 -1
  126. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
  127. package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
  128. package/build/require/type/indexed/indexed-from-mapped-result.d.ts +2 -2
  129. package/build/require/type/indexed/indexed-from-mapped-result.js +1 -1
  130. package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
  131. package/build/require/type/indexed/indexed-property-keys.js +3 -5
  132. package/build/require/type/indexed/indexed.d.ts +1 -1
  133. package/build/require/type/indexed/indexed.js +9 -27
  134. package/build/require/type/intersect/intersect-evaluated.js +3 -13
  135. package/build/require/type/intrinsic/capitalize.d.ts +2 -2
  136. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
  137. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
  138. package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
  139. package/build/require/type/intrinsic/intrinsic.js +2 -5
  140. package/build/require/type/intrinsic/lowercase.d.ts +2 -2
  141. package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
  142. package/build/require/type/intrinsic/uppercase.d.ts +2 -2
  143. package/build/require/type/iterator/iterator.js +1 -1
  144. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
  145. package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
  146. package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
  147. package/build/require/type/keyof/keyof-property-keys.js +9 -15
  148. package/build/require/type/keyof/keyof.js +2 -8
  149. package/build/require/type/mapped/mapped.d.ts +6 -1
  150. package/build/require/type/mapped/mapped.js +21 -14
  151. package/build/require/type/not/not.js +1 -1
  152. package/build/require/type/object/object.d.ts +1 -1
  153. package/build/require/type/object/object.js +0 -1
  154. package/build/require/type/omit/index.d.ts +1 -0
  155. package/build/require/type/omit/index.js +1 -0
  156. package/build/require/type/omit/omit-from-mapped-key.js +4 -5
  157. package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
  158. package/build/require/type/omit/omit-from-mapped-result.js +22 -0
  159. package/build/require/type/omit/omit.d.ts +6 -3
  160. package/build/require/type/omit/omit.js +10 -8
  161. package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
  162. package/build/require/type/optional/optional-from-mapped-result.js +7 -7
  163. package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
  164. package/build/require/type/partial/partial-from-mapped-result.js +4 -4
  165. package/build/require/type/partial/partial.d.ts +2 -3
  166. package/build/require/type/partial/partial.js +8 -21
  167. package/build/require/type/pick/index.d.ts +1 -0
  168. package/build/require/type/pick/index.js +1 -0
  169. package/build/require/type/pick/pick-from-mapped-key.js +4 -5
  170. package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
  171. package/build/require/type/pick/pick-from-mapped-result.js +22 -0
  172. package/build/require/type/pick/pick.d.ts +5 -2
  173. package/build/require/type/pick/pick.js +10 -9
  174. package/build/require/type/promise/promise.js +1 -1
  175. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
  176. package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
  177. package/build/require/type/record/record.d.ts +2 -2
  178. package/build/require/type/record/record.js +3 -0
  179. package/build/require/type/ref/ref.js +1 -1
  180. package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
  181. package/build/require/type/required/required-from-mapped-result.js +7 -7
  182. package/build/require/type/required/required.d.ts +2 -3
  183. package/build/require/type/required/required.js +4 -14
  184. package/build/require/type/rest/rest.d.ts +2 -2
  185. package/build/require/type/rest/rest.js +1 -3
  186. package/build/require/type/sets/index.d.ts +1 -0
  187. package/build/require/type/{operators → sets}/index.js +1 -1
  188. package/build/require/type/sets/set.d.ts +24 -0
  189. package/build/require/type/sets/set.js +47 -0
  190. package/build/require/type/strict/strict.d.ts +1 -1
  191. package/build/require/type/strict/strict.js +1 -1
  192. package/build/require/type/template-literal/parse.js +1 -1
  193. package/build/require/type/template-literal/syntax.d.ts +1 -1
  194. package/build/require/type/template-literal/template-literal.d.ts +1 -1
  195. package/build/require/type/transform/transform.js +1 -1
  196. package/build/require/type/type/json.d.ts +6 -2
  197. package/build/require/type/union/union-evaluated.js +3 -14
  198. package/package.json +1 -1
  199. package/readme.md +67 -67
  200. package/build/import/type/operators/index.d.mts +0 -1
  201. package/build/import/type/operators/index.mjs +0 -1
  202. package/build/import/type/operators/operators.d.mts +0 -24
  203. package/build/import/type/operators/operators.mjs +0 -77
  204. package/build/require/type/operators/index.d.ts +0 -1
  205. package/build/require/type/operators/operators.d.ts +0 -24
  206. package/build/require/type/operators/operators.js +0 -89
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Rest = exports.RestResolve = void 0;
4
+ exports.Rest = void 0;
5
5
  const type_1 = require("../clone/type");
6
6
  // ------------------------------------------------------------------
7
7
  // TypeGuard
8
8
  // ------------------------------------------------------------------
9
- // prettier-ignore
10
9
  const type_2 = require("../guard/type");
11
10
  // prettier-ignore
12
11
  function RestResolve(T) {
@@ -15,7 +14,6 @@ function RestResolve(T) {
15
14
  (0, type_2.IsTuple)(T) ? [...(T.items ?? [])] :
16
15
  []);
17
16
  }
18
- exports.RestResolve = RestResolve;
19
17
  /** `[Json]` Extracts interior Rest elements from Tuple, Intersect and Union types */
20
18
  function Rest(T) {
21
19
  return (0, type_1.CloneRest)(RestResolve(T));
@@ -0,0 +1 @@
1
+ export * from './set';
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- __exportStar(require("./operators"), exports);
18
+ __exportStar(require("./set"), exports);
@@ -0,0 +1,24 @@
1
+ export type TSetIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TSetIncludes<R, S> : false);
2
+ /** Returns true if element S is in the set of T */
3
+ export declare function SetIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TSetIncludes<T, S>;
4
+ export type SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? SetIsSubset<R, S> : false : true);
5
+ /** Returns true if T is a subset of S */
6
+ export declare function SetIsSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): SetIsSubset<T, S>;
7
+ export type TSetDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<Acc, L> extends false ? TSetDistinct<R, [...Acc, L]> : TSetDistinct<R, [...Acc]> : Acc;
8
+ /** Returns a distinct set of elements */
9
+ export declare function SetDistinct<T extends PropertyKey[]>(T: [...T]): TSetDistinct<T>;
10
+ export type TSetIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetIntersect<R, S, [L, ...Acc]> : TSetIntersect<R, S, [...Acc]> : Acc);
11
+ /** Returns the Intersect of the given sets */
12
+ export declare function SetIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetIntersect<T, S>;
13
+ export type TSetUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetUnion<R, S, [...Acc, L]> : Acc);
14
+ /** Returns the Union of the given sets */
15
+ export declare function SetUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetUnion<T, S>;
16
+ export type TSetComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TSetIncludes<S, L> extends true ? TSetComplement<R, S, [...Acc]> : TSetComplement<R, S, [...Acc, L]> : Acc);
17
+ /** Returns the Complement by omitting elements in T that are in S */
18
+ export declare function SetComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TSetComplement<T, S>;
19
+ export type TSetIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetIntersectMany<R, TSetIntersect<Acc, L>> : Acc);
20
+ /** Returns the Intersect of multiple sets */
21
+ export declare function SetIntersectMany<T extends PropertyKey[][]>(T: [...T]): TSetIntersectMany<T>;
22
+ export type TSetUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? TSetUnionMany<R, TSetUnion<Acc, L>> : Acc);
23
+ /** Returns the Union of multiple sets */
24
+ export declare function SetUnionMany<T extends PropertyKey[][]>(T: [...T]): TSetUnionMany<T>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SetUnionMany = exports.SetIntersectMany = exports.SetComplement = exports.SetUnion = exports.SetIntersect = exports.SetDistinct = exports.SetIsSubset = exports.SetIncludes = void 0;
5
+ /** Returns true if element S is in the set of T */
6
+ // prettier-ignore
7
+ function SetIncludes(T, S) {
8
+ return T.includes(S);
9
+ }
10
+ exports.SetIncludes = SetIncludes;
11
+ /** Returns true if T is a subset of S */
12
+ function SetIsSubset(T, S) {
13
+ return T.every((L) => SetIncludes(S, L));
14
+ }
15
+ exports.SetIsSubset = SetIsSubset;
16
+ /** Returns a distinct set of elements */
17
+ function SetDistinct(T) {
18
+ return [...new Set(T)];
19
+ }
20
+ exports.SetDistinct = SetDistinct;
21
+ /** Returns the Intersect of the given sets */
22
+ function SetIntersect(T, S) {
23
+ return T.filter((L) => S.includes(L));
24
+ }
25
+ exports.SetIntersect = SetIntersect;
26
+ /** Returns the Union of the given sets */
27
+ function SetUnion(T, S) {
28
+ return [...T, ...S];
29
+ }
30
+ exports.SetUnion = SetUnion;
31
+ /** Returns the Complement by omitting elements in T that are in S */
32
+ // prettier-ignore
33
+ function SetComplement(T, S) {
34
+ return T.filter(L => !S.includes(L));
35
+ }
36
+ exports.SetComplement = SetComplement;
37
+ /** Returns the Intersect of multiple sets */
38
+ // prettier-ignore
39
+ function SetIntersectMany(T) {
40
+ return (T.length === 1 ? T[0] : T.reduce((Acc, L) => [...SetIntersect(Acc, L)], []));
41
+ }
42
+ exports.SetIntersectMany = SetIntersectMany;
43
+ /** Returns the Union of multiple sets */
44
+ function SetUnionMany(T) {
45
+ return T.reduce((Acc, L) => [...Acc, ...L], []);
46
+ }
47
+ exports.SetUnionMany = SetUnionMany;
@@ -1,3 +1,3 @@
1
1
  import type { TSchema } from '../schema/index';
2
- /** `[Json]` Omits compositing symbols from this schema */
2
+ /** `[Json]` Omits compositing symbols from this schema. */
3
3
  export declare function Strict<T extends TSchema>(schema: T): T;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Strict = void 0;
5
- /** `[Json]` Omits compositing symbols from this schema */
5
+ /** `[Json]` Omits compositing symbols from this schema. */
6
6
  function Strict(schema) {
7
7
  return JSON.parse(JSON.stringify(schema));
8
8
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
+
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralParserError = void 0;
4
-
5
5
  const index_1 = require("../error/index");
6
6
  // ------------------------------------------------------------------
7
7
  // TemplateLiteralParserError
@@ -1,5 +1,5 @@
1
1
  import type { Assert, Trim } from '../helpers/index';
2
- import type { TTemplateLiteralKind, TTemplateLiteral } from './index';
2
+ import type { TTemplateLiteral, TTemplateLiteralKind } from './index';
3
3
  import { type TLiteral } from '../literal/index';
4
4
  import { type TBoolean } from '../boolean/index';
5
5
  import { type TBigInt } from '../bigint/index';
@@ -9,7 +9,7 @@ import type { TString } from '../string/index';
9
9
  import type { TBoolean } from '../boolean/index';
10
10
  import type { TNever } from '../never/index';
11
11
  import type { Static } from '../static/index';
12
- import { TTemplateLiteralSyntax } from './syntax';
12
+ import { type TTemplateLiteralSyntax } from './syntax';
13
13
  import { EmptyString } from '../helpers/index';
14
14
  import { Kind } from '../symbols/index';
15
15
  type TemplateLiteralStaticKind<T, Acc extends string> = T extends TUnion<infer U> ? {
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Transform = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = void 0;
5
- const type_1 = require("../clone/type");
6
5
  const index_1 = require("../symbols/index");
6
+ const type_1 = require("../clone/type");
7
7
  // ------------------------------------------------------------------
8
8
  // TypeGuard
9
9
  // ------------------------------------------------------------------
@@ -21,10 +21,10 @@ import { type TNull } from '../null/index';
21
21
  import { type TMappedKey } from '../mapped/index';
22
22
  import { type TNumber, type NumberOptions } from '../number/index';
23
23
  import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
24
- import { type TOmit, type TOmitFromMappedKey } from '../omit/index';
24
+ import { type TOmit, type TOmitFromMappedKey, type TOmitFromMappedResult } from '../omit/index';
25
25
  import { type TOptionalWithFlag, type TOptionalFromMappedResult } from '../optional/index';
26
26
  import { type TPartial, type TPartialFromMappedResult } from '../partial/index';
27
- import { type TPick, type TPickFromMappedKey } from '../pick/index';
27
+ import { type TPick, type TPickFromMappedKey, type TPickFromMappedResult } from '../pick/index';
28
28
  import { type TReadonlyWithFlag, type TReadonlyFromMappedResult } from '../readonly/index';
29
29
  import { type TReadonlyOptional } from '../readonly-optional/index';
30
30
  import { type TRecordOrObject } from '../record/index';
@@ -127,6 +127,8 @@ export declare class JsonTypeBuilder {
127
127
  /** `[Json]` Creates an Object type */
128
128
  Object<T extends TProperties>(properties: T, options?: ObjectOptions): TObject<T>;
129
129
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
130
+ Omit<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TOmitFromMappedResult<T, K>;
131
+ /** `[Json]` Constructs a type whose keys are omitted from the given type */
130
132
  Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
131
133
  /** `[Json]` Constructs a type whose keys are omitted from the given type */
132
134
  Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
@@ -137,6 +139,8 @@ export declare class JsonTypeBuilder {
137
139
  /** `[Json]` Constructs a type where all properties are optional */
138
140
  Partial<T extends TSchema>(schema: T, options?: ObjectOptions): TPartial<T>;
139
141
  /** `[Json]` Constructs a type whose keys are picked from the given type */
142
+ Pick<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K]): TPickFromMappedResult<T, K>;
143
+ /** `[Json]` Constructs a type whose keys are picked from the given type */
140
144
  Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
141
145
  /** `[Json]` Constructs a type whose keys are picked from the given type */
142
146
  Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
@@ -11,25 +11,14 @@ const union_create_1 = require("./union-create");
11
11
  // ------------------------------------------------------------------
12
12
  // TypeGuard
13
13
  // ------------------------------------------------------------------
14
- // prettier-ignore
15
14
  const type_2 = require("../guard/type");
16
15
  // prettier-ignore
17
16
  function IsUnionOptional(T) {
18
- const [L, ...R] = T;
19
- return (T.length > 0
20
- ? (0, type_2.IsOptional)(L)
21
- ? true
22
- : IsUnionOptional(R)
23
- : false);
17
+ return T.some(L => (0, type_2.IsOptional)(L));
24
18
  }
25
19
  // prettier-ignore
26
- function RemoveOptionalFromRest(T, Acc = []) {
27
- const [L, ...R] = T;
28
- return (T.length > 0
29
- ? (0, type_2.IsOptional)(L)
30
- ? RemoveOptionalFromRest(R, [...Acc, RemoveOptionalFromType(L)])
31
- : RemoveOptionalFromRest(R, [...Acc, L])
32
- : Acc);
20
+ function RemoveOptionalFromRest(T) {
21
+ return T.map(L => (0, type_2.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
33
22
  }
34
23
  // prettier-ignore
35
24
  function RemoveOptionalFromType(T) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.32.0-dev-25",
3
+ "version": "0.32.0-dev-27",
4
4
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",
package/readme.md CHANGED
@@ -53,7 +53,7 @@ type T = Static<typeof T> // type T = {
53
53
 
54
54
  TypeBox is a runtime type builder that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime asserted using standard Json Schema validation.
55
55
 
56
- This library is designed to be a runtime type system with capabilities similar to TypeScript's static type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
56
+ This library is built to be a runtime type system offering similar capabilities to TypeScript's static type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
57
57
 
58
58
  License MIT
59
59
 
@@ -1619,12 +1619,12 @@ The following example shows an inline error function that intercepts errors for
1619
1619
  ```typescript
1620
1620
  import { SetErrorFunction, DefaultErrorFunction, ValueErrorType } from '@sinclair/typebox/errors'
1621
1621
 
1622
- SetErrorFunction((schema, errorType) => { // i18n override
1623
- switch(errorType) {
1622
+ SetErrorFunction((error) => { // i18n override
1623
+ switch(error.errorType) {
1624
1624
  /* en-US */ case ValueErrorType.String: return 'Expected string'
1625
1625
  /* fr-FR */ case ValueErrorType.Number: return 'Nombre attendu'
1626
1626
  /* ko-KR */ case ValueErrorType.Boolean: return '예상 부울'
1627
- /* en-US */ default: return DefaultErrorFunction(schema, errorType)
1627
+ /* en-US */ default: return DefaultErrorFunction(error)
1628
1628
  }
1629
1629
  })
1630
1630
  const T = Type.Object({ // const T: TObject<{
@@ -1709,35 +1709,35 @@ This benchmark measures compilation performance for varying types.
1709
1709
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1710
1710
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1711
1711
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
1712
- │ Literal_String │ 1000 │ ' 236 ms' │ ' 9 ms' │ ' 26.22 x' │
1713
- │ Literal_Number │ 1000 │ ' 205 ms' │ ' 13 ms' │ ' 15.77 x' │
1714
- │ Literal_Boolean │ 1000 │ ' 168 ms' │ ' 4 ms' │ ' 42.00 x' │
1715
- │ Primitive_Number │ 1000 │ ' 170 ms' │ ' 8 ms' │ ' 21.25 x' │
1716
- │ Primitive_String │ 1000 │ ' 162 ms' │ ' 7 ms' │ ' 23.14 x' │
1717
- │ Primitive_String_Pattern │ 1000 │ ' 211 ms' │ ' 10 ms' │ ' 21.10 x' │
1718
- │ Primitive_Boolean │ 1000 │ ' 139 ms' │ ' 4 ms' │ ' 34.75 x' │
1719
- │ Primitive_Null │ 1000 │ ' 146 ms' │ ' 5 ms' │ ' 29.20 x' │
1720
- │ Object_Unconstrained │ 1000 │ ' 1160 ms' │ ' 33 ms' │ ' 35.15 x' │
1721
- │ Object_Constrained │ 1000 │ ' 1257 ms' │ ' 26 ms' │ ' 48.35 x' │
1722
- │ Object_Vector3 │ 1000 │ ' 393 ms' │ ' 8 ms' │ ' 49.13 x' │
1723
- │ Object_Box3D │ 1000 │ ' 1795 ms' │ ' 30 ms' │ ' 59.83 x' │
1724
- │ Tuple_Primitive │ 1000 │ ' 542 ms' │ ' 16 ms' │ ' 33.88 x' │
1725
- │ Tuple_Object │ 1000 │ ' 1330 ms' │ ' 17 ms' │ ' 78.24 x' │
1726
- │ Composite_Intersect │ 1000 │ ' 624 ms' │ ' 17 ms' │ ' 36.71 x' │
1727
- │ Composite_Union │ 1000 │ ' 565 ms' │ ' 19 ms' │ ' 29.74 x' │
1728
- │ Math_Vector4 │ 1000 │ ' 853 ms' │ ' 10 ms' │ ' 85.30 x' │
1729
- │ Math_Matrix4 │ 1000 │ ' 406 ms' │ ' 12 ms' │ ' 33.83 x' │
1730
- │ Array_Primitive_Number │ 1000 │ ' 401 ms' │ ' 11 ms' │ ' 36.45 x' │
1731
- │ Array_Primitive_String │ 1000 │ ' 385 ms' │ ' 6 ms' │ ' 64.17 x' │
1732
- │ Array_Primitive_Boolean │ 1000 │ ' 347 ms' │ ' 8 ms' │ ' 43.38 x' │
1733
- │ Array_Object_Unconstrained │ 1000 │ ' 1904 ms' │ ' 25 ms' │ ' 76.16 x' │
1734
- │ Array_Object_Constrained │ 1000 │ ' 1582 ms' │ ' 20 ms' │ ' 79.10 x' │
1735
- │ Array_Tuple_Primitive │ 1000 │ ' 864 ms' │ ' 11 ms' │ ' 78.55 x' │
1736
- │ Array_Tuple_Object │ 1000 │ ' 1658 ms' │ ' 16 ms' │ ' 103.63 x' │
1737
- │ Array_Composite_Intersect │ 1000 │ ' 786 ms' │ ' 17 ms' │ ' 46.24 x' │
1738
- │ Array_Composite_Union │ 1000 │ ' 844 ms' │ ' 16 ms' │ ' 52.75 x' │
1739
- │ Array_Math_Vector4 │ 1000 │ ' 1192 ms' │ ' 10 ms' │ ' 119.20 x' │
1740
- │ Array_Math_Matrix4 │ 1000 │ ' 688 ms' │ ' 10 ms' │ ' 68.80 x' │
1712
+ │ Literal_String │ 1000 │ ' 242 ms' │ ' 10 ms' │ ' 24.20 x' │
1713
+ │ Literal_Number │ 1000 │ ' 200 ms' │ ' 8 ms' │ ' 25.00 x' │
1714
+ │ Literal_Boolean │ 1000 │ ' 168 ms' │ ' 6 ms' │ ' 28.00 x' │
1715
+ │ Primitive_Number │ 1000 │ ' 165 ms' │ ' 8 ms' │ ' 20.63 x' │
1716
+ │ Primitive_String │ 1000 │ ' 154 ms' │ ' 6 ms' │ ' 25.67 x' │
1717
+ │ Primitive_String_Pattern │ 1000 │ ' 208 ms' │ ' 14 ms' │ ' 14.86 x' │
1718
+ │ Primitive_Boolean │ 1000 │ ' 142 ms' │ ' 6 ms' │ ' 23.67 x' │
1719
+ │ Primitive_Null │ 1000 │ ' 143 ms' │ ' 6 ms' │ ' 23.83 x' │
1720
+ │ Object_Unconstrained │ 1000 │ ' 1217 ms' │ ' 31 ms' │ ' 39.26 x' │
1721
+ │ Object_Constrained │ 1000 │ ' 1275 ms' │ ' 26 ms' │ ' 49.04 x' │
1722
+ │ Object_Vector3 │ 1000 │ ' 405 ms' │ ' 12 ms' │ ' 33.75 x' │
1723
+ │ Object_Box3D │ 1000 │ ' 1833 ms' │ ' 27 ms' │ ' 67.89 x' │
1724
+ │ Tuple_Primitive │ 1000 │ ' 475 ms' │ ' 13 ms' │ ' 36.54 x' │
1725
+ │ Tuple_Object │ 1000 │ ' 1267 ms' │ ' 30 ms' │ ' 42.23 x' │
1726
+ │ Composite_Intersect │ 1000 │ ' 604 ms' │ ' 18 ms' │ ' 33.56 x' │
1727
+ │ Composite_Union │ 1000 │ ' 545 ms' │ ' 20 ms' │ ' 27.25 x' │
1728
+ │ Math_Vector4 │ 1000 │ ' 829 ms' │ ' 12 ms' │ ' 69.08 x' │
1729
+ │ Math_Matrix4 │ 1000 │ ' 405 ms' │ ' 10 ms' │ ' 40.50 x' │
1730
+ │ Array_Primitive_Number │ 1000 │ ' 372 ms' │ ' 12 ms' │ ' 31.00 x' │
1731
+ │ Array_Primitive_String │ 1000 │ ' 327 ms' │ ' 5 ms' │ ' 65.40 x' │
1732
+ │ Array_Primitive_Boolean │ 1000 │ ' 300 ms' │ ' 4 ms' │ ' 75.00 x' │
1733
+ │ Array_Object_Unconstrained │ 1000 │ ' 1755 ms' │ ' 21 ms' │ ' 83.57 x' │
1734
+ │ Array_Object_Constrained │ 1000 │ ' 1516 ms' │ ' 20 ms' │ ' 75.80 x' │
1735
+ │ Array_Tuple_Primitive │ 1000 │ ' 825 ms' │ ' 14 ms' │ ' 58.93 x' │
1736
+ │ Array_Tuple_Object │ 1000 │ ' 1616 ms' │ ' 16 ms' │ ' 101.00 x' │
1737
+ │ Array_Composite_Intersect │ 1000 │ ' 776 ms' │ ' 16 ms' │ ' 48.50 x' │
1738
+ │ Array_Composite_Union │ 1000 │ ' 820 ms' │ ' 14 ms' │ ' 58.57 x' │
1739
+ │ Array_Math_Vector4 │ 1000 │ ' 1166 ms' │ ' 15 ms' │ ' 77.73 x' │
1740
+ │ Array_Math_Matrix4 │ 1000 │ ' 695 ms' │ ' 8 ms' │ ' 86.88 x' │
1741
1741
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1742
1742
  ```
1743
1743
 
@@ -1751,37 +1751,37 @@ This benchmark measures validation performance for varying types.
1751
1751
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1752
1752
  │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1753
1753
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
1754
- │ Literal_String │ 1000000 │ ' 19 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1755
- │ Literal_Number │ 1000000 │ ' 14 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1756
- │ Literal_Boolean │ 1000000 │ ' 14 ms' │ ' 19 ms' │ ' 9 ms' │ ' 2.11 x' │
1757
- │ Primitive_Number │ 1000000 │ ' 21 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1758
- │ Primitive_String │ 1000000 │ ' 22 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1759
- │ Primitive_String_Pattern │ 1000000 │ ' 164 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
1760
- │ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1754
+ │ Literal_String │ 1000000 │ ' 18 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1755
+ │ Literal_Number │ 1000000 │ ' 16 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1756
+ │ Literal_Boolean │ 1000000 │ ' 15 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1757
+ │ Primitive_Number │ 1000000 │ ' 21 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1758
+ │ Primitive_String │ 1000000 │ ' 22 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1759
+ │ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 41 ms' │ ' 34 ms' │ ' 1.21 x' │
1760
+ │ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1761
1761
  │ Primitive_Null │ 1000000 │ ' 19 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1762
- │ Object_Unconstrained │ 1000000 │ ' 966 ms' │ ' 33 ms' │ ' 24 ms' │ ' 1.38 x' │
1763
- │ Object_Constrained │ 1000000 │ ' 1275 ms' │ ' 52 ms' │ ' 42 ms' │ ' 1.24 x' │
1764
- │ Object_Vector3 │ 1000000 │ ' 427 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1765
- │ Object_Box3D │ 1000000 │ ' 2024 ms' │ ' 56 ms' │ ' 50 ms' │ ' 1.12 x' │
1766
- │ Object_Recursive │ 1000000 │ ' 5263 ms' │ ' 358 ms' │ ' 164 ms' │ ' 2.18 x' │
1767
- │ Tuple_Primitive │ 1000000 │ ' 157 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1768
- │ Tuple_Object │ 1000000 │ ' 767 ms' │ ' 29 ms' │ ' 18 ms' │ ' 1.61 x' │
1769
- │ Composite_Intersect │ 1000000 │ ' 769 ms' │ ' 26 ms' │ ' 15 ms' │ ' 1.73 x' │
1770
- │ Composite_Union │ 1000000 │ ' 501 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
1771
- │ Math_Vector4 │ 1000000 │ ' 250 ms' │ ' 23 ms' │ ' 11 ms' │ ' 2.09 x' │
1772
- │ Math_Matrix4 │ 1000000 │ ' 1073 ms' │ ' 43 ms' │ ' 28 ms' │ ' 1.54 x' │
1773
- │ Array_Primitive_Number │ 1000000 │ ' 264 ms' │ ' 21 ms' │ ' 12 ms' │ ' 1.75 x' │
1774
- │ Array_Primitive_String │ 1000000 │ ' 242 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1775
- │ Array_Primitive_Boolean │ 1000000 │ ' 151 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1776
- │ Array_Object_Unconstrained │ 1000000 │ ' 5864 ms' │ ' 66 ms' │ ' 58 ms' │ ' 1.14 x' │
1777
- │ Array_Object_Constrained │ 1000000 │ ' 5996 ms' │ ' 138 ms' │ ' 116 ms' │ ' 1.19 x' │
1778
- │ Array_Object_Recursive │ 1000000 │ ' 22515 ms' │ ' 1625 ms' │ ' 585 ms' │ ' 2.78 x' │
1779
- │ Array_Tuple_Primitive │ 1000000 │ ' 737 ms' │ ' 38 ms' │ ' 31 ms' │ ' 1.23 x' │
1780
- │ Array_Tuple_Object │ 1000000 │ ' 3257 ms' │ ' 77 ms' │ ' 56 ms' │ ' 1.38 x' │
1781
- │ Array_Composite_Intersect │ 1000000 │ ' 3119 ms' │ ' 49 ms' │ ' 38 ms' │ ' 1.29 x' │
1782
- │ Array_Composite_Union │ 1000000 │ ' 2108 ms' │ ' 72 ms' │ ' 33 ms' │ ' 2.18 x' │
1783
- │ Array_Math_Vector4 │ 1000000 │ ' 1078 ms' │ ' 38 ms' │ ' 26 ms' │ ' 1.46 x' │
1784
- │ Array_Math_Matrix4 │ 1000000 │ ' 4967 ms' │ ' 126 ms' │ ' 88 ms' │ ' 1.43 x' │
1762
+ │ Object_Unconstrained │ 1000000 │ ' 1003 ms' │ ' 32 ms' │ ' 24 ms' │ ' 1.33 x' │
1763
+ │ Object_Constrained │ 1000000 │ ' 1265 ms' │ ' 49 ms' │ ' 38 ms' │ ' 1.29 x' │
1764
+ │ Object_Vector3 │ 1000000 │ ' 418 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1765
+ │ Object_Box3D │ 1000000 │ ' 2035 ms' │ ' 56 ms' │ ' 49 ms' │ ' 1.14 x' │
1766
+ │ Object_Recursive │ 1000000 │ ' 5243 ms' │ ' 326 ms' │ ' 157 ms' │ ' 2.08 x' │
1767
+ │ Tuple_Primitive │ 1000000 │ ' 153 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1768
+ │ Tuple_Object │ 1000000 │ ' 781 ms' │ ' 28 ms' │ ' 18 ms' │ ' 1.56 x' │
1769
+ │ Composite_Intersect │ 1000000 │ ' 742 ms' │ ' 25 ms' │ ' 14 ms' │ ' 1.79 x' │
1770
+ │ Composite_Union │ 1000000 │ ' 558 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
1771
+ │ Math_Vector4 │ 1000000 │ ' 246 ms' │ ' 22 ms' │ ' 11 ms' │ ' 2.00 x' │
1772
+ │ Math_Matrix4 │ 1000000 │ ' 1052 ms' │ ' 43 ms' │ ' 28 ms' │ ' 1.54 x' │
1773
+ │ Array_Primitive_Number │ 1000000 │ ' 272 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1774
+ │ Array_Primitive_String │ 1000000 │ ' 235 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1775
+ │ Array_Primitive_Boolean │ 1000000 │ ' 134 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1776
+ │ Array_Object_Unconstrained │ 1000000 │ ' 6280 ms' │ ' 65 ms' │ ' 59 ms' │ ' 1.10 x' │
1777
+ │ Array_Object_Constrained │ 1000000 │ ' 6076 ms' │ ' 130 ms' │ ' 119 ms' │ ' 1.09 x' │
1778
+ │ Array_Object_Recursive │ 1000000 │ ' 22738 ms' │ ' 1730 ms' │ ' 635 ms' │ ' 2.72 x' │
1779
+ │ Array_Tuple_Primitive │ 1000000 │ ' 689 ms' │ ' 35 ms' │ ' 30 ms' │ ' 1.17 x' │
1780
+ │ Array_Tuple_Object │ 1000000 │ ' 3266 ms' │ ' 63 ms' │ ' 52 ms' │ ' 1.21 x' │
1781
+ │ Array_Composite_Intersect │ 1000000 │ ' 3310 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
1782
+ │ Array_Composite_Union │ 1000000 │ ' 2432 ms' │ ' 69 ms' │ ' 33 ms' │ ' 2.09 x' │
1783
+ │ Array_Math_Vector4 │ 1000000 │ ' 1158 ms' │ ' 37 ms' │ ' 24 ms' │ ' 1.54 x' │
1784
+ │ Array_Math_Matrix4 │ 1000000 │ ' 5435 ms' │ ' 132 ms' │ ' 92 ms' │ ' 1.43 x' │
1785
1785
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1786
1786
  ```
1787
1787
 
@@ -1795,11 +1795,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1795
1795
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1796
1796
  │ (index) │ Compiled │ Minified │ Compression │
1797
1797
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1798
- │ typebox/compiler │ '120.5 kb' │ ' 52.7 kb' │ '2.29 x' │
1799
- │ typebox/errors │ ' 55.5 kb' │ ' 25.2 kb' │ '2.20 x' │
1798
+ │ typebox/compiler │ '119.2 kb' │ ' 52.3 kb' │ '2.28 x' │
1799
+ │ typebox/errors │ ' 55.0 kb' │ ' 25.2 kb' │ '2.19 x' │
1800
1800
  │ typebox/system │ ' 4.7 kb' │ ' 2.0 kb' │ '2.33 x' │
1801
- │ typebox/value │ '147.4 kb' │ ' 62.2 kb' │ '2.37 x' │
1802
- │ typebox │ ' 91.3 kb' │ ' 38.0 kb' │ '2.40 x' │
1801
+ │ typebox/value │ '146.1 kb' │ ' 61.8 kb' │ '2.37 x' │
1802
+ │ typebox │ ' 90.1 kb' │ ' 37.3 kb' │ '2.41 x' │
1803
1803
  └──────────────────────┴────────────┴────────────┴─────────────┘
1804
1804
  ```
1805
1805
 
@@ -1 +0,0 @@
1
- export * from './operators.mjs';
@@ -1 +0,0 @@
1
- export * from './operators.mjs';
@@ -1,24 +0,0 @@
1
- export type TOperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TOperatorIncludes<R, S> : false);
2
- /** Returns true if element S is in the set of T */
3
- export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TOperatorIncludes<T, S>;
4
- export type TOperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorSubset<R, S> : false : true);
5
- /** Returns true if T is a subset of S */
6
- export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorSubset<T, S>;
7
- export type TOperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<Acc, L> extends false ? TOperatorDistinct<R, [...Acc, L]> : TOperatorDistinct<R, [...Acc]> : Acc;
8
- /** Returns a distinct set of elements */
9
- export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): TOperatorDistinct<T>;
10
- export type TOperatorIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorIntersect<R, S, [L, ...Acc]> : TOperatorIntersect<R, S, [...Acc]> : Acc);
11
- /** Returns the Intersect of the given sets */
12
- export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorIntersect<T, S>;
13
- export type TOperatorUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorUnion<R, S, [...Acc, L]> : Acc);
14
- /** Returns the Union of the given sets */
15
- export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): TOperatorUnion<T, S>;
16
- export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? OperatorComplement<R, S, [...Acc]> : OperatorComplement<R, S, [L, ...Acc]> : Acc);
17
- /** Returns the Complement by omitting elements in T that are in S */
18
- export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): OperatorComplement<T, S>;
19
- export type OperatorIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersectMany<R, TOperatorIntersect<Acc, L>> : Acc);
20
- /** Returns the Intersect of multiple sets */
21
- export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorIntersectMany<T>;
22
- export type OperatorUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnionMany<R, TOperatorUnion<Acc, L>> : Acc);
23
- /** Returns the Union of multiple sets */
24
- export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorUnionMany<T>;
@@ -1,77 +0,0 @@
1
- /** Returns true if element S is in the set of T */
2
- // prettier-ignore
3
- export function OperatorIncludes(T, S) {
4
- const [L, ...R] = T;
5
- return (T.length > 0
6
- ? S === L
7
- ? true
8
- : OperatorIncludes(R, S)
9
- : false);
10
- }
11
- /** Returns true if T is a subset of S */
12
- export function OperatorSubset(T, S) {
13
- const [L, ...R] = T;
14
- // prettier-ignore
15
- return (T.length > 0
16
- ? OperatorIncludes(S, L) === true
17
- ? OperatorSubset(R, S)
18
- : false
19
- : true);
20
- }
21
- /** Returns a distinct set of elements */
22
- export function OperatorDistinct(T, Acc = []) {
23
- const [L, ...R] = T;
24
- // prettier-ignore
25
- return (T.length > 0 ?
26
- (OperatorIncludes(Acc, L) === false
27
- ? OperatorDistinct(R, [...Acc, L])
28
- : OperatorDistinct(R, [...Acc])) : Acc);
29
- }
30
- /** Returns the Intersect of the given sets */
31
- export function OperatorIntersect(T, S) {
32
- const [L, ...R] = T;
33
- // prettier-ignore
34
- return (T.length > 0
35
- ? OperatorIncludes(S, L) === true
36
- ? [L, ...OperatorIntersect(R, S)]
37
- : [...OperatorIntersect(R, S)]
38
- : []);
39
- }
40
- /** Returns the Union of the given sets */
41
- export function OperatorUnion(T, S, Acc = S) {
42
- const [L, ...R] = T;
43
- // prettier-ignore
44
- return (T.length > 0
45
- ? OperatorUnion(R, S, [...Acc, L])
46
- : Acc);
47
- }
48
- /** Returns the Complement by omitting elements in T that are in S */
49
- // prettier-ignore
50
- export function OperatorComplement(T, S, Acc = []) {
51
- const [L, ...R] = T;
52
- return (T.length > 0
53
- ? OperatorIncludes(S, L) === true
54
- ? OperatorComplement(R, S, [...Acc])
55
- : OperatorComplement(R, S, [L, ...Acc])
56
- : Acc);
57
- }
58
- /** Returns the Intersect of multiple sets */
59
- // prettier-ignore
60
- export function OperatorIntersectMany(T, Acc = []) {
61
- return (T.length === 1
62
- ? T[0]
63
- : (() => {
64
- const [L, ...R] = T;
65
- return (L.length > 0
66
- ? OperatorIntersect(L, OperatorIntersectMany(R))
67
- : []);
68
- })());
69
- }
70
- /** Returns the Union of multiple sets */
71
- export function OperatorUnionMany(T, Acc = []) {
72
- const [L, ...R] = T;
73
- // prettier-ignore
74
- return (T.length > 0
75
- ? OperatorUnionMany(R, OperatorUnion(Acc, L))
76
- : Acc);
77
- }
@@ -1 +0,0 @@
1
- export * from './operators';
@@ -1,24 +0,0 @@
1
- export type TOperatorIncludes<T extends PropertyKey[], S extends PropertyKey> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? S extends L ? true : TOperatorIncludes<R, S> : false);
2
- /** Returns true if element S is in the set of T */
3
- export declare function OperatorIncludes<T extends PropertyKey[], S extends PropertyKey>(T: [...T], S: S): TOperatorIncludes<T, S>;
4
- export type TOperatorSubset<T extends PropertyKey[], S extends PropertyKey[]> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorSubset<R, S> : false : true);
5
- /** Returns true if T is a subset of S */
6
- export declare function OperatorSubset<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorSubset<T, S>;
7
- export type TOperatorDistinct<T extends PropertyKey[], Acc extends PropertyKey[] = []> = T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<Acc, L> extends false ? TOperatorDistinct<R, [...Acc, L]> : TOperatorDistinct<R, [...Acc]> : Acc;
8
- /** Returns a distinct set of elements */
9
- export declare function OperatorDistinct<T extends PropertyKey[]>(T: [...T], Acc?: PropertyKey[]): TOperatorDistinct<T>;
10
- export type TOperatorIntersect<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? TOperatorIntersect<R, S, [L, ...Acc]> : TOperatorIntersect<R, S, [...Acc]> : Acc);
11
- /** Returns the Intersect of the given sets */
12
- export declare function OperatorIntersect<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S]): TOperatorIntersect<T, S>;
13
- export type TOperatorUnion<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = S> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorUnion<R, S, [...Acc, L]> : Acc);
14
- /** Returns the Union of the given sets */
15
- export declare function OperatorUnion<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): TOperatorUnion<T, S>;
16
- export type OperatorComplement<T extends PropertyKey[], S extends PropertyKey[], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TOperatorIncludes<S, L> extends true ? OperatorComplement<R, S, [...Acc]> : OperatorComplement<R, S, [L, ...Acc]> : Acc);
17
- /** Returns the Complement by omitting elements in T that are in S */
18
- export declare function OperatorComplement<T extends PropertyKey[], S extends PropertyKey[]>(T: [...T], S: [...S], Acc?: PropertyKey[]): OperatorComplement<T, S>;
19
- export type OperatorIntersectMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[]] ? L : T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorIntersectMany<R, TOperatorIntersect<Acc, L>> : Acc);
20
- /** Returns the Intersect of multiple sets */
21
- export declare function OperatorIntersectMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorIntersectMany<T>;
22
- export type OperatorUnionMany<T extends PropertyKey[][], Acc extends PropertyKey[] = []> = (T extends [infer L extends PropertyKey[], ...infer R extends PropertyKey[][]] ? OperatorUnionMany<R, TOperatorUnion<Acc, L>> : Acc);
23
- /** Returns the Union of multiple sets */
24
- export declare function OperatorUnionMany<T extends PropertyKey[][]>(T: [...T], Acc?: PropertyKey[]): OperatorUnionMany<T>;