@sinclair/typebox 0.32.0-dev-26 → 0.32.0-dev-28

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 (256) hide show
  1. package/build/import/compiler/compiler.mjs +7 -0
  2. package/build/import/errors/errors.d.mts +16 -15
  3. package/build/import/errors/errors.mjs +24 -15
  4. package/build/import/errors/function.mjs +2 -0
  5. package/build/import/index.d.mts +2 -2
  6. package/build/import/type/awaited/awaited.mjs +2 -6
  7. package/build/import/type/clone/value.mjs +6 -2
  8. package/build/import/type/composite/composite.d.mts +1 -2
  9. package/build/import/type/composite/composite.mjs +2 -2
  10. package/build/import/type/const/const.mjs +6 -6
  11. package/build/import/type/constructor/constructor.d.mts +1 -1
  12. package/build/import/type/constructor/constructor.mjs +1 -1
  13. package/build/import/type/deref/deref.mjs +1 -2
  14. package/build/import/type/discard/discard.mjs +2 -2
  15. package/build/import/type/enum/enum.mjs +3 -0
  16. package/build/import/type/exclude/exclude-from-mapped-result.d.mts +5 -5
  17. package/build/import/type/exclude/exclude-from-mapped-result.mjs +7 -7
  18. package/build/import/type/exclude/exclude.mjs +0 -1
  19. package/build/import/type/extends/extends-check.mjs +137 -125
  20. package/build/import/type/extends/extends-from-mapped-key.d.mts +1 -1
  21. package/build/import/type/extends/extends-from-mapped-key.mjs +4 -5
  22. package/build/import/type/extends/extends-from-mapped-result.d.mts +5 -5
  23. package/build/import/type/extends/extends-from-mapped-result.mjs +7 -7
  24. package/build/import/type/extends/extends.mjs +0 -1
  25. package/build/import/type/extract/extract-from-mapped-result.d.mts +5 -5
  26. package/build/import/type/extract/extract-from-mapped-result.mjs +7 -7
  27. package/build/import/type/extract/extract.d.mts +1 -2
  28. package/build/import/type/extract/extract.mjs +4 -2
  29. package/build/import/type/guard/type.d.mts +3 -0
  30. package/build/import/type/guard/type.mjs +10 -0
  31. package/build/import/type/guard/value.d.mts +2 -0
  32. package/build/import/type/guard/value.mjs +4 -0
  33. package/build/import/type/index.d.mts +1 -1
  34. package/build/import/type/index.mjs +1 -1
  35. package/build/import/type/indexed/indexed-from-mapped-key.d.mts +2 -2
  36. package/build/import/type/indexed/indexed-from-mapped-key.mjs +4 -5
  37. package/build/import/type/indexed/indexed-from-mapped-result.d.mts +1 -1
  38. package/build/import/type/indexed/indexed-property-keys.d.mts +6 -6
  39. package/build/import/type/indexed/indexed-property-keys.mjs +3 -5
  40. package/build/import/type/indexed/indexed.d.mts +1 -1
  41. package/build/import/type/indexed/indexed.mjs +9 -27
  42. package/build/import/type/intersect/intersect-evaluated.mjs +3 -13
  43. package/build/import/type/intrinsic/capitalize.d.mts +2 -2
  44. package/build/import/type/intrinsic/intrinsic-from-mapped-key.d.mts +1 -1
  45. package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -5
  46. package/build/import/type/intrinsic/intrinsic.d.mts +2 -3
  47. package/build/import/type/intrinsic/intrinsic.mjs +2 -5
  48. package/build/import/type/intrinsic/lowercase.d.mts +2 -2
  49. package/build/import/type/intrinsic/uncapitalize.d.mts +2 -2
  50. package/build/import/type/intrinsic/uppercase.d.mts +2 -2
  51. package/build/import/type/iterator/iterator.mjs +1 -1
  52. package/build/import/type/keyof/keyof-from-mapped-result.d.mts +3 -3
  53. package/build/import/type/keyof/keyof-from-mapped-result.mjs +4 -4
  54. package/build/import/type/keyof/keyof-property-keys.d.mts +3 -3
  55. package/build/import/type/keyof/keyof-property-keys.mjs +9 -15
  56. package/build/import/type/keyof/keyof.mjs +2 -8
  57. package/build/import/type/mapped/mapped.d.mts +6 -1
  58. package/build/import/type/mapped/mapped.mjs +21 -14
  59. package/build/import/type/not/not.mjs +1 -1
  60. package/build/import/type/object/object.d.mts +1 -1
  61. package/build/import/type/object/object.mjs +0 -1
  62. package/build/import/type/omit/index.d.mts +1 -0
  63. package/build/import/type/omit/index.mjs +1 -0
  64. package/build/import/type/omit/omit-from-mapped-key.mjs +4 -5
  65. package/build/import/type/omit/omit-from-mapped-result.d.mts +11 -0
  66. package/build/import/type/omit/omit-from-mapped-result.mjs +17 -0
  67. package/build/import/type/omit/omit.d.mts +6 -3
  68. package/build/import/type/omit/omit.mjs +11 -9
  69. package/build/import/type/optional/optional-from-mapped-result.d.mts +5 -5
  70. package/build/import/type/optional/optional-from-mapped-result.mjs +7 -7
  71. package/build/import/type/partial/partial-from-mapped-result.d.mts +5 -5
  72. package/build/import/type/partial/partial-from-mapped-result.mjs +4 -4
  73. package/build/import/type/partial/partial.d.mts +2 -3
  74. package/build/import/type/partial/partial.mjs +8 -21
  75. package/build/import/type/pick/index.d.mts +1 -0
  76. package/build/import/type/pick/index.mjs +1 -0
  77. package/build/import/type/pick/pick-from-mapped-key.mjs +4 -5
  78. package/build/import/type/pick/pick-from-mapped-result.d.mts +11 -0
  79. package/build/import/type/pick/pick-from-mapped-result.mjs +17 -0
  80. package/build/import/type/pick/pick.d.mts +5 -2
  81. package/build/import/type/pick/pick.mjs +11 -10
  82. package/build/import/type/promise/promise.mjs +1 -1
  83. package/build/import/type/readonly/readonly-from-mapped-result.d.mts +5 -5
  84. package/build/import/type/readonly/readonly-from-mapped-result.mjs +4 -4
  85. package/build/import/type/record/record.d.mts +5 -3
  86. package/build/import/type/record/record.mjs +13 -5
  87. package/build/import/type/ref/ref.mjs +1 -1
  88. package/build/import/type/regexp/regexp.d.mts +11 -4
  89. package/build/import/type/regexp/regexp.mjs +3 -3
  90. package/build/import/type/required/required-from-mapped-result.d.mts +5 -5
  91. package/build/import/type/required/required-from-mapped-result.mjs +7 -7
  92. package/build/import/type/required/required.d.mts +2 -3
  93. package/build/import/type/required/required.mjs +4 -14
  94. package/build/import/type/rest/rest.d.mts +2 -2
  95. package/build/import/type/rest/rest.mjs +1 -2
  96. package/build/import/type/schema/anyschema.d.mts +2 -1
  97. package/build/import/type/sets/index.d.mts +1 -0
  98. package/build/import/type/sets/index.mjs +1 -0
  99. package/build/import/type/sets/set.d.mts +24 -0
  100. package/build/import/type/sets/set.mjs +35 -0
  101. package/build/import/type/strict/strict.d.mts +1 -1
  102. package/build/import/type/strict/strict.mjs +1 -1
  103. package/build/import/type/template-literal/syntax.d.mts +1 -1
  104. package/build/import/type/template-literal/template-literal.d.mts +1 -1
  105. package/build/import/type/transform/transform.mjs +1 -1
  106. package/build/import/type/type/javascript.d.mts +2 -2
  107. package/build/import/type/type/javascript.mjs +1 -1
  108. package/build/import/type/type/json.d.mts +6 -2
  109. package/build/import/type/union/union-evaluated.mjs +3 -14
  110. package/build/import/value/cast/cast.d.mts +2 -15
  111. package/build/import/value/cast/cast.mjs +5 -28
  112. package/build/import/value/check/check.mjs +6 -1
  113. package/build/import/value/convert/convert.d.mts +0 -5
  114. package/build/import/value/convert/convert.mjs +0 -12
  115. package/build/import/value/create/create.d.mts +2 -23
  116. package/build/import/value/create/create.mjs +30 -53
  117. package/build/import/value/default/default.mjs +0 -2
  118. package/build/import/value/delta/delta.d.mts +4 -4
  119. package/build/import/value/delta/delta.mjs +12 -12
  120. package/build/import/value/index.d.mts +7 -7
  121. package/build/import/value/index.mjs +6 -6
  122. package/build/import/value/mutate/mutate.d.mts +2 -5
  123. package/build/import/value/mutate/mutate.mjs +5 -10
  124. package/build/require/compiler/compiler.js +7 -0
  125. package/build/require/errors/errors.d.ts +16 -15
  126. package/build/require/errors/errors.js +24 -15
  127. package/build/require/errors/function.js +2 -0
  128. package/build/require/index.d.ts +2 -2
  129. package/build/require/type/awaited/awaited.js +2 -6
  130. package/build/require/type/clone/value.js +6 -2
  131. package/build/require/type/composite/composite.d.ts +1 -2
  132. package/build/require/type/composite/composite.js +5 -6
  133. package/build/require/type/const/const.js +6 -6
  134. package/build/require/type/constructor/constructor.d.ts +1 -1
  135. package/build/require/type/constructor/constructor.js +1 -1
  136. package/build/require/type/deref/deref.js +0 -1
  137. package/build/require/type/discard/discard.js +2 -2
  138. package/build/require/type/enum/enum.js +3 -0
  139. package/build/require/type/exclude/exclude-from-mapped-result.d.ts +5 -5
  140. package/build/require/type/exclude/exclude-from-mapped-result.js +7 -7
  141. package/build/require/type/exclude/exclude.js +0 -1
  142. package/build/require/type/extends/extends-check.js +137 -125
  143. package/build/require/type/extends/extends-from-mapped-key.d.ts +1 -1
  144. package/build/require/type/extends/extends-from-mapped-key.js +4 -5
  145. package/build/require/type/extends/extends-from-mapped-result.d.ts +5 -5
  146. package/build/require/type/extends/extends-from-mapped-result.js +7 -7
  147. package/build/require/type/extends/extends.js +0 -1
  148. package/build/require/type/extract/extract-from-mapped-result.d.ts +5 -5
  149. package/build/require/type/extract/extract-from-mapped-result.js +7 -7
  150. package/build/require/type/extract/extract.d.ts +1 -2
  151. package/build/require/type/extract/extract.js +4 -3
  152. package/build/require/type/guard/type.d.ts +3 -0
  153. package/build/require/type/guard/type.js +12 -1
  154. package/build/require/type/guard/value.d.ts +2 -0
  155. package/build/require/type/guard/value.js +6 -1
  156. package/build/require/type/index.d.ts +1 -1
  157. package/build/require/type/index.js +1 -1
  158. package/build/require/type/indexed/indexed-from-mapped-key.d.ts +2 -2
  159. package/build/require/type/indexed/indexed-from-mapped-key.js +4 -5
  160. package/build/require/type/indexed/indexed-from-mapped-result.d.ts +1 -1
  161. package/build/require/type/indexed/indexed-property-keys.d.ts +6 -6
  162. package/build/require/type/indexed/indexed-property-keys.js +3 -5
  163. package/build/require/type/indexed/indexed.d.ts +1 -1
  164. package/build/require/type/indexed/indexed.js +9 -27
  165. package/build/require/type/intersect/intersect-evaluated.js +3 -13
  166. package/build/require/type/intrinsic/capitalize.d.ts +2 -2
  167. package/build/require/type/intrinsic/intrinsic-from-mapped-key.d.ts +1 -1
  168. package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +4 -5
  169. package/build/require/type/intrinsic/intrinsic.d.ts +2 -3
  170. package/build/require/type/intrinsic/intrinsic.js +2 -5
  171. package/build/require/type/intrinsic/lowercase.d.ts +2 -2
  172. package/build/require/type/intrinsic/uncapitalize.d.ts +2 -2
  173. package/build/require/type/intrinsic/uppercase.d.ts +2 -2
  174. package/build/require/type/iterator/iterator.js +1 -1
  175. package/build/require/type/keyof/keyof-from-mapped-result.d.ts +3 -3
  176. package/build/require/type/keyof/keyof-from-mapped-result.js +4 -4
  177. package/build/require/type/keyof/keyof-property-keys.d.ts +3 -3
  178. package/build/require/type/keyof/keyof-property-keys.js +9 -15
  179. package/build/require/type/keyof/keyof.js +2 -8
  180. package/build/require/type/mapped/mapped.d.ts +6 -1
  181. package/build/require/type/mapped/mapped.js +21 -14
  182. package/build/require/type/not/not.js +1 -1
  183. package/build/require/type/object/object.d.ts +1 -1
  184. package/build/require/type/object/object.js +0 -1
  185. package/build/require/type/omit/index.d.ts +1 -0
  186. package/build/require/type/omit/index.js +1 -0
  187. package/build/require/type/omit/omit-from-mapped-key.js +4 -5
  188. package/build/require/type/omit/omit-from-mapped-result.d.ts +11 -0
  189. package/build/require/type/omit/omit-from-mapped-result.js +22 -0
  190. package/build/require/type/omit/omit.d.ts +6 -3
  191. package/build/require/type/omit/omit.js +10 -8
  192. package/build/require/type/optional/optional-from-mapped-result.d.ts +5 -5
  193. package/build/require/type/optional/optional-from-mapped-result.js +7 -7
  194. package/build/require/type/partial/partial-from-mapped-result.d.ts +5 -5
  195. package/build/require/type/partial/partial-from-mapped-result.js +4 -4
  196. package/build/require/type/partial/partial.d.ts +2 -3
  197. package/build/require/type/partial/partial.js +8 -21
  198. package/build/require/type/pick/index.d.ts +1 -0
  199. package/build/require/type/pick/index.js +1 -0
  200. package/build/require/type/pick/pick-from-mapped-key.js +4 -5
  201. package/build/require/type/pick/pick-from-mapped-result.d.ts +11 -0
  202. package/build/require/type/pick/pick-from-mapped-result.js +22 -0
  203. package/build/require/type/pick/pick.d.ts +5 -2
  204. package/build/require/type/pick/pick.js +10 -9
  205. package/build/require/type/promise/promise.js +1 -1
  206. package/build/require/type/readonly/readonly-from-mapped-result.d.ts +5 -5
  207. package/build/require/type/readonly/readonly-from-mapped-result.js +4 -4
  208. package/build/require/type/record/record.d.ts +5 -3
  209. package/build/require/type/record/record.js +12 -4
  210. package/build/require/type/ref/ref.js +1 -1
  211. package/build/require/type/regexp/regexp.d.ts +11 -4
  212. package/build/require/type/regexp/regexp.js +3 -3
  213. package/build/require/type/required/required-from-mapped-result.d.ts +5 -5
  214. package/build/require/type/required/required-from-mapped-result.js +7 -7
  215. package/build/require/type/required/required.d.ts +2 -3
  216. package/build/require/type/required/required.js +4 -14
  217. package/build/require/type/rest/rest.d.ts +2 -2
  218. package/build/require/type/rest/rest.js +1 -3
  219. package/build/require/type/schema/anyschema.d.ts +2 -1
  220. package/build/require/type/sets/index.d.ts +1 -0
  221. package/build/require/type/{operators → sets}/index.js +1 -1
  222. package/build/require/type/sets/set.d.ts +24 -0
  223. package/build/require/type/sets/set.js +47 -0
  224. package/build/require/type/strict/strict.d.ts +1 -1
  225. package/build/require/type/strict/strict.js +1 -1
  226. package/build/require/type/template-literal/parse.js +1 -1
  227. package/build/require/type/template-literal/syntax.d.ts +1 -1
  228. package/build/require/type/template-literal/template-literal.d.ts +1 -1
  229. package/build/require/type/transform/transform.js +1 -1
  230. package/build/require/type/type/javascript.d.ts +2 -2
  231. package/build/require/type/type/javascript.js +1 -1
  232. package/build/require/type/type/json.d.ts +6 -2
  233. package/build/require/type/union/union-evaluated.js +3 -14
  234. package/build/require/value/cast/cast.d.ts +2 -15
  235. package/build/require/value/cast/cast.js +7 -29
  236. package/build/require/value/check/check.js +6 -1
  237. package/build/require/value/convert/convert.d.ts +0 -5
  238. package/build/require/value/convert/convert.js +31 -43
  239. package/build/require/value/create/create.d.ts +2 -23
  240. package/build/require/value/create/create.js +32 -54
  241. package/build/require/value/default/default.js +0 -2
  242. package/build/require/value/delta/delta.d.ts +4 -4
  243. package/build/require/value/delta/delta.js +14 -14
  244. package/build/require/value/index.d.ts +7 -7
  245. package/build/require/value/index.js +8 -19
  246. package/build/require/value/mutate/mutate.d.ts +2 -5
  247. package/build/require/value/mutate/mutate.js +7 -13
  248. package/package.json +1 -1
  249. package/readme.md +68 -67
  250. package/build/import/type/operators/index.d.mts +0 -1
  251. package/build/import/type/operators/index.mjs +0 -1
  252. package/build/import/type/operators/operators.d.mts +0 -24
  253. package/build/import/type/operators/operators.mjs +0 -77
  254. package/build/require/type/operators/index.d.ts +0 -1
  255. package/build/require/type/operators/operators.d.ts +0 -24
  256. package/build/require/type/operators/operators.js +0 -89
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Mutate = exports.ValueMutateInvalidRootMutationError = exports.ValueMutateTypeMismatchError = void 0;
4
+ exports.Mutate = exports.ValueMutateError = void 0;
5
5
  const index_1 = require("../guard/index");
6
6
  const index_2 = require("../pointer/index");
7
7
  const index_3 = require("../clone/index");
@@ -9,18 +9,12 @@ const index_4 = require("../../type/error/index");
9
9
  // ------------------------------------------------------------------
10
10
  // Errors
11
11
  // ------------------------------------------------------------------
12
- class ValueMutateTypeMismatchError extends index_4.TypeBoxError {
13
- constructor() {
14
- super('Cannot assign due type mismatch of assignable values');
12
+ class ValueMutateError extends index_4.TypeBoxError {
13
+ constructor(message) {
14
+ super(message);
15
15
  }
16
16
  }
17
- exports.ValueMutateTypeMismatchError = ValueMutateTypeMismatchError;
18
- class ValueMutateInvalidRootMutationError extends index_4.TypeBoxError {
19
- constructor() {
20
- super('Only object and array types can be mutated at the root level');
21
- }
22
- }
23
- exports.ValueMutateInvalidRootMutationError = ValueMutateInvalidRootMutationError;
17
+ exports.ValueMutateError = ValueMutateError;
24
18
  function ObjectType(root, path, current, next) {
25
19
  if (!(0, index_1.IsPlainObject)(current)) {
26
20
  index_2.ValuePointer.Set(root, path, (0, index_3.Clone)(next));
@@ -96,9 +90,9 @@ function IsMismatchedValue(current, next) {
96
90
  /** `[Mutable]` Performs a deep mutable value assignment while retaining internal references */
97
91
  function Mutate(current, next) {
98
92
  if (IsNonMutableValue(current) || IsNonMutableValue(next))
99
- throw new ValueMutateInvalidRootMutationError();
93
+ throw new ValueMutateError('Only object and array types can be mutated at the root level');
100
94
  if (IsMismatchedValue(current, next))
101
- throw new ValueMutateTypeMismatchError();
95
+ throw new ValueMutateError('Cannot assign due type mismatch of assignable values');
102
96
  Visit(current, '', current, next);
103
97
  }
104
98
  exports.Mutate = Mutate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinclair/typebox",
3
- "version": "0.32.0-dev-26",
3
+ "version": "0.32.0-dev-28",
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
 
@@ -605,9 +605,10 @@ TypeBox provides an extended type set that can be used to create schematics for
605
605
  │ │ │ } │
606
606
  │ │ │ │
607
607
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
608
- │ const T = Type.RegExp(/abc/) │ type T = string │ const T = { │
609
- │ │ │ type: 'string' │
610
- │ │ │ pattern: 'abc'
608
+ │ const T = Type.RegExp(/abc/i) │ type T = string │ const T = { │
609
+ │ │ │ type: 'RegExp' │
610
+ │ │ │ source: 'abc'
611
+ │ │ │ flags: 'i' │
611
612
  │ │ │ } │
612
613
  │ │ │ │
613
614
  ├────────────────────────────────┼─────────────────────────────┼────────────────────────────────┤
@@ -1709,35 +1710,35 @@ This benchmark measures compilation performance for varying types.
1709
1710
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┐
1710
1711
  │ (index) │ Iterations │ Ajv │ TypeCompiler │ Performance │
1711
1712
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┤
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' │
1713
+ │ Literal_String │ 1000 │ ' 242 ms' │ ' 10 ms' │ ' 24.20 x' │
1714
+ │ Literal_Number │ 1000 │ ' 200 ms' │ ' 8 ms' │ ' 25.00 x' │
1715
+ │ Literal_Boolean │ 1000 │ ' 168 ms' │ ' 6 ms' │ ' 28.00 x' │
1716
+ │ Primitive_Number │ 1000 │ ' 165 ms' │ ' 8 ms' │ ' 20.63 x' │
1717
+ │ Primitive_String │ 1000 │ ' 154 ms' │ ' 6 ms' │ ' 25.67 x' │
1718
+ │ Primitive_String_Pattern │ 1000 │ ' 208 ms' │ ' 14 ms' │ ' 14.86 x' │
1719
+ │ Primitive_Boolean │ 1000 │ ' 142 ms' │ ' 6 ms' │ ' 23.67 x' │
1720
+ │ Primitive_Null │ 1000 │ ' 143 ms' │ ' 6 ms' │ ' 23.83 x' │
1721
+ │ Object_Unconstrained │ 1000 │ ' 1217 ms' │ ' 31 ms' │ ' 39.26 x' │
1722
+ │ Object_Constrained │ 1000 │ ' 1275 ms' │ ' 26 ms' │ ' 49.04 x' │
1723
+ │ Object_Vector3 │ 1000 │ ' 405 ms' │ ' 12 ms' │ ' 33.75 x' │
1724
+ │ Object_Box3D │ 1000 │ ' 1833 ms' │ ' 27 ms' │ ' 67.89 x' │
1725
+ │ Tuple_Primitive │ 1000 │ ' 475 ms' │ ' 13 ms' │ ' 36.54 x' │
1726
+ │ Tuple_Object │ 1000 │ ' 1267 ms' │ ' 30 ms' │ ' 42.23 x' │
1727
+ │ Composite_Intersect │ 1000 │ ' 604 ms' │ ' 18 ms' │ ' 33.56 x' │
1728
+ │ Composite_Union │ 1000 │ ' 545 ms' │ ' 20 ms' │ ' 27.25 x' │
1729
+ │ Math_Vector4 │ 1000 │ ' 829 ms' │ ' 12 ms' │ ' 69.08 x' │
1730
+ │ Math_Matrix4 │ 1000 │ ' 405 ms' │ ' 10 ms' │ ' 40.50 x' │
1731
+ │ Array_Primitive_Number │ 1000 │ ' 372 ms' │ ' 12 ms' │ ' 31.00 x' │
1732
+ │ Array_Primitive_String │ 1000 │ ' 327 ms' │ ' 5 ms' │ ' 65.40 x' │
1733
+ │ Array_Primitive_Boolean │ 1000 │ ' 300 ms' │ ' 4 ms' │ ' 75.00 x' │
1734
+ │ Array_Object_Unconstrained │ 1000 │ ' 1755 ms' │ ' 21 ms' │ ' 83.57 x' │
1735
+ │ Array_Object_Constrained │ 1000 │ ' 1516 ms' │ ' 20 ms' │ ' 75.80 x' │
1736
+ │ Array_Tuple_Primitive │ 1000 │ ' 825 ms' │ ' 14 ms' │ ' 58.93 x' │
1737
+ │ Array_Tuple_Object │ 1000 │ ' 1616 ms' │ ' 16 ms' │ ' 101.00 x' │
1738
+ │ Array_Composite_Intersect │ 1000 │ ' 776 ms' │ ' 16 ms' │ ' 48.50 x' │
1739
+ │ Array_Composite_Union │ 1000 │ ' 820 ms' │ ' 14 ms' │ ' 58.57 x' │
1740
+ │ Array_Math_Vector4 │ 1000 │ ' 1166 ms' │ ' 15 ms' │ ' 77.73 x' │
1741
+ │ Array_Math_Matrix4 │ 1000 │ ' 695 ms' │ ' 8 ms' │ ' 86.88 x' │
1741
1742
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┘
1742
1743
  ```
1743
1744
 
@@ -1751,37 +1752,37 @@ This benchmark measures validation performance for varying types.
1751
1752
  ┌────────────────────────────┬────────────┬──────────────┬──────────────┬──────────────┬──────────────┐
1752
1753
  │ (index) │ Iterations │ ValueCheck │ Ajv │ TypeCompiler │ Performance │
1753
1754
  ├────────────────────────────┼────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
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' │
1755
+ │ Literal_String │ 1000000 │ ' 18 ms' │ ' 5 ms' │ ' 4 ms' │ ' 1.25 x' │
1756
+ │ Literal_Number │ 1000000 │ ' 16 ms' │ ' 18 ms' │ ' 10 ms' │ ' 1.80 x' │
1757
+ │ Literal_Boolean │ 1000000 │ ' 15 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1758
+ │ Primitive_Number │ 1000000 │ ' 21 ms' │ ' 19 ms' │ ' 10 ms' │ ' 1.90 x' │
1759
+ │ Primitive_String │ 1000000 │ ' 22 ms' │ ' 18 ms' │ ' 9 ms' │ ' 2.00 x' │
1760
+ │ Primitive_String_Pattern │ 1000000 │ ' 155 ms' │ ' 41 ms' │ ' 34 ms' │ ' 1.21 x' │
1761
+ │ Primitive_Boolean │ 1000000 │ ' 18 ms' │ ' 17 ms' │ ' 9 ms' │ ' 1.89 x' │
1761
1762
  │ 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' │
1763
+ │ Object_Unconstrained │ 1000000 │ ' 1003 ms' │ ' 32 ms' │ ' 24 ms' │ ' 1.33 x' │
1764
+ │ Object_Constrained │ 1000000 │ ' 1265 ms' │ ' 49 ms' │ ' 38 ms' │ ' 1.29 x' │
1765
+ │ Object_Vector3 │ 1000000 │ ' 418 ms' │ ' 22 ms' │ ' 13 ms' │ ' 1.69 x' │
1766
+ │ Object_Box3D │ 1000000 │ ' 2035 ms' │ ' 56 ms' │ ' 49 ms' │ ' 1.14 x' │
1767
+ │ Object_Recursive │ 1000000 │ ' 5243 ms' │ ' 326 ms' │ ' 157 ms' │ ' 2.08 x' │
1768
+ │ Tuple_Primitive │ 1000000 │ ' 153 ms' │ ' 20 ms' │ ' 12 ms' │ ' 1.67 x' │
1769
+ │ Tuple_Object │ 1000000 │ ' 781 ms' │ ' 28 ms' │ ' 18 ms' │ ' 1.56 x' │
1770
+ │ Composite_Intersect │ 1000000 │ ' 742 ms' │ ' 25 ms' │ ' 14 ms' │ ' 1.79 x' │
1771
+ │ Composite_Union │ 1000000 │ ' 558 ms' │ ' 24 ms' │ ' 13 ms' │ ' 1.85 x' │
1772
+ │ Math_Vector4 │ 1000000 │ ' 246 ms' │ ' 22 ms' │ ' 11 ms' │ ' 2.00 x' │
1773
+ │ Math_Matrix4 │ 1000000 │ ' 1052 ms' │ ' 43 ms' │ ' 28 ms' │ ' 1.54 x' │
1774
+ │ Array_Primitive_Number │ 1000000 │ ' 272 ms' │ ' 22 ms' │ ' 12 ms' │ ' 1.83 x' │
1775
+ │ Array_Primitive_String │ 1000000 │ ' 235 ms' │ ' 24 ms' │ ' 14 ms' │ ' 1.71 x' │
1776
+ │ Array_Primitive_Boolean │ 1000000 │ ' 134 ms' │ ' 23 ms' │ ' 14 ms' │ ' 1.64 x' │
1777
+ │ Array_Object_Unconstrained │ 1000000 │ ' 6280 ms' │ ' 65 ms' │ ' 59 ms' │ ' 1.10 x' │
1778
+ │ Array_Object_Constrained │ 1000000 │ ' 6076 ms' │ ' 130 ms' │ ' 119 ms' │ ' 1.09 x' │
1779
+ │ Array_Object_Recursive │ 1000000 │ ' 22738 ms' │ ' 1730 ms' │ ' 635 ms' │ ' 2.72 x' │
1780
+ │ Array_Tuple_Primitive │ 1000000 │ ' 689 ms' │ ' 35 ms' │ ' 30 ms' │ ' 1.17 x' │
1781
+ │ Array_Tuple_Object │ 1000000 │ ' 3266 ms' │ ' 63 ms' │ ' 52 ms' │ ' 1.21 x' │
1782
+ │ Array_Composite_Intersect │ 1000000 │ ' 3310 ms' │ ' 44 ms' │ ' 36 ms' │ ' 1.22 x' │
1783
+ │ Array_Composite_Union │ 1000000 │ ' 2432 ms' │ ' 69 ms' │ ' 33 ms' │ ' 2.09 x' │
1784
+ │ Array_Math_Vector4 │ 1000000 │ ' 1158 ms' │ ' 37 ms' │ ' 24 ms' │ ' 1.54 x' │
1785
+ │ Array_Math_Matrix4 │ 1000000 │ ' 5435 ms' │ ' 132 ms' │ ' 92 ms' │ ' 1.43 x' │
1785
1786
  └────────────────────────────┴────────────┴──────────────┴──────────────┴──────────────┴──────────────┘
1786
1787
  ```
1787
1788
 
@@ -1795,11 +1796,11 @@ The following table lists esbuild compiled and minified sizes for each TypeBox m
1795
1796
  ┌──────────────────────┬────────────┬────────────┬─────────────┐
1796
1797
  │ (index) │ Compiled │ Minified │ Compression │
1797
1798
  ├──────────────────────┼────────────┼────────────┼─────────────┤
1798
- │ typebox/compiler │ '120.7 kb' │ ' 53.0 kb' │ '2.28 x' │
1799
- │ typebox/errors │ ' 55.8 kb' │ ' 25.5 kb' │ '2.19 x' │
1799
+ │ typebox/compiler │ '120.6 kb' │ ' 52.9 kb' │ '2.28 x' │
1800
+ │ typebox/errors │ ' 55.7 kb' │ ' 25.5 kb' │ '2.19 x' │
1800
1801
  │ typebox/system │ ' 4.7 kb' │ ' 2.0 kb' │ '2.33 x' │
1801
- │ typebox/value │ '147.6 kb' │ ' 62.5 kb' │ '2.36 x' │
1802
- │ typebox │ ' 91.3 kb' │ ' 38.0 kb' │ '2.40 x' │
1802
+ │ typebox/value │ '146.2 kb' │ ' 62.0 kb' │ '2.36 x' │
1803
+ │ typebox │ ' 91.4 kb' │ ' 37.8 kb' │ '2.42 x' │
1803
1804
  └──────────────────────┴────────────┴────────────┴─────────────┘
1804
1805
  ```
1805
1806
 
@@ -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>;
@@ -1,89 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.OperatorUnionMany = exports.OperatorIntersectMany = exports.OperatorComplement = exports.OperatorUnion = exports.OperatorIntersect = exports.OperatorDistinct = exports.OperatorSubset = exports.OperatorIncludes = void 0;
5
- /** Returns true if element S is in the set of T */
6
- // prettier-ignore
7
- function OperatorIncludes(T, S) {
8
- const [L, ...R] = T;
9
- return (T.length > 0
10
- ? S === L
11
- ? true
12
- : OperatorIncludes(R, S)
13
- : false);
14
- }
15
- exports.OperatorIncludes = OperatorIncludes;
16
- /** Returns true if T is a subset of S */
17
- function OperatorSubset(T, S) {
18
- const [L, ...R] = T;
19
- // prettier-ignore
20
- return (T.length > 0
21
- ? OperatorIncludes(S, L) === true
22
- ? OperatorSubset(R, S)
23
- : false
24
- : true);
25
- }
26
- exports.OperatorSubset = OperatorSubset;
27
- /** Returns a distinct set of elements */
28
- function OperatorDistinct(T, Acc = []) {
29
- const [L, ...R] = T;
30
- // prettier-ignore
31
- return (T.length > 0 ?
32
- (OperatorIncludes(Acc, L) === false
33
- ? OperatorDistinct(R, [...Acc, L])
34
- : OperatorDistinct(R, [...Acc])) : Acc);
35
- }
36
- exports.OperatorDistinct = OperatorDistinct;
37
- /** Returns the Intersect of the given sets */
38
- function OperatorIntersect(T, S) {
39
- const [L, ...R] = T;
40
- // prettier-ignore
41
- return (T.length > 0
42
- ? OperatorIncludes(S, L) === true
43
- ? [L, ...OperatorIntersect(R, S)]
44
- : [...OperatorIntersect(R, S)]
45
- : []);
46
- }
47
- exports.OperatorIntersect = OperatorIntersect;
48
- /** Returns the Union of the given sets */
49
- function OperatorUnion(T, S, Acc = S) {
50
- const [L, ...R] = T;
51
- // prettier-ignore
52
- return (T.length > 0
53
- ? OperatorUnion(R, S, [...Acc, L])
54
- : Acc);
55
- }
56
- exports.OperatorUnion = OperatorUnion;
57
- /** Returns the Complement by omitting elements in T that are in S */
58
- // prettier-ignore
59
- function OperatorComplement(T, S, Acc = []) {
60
- const [L, ...R] = T;
61
- return (T.length > 0
62
- ? OperatorIncludes(S, L) === true
63
- ? OperatorComplement(R, S, [...Acc])
64
- : OperatorComplement(R, S, [L, ...Acc])
65
- : Acc);
66
- }
67
- exports.OperatorComplement = OperatorComplement;
68
- /** Returns the Intersect of multiple sets */
69
- // prettier-ignore
70
- function OperatorIntersectMany(T, Acc = []) {
71
- return (T.length === 1
72
- ? T[0]
73
- : (() => {
74
- const [L, ...R] = T;
75
- return (L.length > 0
76
- ? OperatorIntersect(L, OperatorIntersectMany(R))
77
- : []);
78
- })());
79
- }
80
- exports.OperatorIntersectMany = OperatorIntersectMany;
81
- /** Returns the Union of multiple sets */
82
- function OperatorUnionMany(T, Acc = []) {
83
- const [L, ...R] = T;
84
- // prettier-ignore
85
- return (T.length > 0
86
- ? OperatorUnionMany(R, OperatorUnion(Acc, L))
87
- : Acc);
88
- }
89
- exports.OperatorUnionMany = OperatorUnionMany;